#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct ListNode {
  int dummy;
};

/* Variables and functions */
struct ListNode *addToList(struct ListNode *, int);
int /*<<< orphan*/ free(struct ListNode *);
int /*<<< orphan*/ iterateList(struct ListNode *);
int main(void) {
  struct ListNode *list = NULL;
  list = addToList(list, 5);
  list = addToList(list, 4);
  list = addToList(list, 3);
  list = addToList(list, 2);
  list = addToList(list, 1);
  iterateList(list);
  struct ListNode *deleteone = NULL;
  deleteone = addToList(deleteone, 4);
  if (list) {
    iterateList(list);
    free(list);
  }
  if (deleteone)
    free(deleteone);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x5,%esi
call   1040 <addToList@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1040 <addToList@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3,%esi
call   1040 <addToList@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2,%esi
call   1040 <addToList@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1040 <addToList@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <iterateList@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x4,%esi
call   1040 <addToList@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11e1 <main+0xb1>
mov    -0x10(%rbp),%rdi
call   1050 <iterateList@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x18(%rbp)
je     11f5 <main+0xc5>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
mov    $0x5,%esi
call   1040 <addToList@plt>
mov    %rax,%rdi
mov    $0x4,%esi
call   1040 <addToList@plt>
mov    %rax,%rdi
mov    $0x3,%esi
call   1040 <addToList@plt>
mov    %rax,%rdi
mov    $0x2,%esi
call   1040 <addToList@plt>
mov    %rax,%rdi
mov    $0x1,%esi
call   1040 <addToList@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <iterateList@plt>
xor    %edi,%edi
mov    $0x4,%esi
call   1040 <addToList@plt>
mov    %rax,%r14
test   %rbx,%rbx
je     11a3 <main+0x73>
mov    %rbx,%rdi
call   1050 <iterateList@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
test   %r14,%r14
je     11b0 <main+0x80>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.ListNode = type { i32 }
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.ListNode*
%3 = alloca %struct.ListNode*
store i32 0, i32* %1
store %struct.ListNode* null, %struct.ListNode** %2
%4 = load %struct.ListNode*, %struct.ListNode** %2
%5 = call %struct.ListNode* @addToList(%struct.ListNode* %4, i32 5)
store %struct.ListNode* %5, %struct.ListNode** %2
%6 = load %struct.ListNode*, %struct.ListNode** %2
%7 = call %struct.ListNode* @addToList(%struct.ListNode* %6, i32 4)
store %struct.ListNode* %7, %struct.ListNode** %2
%8 = load %struct.ListNode*, %struct.ListNode** %2
%9 = call %struct.ListNode* @addToList(%struct.ListNode* %8, i32 3)
store %struct.ListNode* %9, %struct.ListNode** %2
%10 = load %struct.ListNode*, %struct.ListNode** %2
%11 = call %struct.ListNode* @addToList(%struct.ListNode* %10, i32 2)
store %struct.ListNode* %11, %struct.ListNode** %2
%12 = load %struct.ListNode*, %struct.ListNode** %2
%13 = call %struct.ListNode* @addToList(%struct.ListNode* %12, i32 1)
store %struct.ListNode* %13, %struct.ListNode** %2
%14 = load %struct.ListNode*, %struct.ListNode** %2
%15 = call i32 @iterateList(%struct.ListNode* %14)
store %struct.ListNode* null, %struct.ListNode** %3
%16 = load %struct.ListNode*, %struct.ListNode** %3
%17 = call %struct.ListNode* @addToList(%struct.ListNode* %16, i32 4)
store %struct.ListNode* %17, %struct.ListNode** %3
%18 = load %struct.ListNode*, %struct.ListNode** %2
%19 = icmp ne %struct.ListNode* %18, null
br i1 %19, label %20, label %25
20: ; preds = %0
%21 = load %struct.ListNode*, %struct.ListNode** %2
%22 = call i32 @iterateList(%struct.ListNode* %21)
%23 = load %struct.ListNode*, %struct.ListNode** %2
%24 = call i32 @free(%struct.ListNode* %23)
br label %25
25: ; preds = %20, %0
%26 = load %struct.ListNode*, %struct.ListNode** %3
%27 = icmp ne %struct.ListNode* %26, null
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load %struct.ListNode*, %struct.ListNode** %3
%30 = call i32 @free(%struct.ListNode* %29)
br label %31
31: ; preds = %28, %25
ret i32 0
}

LLVM IR (-O2):
%struct.ListNode = type { i32 }
define i32 @main() {
%1 = tail call %struct.ListNode* @addToList(%struct.ListNode* null, i32 5)
%2 = tail call %struct.ListNode* @addToList(%struct.ListNode* %1, i32 4)
%3 = tail call %struct.ListNode* @addToList(%struct.ListNode* %2, i32 3)
%4 = tail call %struct.ListNode* @addToList(%struct.ListNode* %3, i32 2)
%5 = tail call %struct.ListNode* @addToList(%struct.ListNode* %4, i32 1)
%6 = tail call i32 @iterateList(%struct.ListNode* %5)
%7 = tail call %struct.ListNode* @addToList(%struct.ListNode* null, i32 4)
%8 = icmp eq %struct.ListNode* %5, null
br i1 %8, label %12, label %9
9: ; preds = %0
%10 = tail call i32 @iterateList(%struct.ListNode* %5)
%11 = tail call i32 @free(%struct.ListNode* %5)
br label %12
12: ; preds = %9, %0
%13 = icmp eq %struct.ListNode* %7, null
br i1 %13, label %16, label %14
14: ; preds = %12
%15 = tail call i32 @free(%struct.ListNode* %7)
br label %16
16: ; preds = %14, %12
ret i32 0
}