1  /* { dg-additional-options "-Wno-analyzer-too-complex -fno-analyzer-call-summaries" } */
       2  
       3  #include <stdbool.h>
       4  #include <stddef.h>
       5  #include <stdlib.h>
       6  
       7  struct list {
       8  	struct list* next;
       9  	void *a;
      10  };
      11  
      12  void func(struct list **res)
      13  {
      14  	struct list *cur = NULL;
      15  	do {
      16  		struct list *n = malloc(sizeof(struct list));
      17  		void *a = malloc(1);
      18  		if (n == NULL || a == NULL) {
      19  			if (n != NULL) free(n);
      20  			if (a != NULL) free(a);
      21  			break;
      22  		}
      23  
      24  		if (cur == NULL) {
      25  			*res = cur = n;
      26  		} else {
      27  			cur->next = n;
      28  			cur = n;
      29  		}
      30  		n->a = a;
      31  	} while (true);
      32  }
      33  
      34  int main()
      35  {
      36  	struct list *res;
      37  	func(&res);
      38  }