#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*/ insert_beg(struct node **, int);
int /*<<< orphan*/ insert_last(struct node **, int);
int /*<<< orphan*/ insertion_sort(struct node **);
int /*<<< orphan*/ print(struct node *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  struct node *head = NULL;
  int n, v;
  scanf("%d", &n);
  while (n--) {
    scanf("%d", &v);
    if (head == NULL) {
      insert_beg(&head, v);
    } else
      insert_last(&head, v);
  }
  insertion_sort(&head);
  print(head);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xe92(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     11c8 <main+0x78>
lea    0xe6e(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <scanf@plt>
cmpq   $0x0,-0x10(%rbp)
jne    11b7 <main+0x67>
mov    -0x18(%rbp),%esi
lea    -0x10(%rbp),%rdi
call   1030 <insert_beg@plt>
jmp    11c3 <main+0x73>
mov    -0x18(%rbp),%esi
lea    -0x10(%rbp),%rdi
call   1040 <insert_last@plt>
jmp    1177 <main+0x27>
lea    -0x10(%rbp),%rdi
call   1070 <insertion_sort@plt>
mov    -0x10(%rbp),%rdi
call   1050 <print@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movq   $0x0,0x10(%rsp)
lea    0xe97(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
subl   $0x1,0xc(%rsp)
jb     11c2 <main+0x72>
lea    0xe7f(%rip),%r14
lea    0x1c(%rsp),%r15
lea    0x10(%rsp),%rbx
jmp    119c <main+0x4c>
nopl   (%rax)
call   1040 <insert_last@plt>
subl   $0x1,0xc(%rsp)
jb     11c2 <main+0x72>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
cmpq   $0x0,0x10(%rsp)
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
jne    1190 <main+0x40>
call   1030 <insert_beg@plt>
subl   $0x1,0xc(%rsp)
jae    119c <main+0x4c>
lea    0x10(%rsp),%rdi
call   1070 <insertion_sort@plt>
mov    0x10(%rsp),%rdi
call   1050 <print@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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