#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 */
scalar_t__ EOF;
int /*<<< orphan*/ free_list(struct ListNode *);
struct ListNode *insertionSortList(struct ListNode *);
int /*<<< orphan*/ mk_list(struct ListNode **, int *, int);
int /*<<< orphan*/ print(struct ListNode *);
scalar_t__ scanf(char *, int *);
int main(int argc, char **argv) {
  struct ListNode *head = NULL;
  int a[100], n;
  while (scanf("%d", &n) != EOF) {
    free_list(head);
    for (int i = 0; i < n; ++i)
      scanf("%d", a + i);
    mk_list(&head, a, n);
    head = insertionSortList(head);
    print(head);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe88(%rip),%rdi
lea    -0x1b4(%rbp),%rsi
call   1070 <scanf@plt>
mov    0x2e5d(%rip),%rcx
cmp    (%rcx),%rax
je     121f <main+0xcf>
mov    -0x18(%rbp),%rdi
call   1050 <free_list@plt>
movl   $0x0,-0x1b8(%rbp)
mov    -0x1b8(%rbp),%eax
cmp    -0x1b4(%rbp),%eax
jge    11ee <main+0x9e>
lea    -0x1b0(%rbp),%rsi
movslq -0x1b8(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe2b(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x1b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b8(%rbp)
jmp    11a7 <main+0x57>
lea    -0x1b0(%rbp),%rsi
mov    -0x1b4(%rbp),%edx
lea    -0x18(%rbp),%rdi
call   1060 <mk_list@plt>
mov    -0x18(%rbp),%rdi
call   1030 <insertionSortList@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <print@plt>
jmp    1171 <main+0x21>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a8,%rsp
movq   $0x0,0x8(%rsp)
lea    0xe8f(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x2e66(%rip),%rcx
cmp    (%rcx),%rax
jne    119b <main+0x4b>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
lea    0x10(%rsp),%r14
lea    0xe57(%rip),%r13
lea    0x8(%rsp),%r15
lea    0x4(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1050 <free_list@plt>
mov    0x4(%rsp),%edx
test   %edx,%edx
jle    11fd <main+0xad>
mov    %r14,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r13,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
add    $0x1,%rbp
movslq 0x4(%rsp),%rdx
add    $0x4,%rbx
cmp    %rdx,%rbp
jl     11e0 <main+0x90>
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <mk_list@plt>
mov    0x8(%rsp),%rdi
call   1030 <insertionSortList@plt>
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
call   1040 <print@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    0x2db7(%rip),%rcx
cmp    (%rcx),%rax
je     1187 <main+0x37>
mov    0x8(%rsp),%rdi
jmp    11c0 <main+0x70>

LLVM IR (-O0):
%struct.ListNode = type { i32 }
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.ListNode*
%7 = alloca [100 x i32]
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.ListNode* null, %struct.ListNode** %6
br label %10
10: ; preds = %30, %2
%11 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%12 = load i64, i64* @EOF
%13 = icmp ne i64 %11, %12
br i1 %13, label %14, label %38
14: ; preds = %10
%15 = load %struct.ListNode*, %struct.ListNode** %6
%16 = call i32 @free_list(%struct.ListNode* %15)
store i32 0, i32* %9
br label %17
17: ; preds = %27, %14
%18 = load i32, i32* %9
%19 = load i32, i32* %8
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = getelementptr inbounds [100 x i32], [100 x i32]* %7, i64 0, i64 0
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %25)
br label %27
27: ; preds = %21
%28 = load i32, i32* %9
%29 = add nsw i32 %28, 1
store i32 %29, i32* %9
br label %17
30: ; preds = %17
%31 = getelementptr inbounds [100 x i32], [100 x i32]* %7, i64 0, i64 0
%32 = load i32, i32* %8
%33 = call i32 @mk_list(%struct.ListNode** %6, i32* %31, i32 %32)
%34 = load %struct.ListNode*, %struct.ListNode** %6
%35 = call %struct.ListNode* @insertionSortList(%struct.ListNode* %34)
store %struct.ListNode* %35, %struct.ListNode** %6
%36 = load %struct.ListNode*, %struct.ListNode** %6
%37 = call i32 @print(%struct.ListNode* %36)
br label %10
38: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
%struct.ListNode = type { i32 }
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.ListNode*
%4 = alloca [100 x i32]
%5 = alloca i32
%6 = bitcast %struct.ListNode** %3 to i8*
store %struct.ListNode* null, %struct.ListNode** %3
%7 = bitcast [100 x i32]* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%10 = load i64, i64* @EOF
%11 = icmp eq i64 %9, %10
br i1 %11, label %38, label %12
12: ; preds = %2
%13 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 0
br label %14
14: ; preds = %28, %12
%15 = phi %struct.ListNode* [ %29, %28 ], [ null, %12 ]
%16 = call i32 @free_list(%struct.ListNode* %15)
%17 = load i32, i32* %5
%18 = icmp sgt i32 %17, 0
br i1 %18, label %30, label %19
19: ; preds = %30, %14
%20 = phi i32 [ %17, %14 ], [ %35, %30 ]
%21 = call i32 @mk_list(%struct.ListNode** %3, i32* %13, i32 %20)
%22 = load %struct.ListNode*, %struct.ListNode** %3
%23 = call %struct.ListNode* @insertionSortList(%struct.ListNode* %22)
store %struct.ListNode* %23, %struct.ListNode** %3
%24 = call i32 @print(%struct.ListNode* %23)
%25 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%26 = load i64, i64* @EOF
%27 = icmp eq i64 %25, %26
br i1 %27, label %38, label %28
28: ; preds = %19
%29 = load %struct.ListNode*, %struct.ListNode** %3
br label %14
30: ; preds = %14, %30
%31 = phi i64 [ %34, %30 ], [ 0, %14 ]
%32 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %31
%33 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %32)
%34 = add nuw nsw i64 %31, 1
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = icmp slt i64 %34, %36
br i1 %37, label %30, label %19
38: ; preds = %19, %2
ret i32 0
}