#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 node {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ destroyList(struct node *);
int /*<<< orphan*/ insertNode(struct node **, struct node **, int);
int /*<<< orphan*/ printList(struct node *);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char *argv[]) {
  struct node *head = NULL;
  struct node *tail = NULL;
  int value;
  int n;
  scanf("%d", &n);
  while (n > 0) {
    n--;
    scanf("%d", &value);
    insertNode(&head, &tail, value);
  }
  printList(head);
  destroyList(head);
  head = NULL;
  tail = NULL;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
lea    0xe93(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x28(%rbp)
jle    11ae <main+0x6e>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
lea    0xe70(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x24(%rbp),%edx
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <insertNode@plt>
jmp    1176 <main+0x36>
mov    -0x18(%rbp),%rdi
call   1060 <printList@plt>
mov    -0x18(%rbp),%rdi
call   1040 <destroyList@plt>
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
movq   $0x0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
lea    0xe9c(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    11c0 <main+0x80>
lea    0xe83(%rip),%r14
lea    0x1c(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0x20(%rsp),%rbx
nopl   0x0(%rax)
add    $0xffffffff,%eax
mov    %eax,0xc(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    0x1c(%rsp),%edx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <insertNode@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jg     1190 <main+0x50>
mov    0x10(%rsp),%rdi
jmp    11c2 <main+0x82>
xor    %edi,%edi
call   1060 <printList@plt>
mov    0x10(%rsp),%rdi
call   1040 <destroyList@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@.str = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.node*
%7 = alloca %struct.node*
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.node* null, %struct.node** %6
store %struct.node* null, %struct.node** %7
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
br label %11
11: ; preds = %14, %2
%12 = load i32, i32* %9
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = load i32, i32* %9
%16 = add nsw i32 %15, -1
store i32 %16, i32* %9
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%18 = load i32, i32* %8
%19 = call i32 @insertNode(%struct.node** %6, %struct.node** %7, i32 %18)
br label %11
20: ; preds = %11
%21 = load %struct.node*, %struct.node** %6
%22 = call i32 @printList(%struct.node* %21)
%23 = load %struct.node*, %struct.node** %6
%24 = call i32 @destroyList(%struct.node* %23)
store %struct.node* null, %struct.node** %6
store %struct.node* null, %struct.node** %7
ret i32 0
}

LLVM IR (-O2):
%struct.node = type { i32 }
@.str = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.node*
%4 = alloca %struct.node*
%5 = alloca i32
%6 = alloca i32
%7 = bitcast %struct.node** %3 to i8*
store %struct.node* null, %struct.node** %3
%8 = bitcast %struct.node** %4 to i8*
store %struct.node* null, %struct.node** %4
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%12 = load i32, i32* %6
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %24
14: ; preds = %2, %14
%15 = phi i32 [ %20, %14 ], [ %12, %2 ]
%16 = add nsw i32 %15, -1
store i32 %16, i32* %6
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%18 = load i32, i32* %5
%19 = call i32 @insertNode(%struct.node** %3, %struct.node** %4, i32 %18)
%20 = load i32, i32* %6
%21 = icmp sgt i32 %20, 0
br i1 %21, label %14, label %22
22: ; preds = %14
%23 = load %struct.node*, %struct.node** %3
br label %24
24: ; preds = %22, %2
%25 = phi %struct.node* [ %23, %22 ], [ null, %2 ]
%26 = call i32 @printList(%struct.node* %25)
%27 = load %struct.node*, %struct.node** %3
%28 = call i32 @destroyList(%struct.node* %27)
ret i32 0
}