#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*/ deleteNode2(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, 2);
  list = addToList(list, 1);
  iterateList(list);
  deleteNode2(&list, 4);
  if (list) {
    iterateList(list);
    free(list);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%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    $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>
lea    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1060 <deleteNode2@plt>
cmpq   $0x0,-0x10(%rbp)
je     11d3 <main+0x93>
mov    -0x10(%rbp),%rdi
call   1050 <iterateList@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
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    $0x2,%esi
call   1040 <addToList@plt>
mov    %rax,%rdi
mov    $0x1,%esi
call   1040 <addToList@plt>
mov    %rax,(%rsp)
mov    %rax,%rdi
call   1050 <iterateList@plt>
mov    %rsp,%rdi
mov    $0x4,%esi
call   1060 <deleteNode2@plt>
mov    (%rsp),%rdi
test   %rdi,%rdi
je     11a4 <main+0x64>
call   1050 <iterateList@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rcx
ret

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

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