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

/* Variables and functions */
int /*<<< orphan*/ add_to_list(struct list *, struct list *);
int /*<<< orphan*/ clear_list(struct list *);
struct list *create_new_list_elem(int);
int /*<<< orphan*/ print_list(struct list *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int size = 0;
  printf("Enter size: ");
  scanf("%d", &size);
  struct list *head = NULL;
  for (int i = 0; i < size; ++i) {
    int data = 0;
    printf("Enter data: ");
    scanf("%d", &data);
    struct list *new_elem = create_new_list_elem(data);
    if (head == NULL)
      head = new_elem;
    else
      add_to_list(head, new_elem);
  }
  print_list(head);
  clear_list(head);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xe83(%rip),%rdi
call   1040 <printf@plt>
lea    0xe84(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1080 <scanf@plt>
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1214 <main+0xb4>
movl   $0x0,-0x18(%rbp)
lea    0xe55(%rip),%rdi
call   1040 <printf@plt>
lea    0xe46(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x18(%rbp),%edi
call   1060 <create_new_list_elem@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11f4 <main+0x94>
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1201 <main+0xa1>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <add_to_list@plt>
jmp    1206 <main+0xa6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a1 <main+0x41>
mov    -0x10(%rbp),%rdi
call   1030 <print_list@plt>
mov    -0x10(%rbp),%rdi
call   1070 <clear_list@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0x8(%rsp)
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
lea    0xe85(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1080 <scanf@plt>
xor    %ebx,%ebx
cmpl   $0x0,0x8(%rsp)
jle    1202 <main+0xa2>
lea    0xe6e(%rip),%r14
lea    0xe64(%rip),%r15
lea    0xc(%rsp),%r12
xor    %r13d,%r13d
jmp    11d4 <main+0x74>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rdi
mov    %rax,%rsi
call   1050 <add_to_list@plt>
add    $0x1,%ebx
cmp    0x8(%rsp),%ebx
jge    1205 <main+0xa5>
movl   $0x0,0xc(%rsp)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1080 <scanf@plt>
mov    0xc(%rsp),%edi
call   1060 <create_new_list_elem@plt>
test   %r13,%r13
jne    11c0 <main+0x60>
mov    %rax,%r13
jmp    11cb <main+0x6b>
xor    %r13d,%r13d
mov    %r13,%rdi
call   1030 <print_list@plt>
mov    %r13,%rdi
call   1070 <clear_list@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.list = type { i32 }
@.str = [13 x i8] c"Enter size: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"Enter data: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.list*
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.list*
store i32 0, i32* %1
store i32 0, i32* %2
%7 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store %struct.list* null, %struct.list** %3
store i32 0, i32* %4
br label %9
9: ; preds = %27, %0
%10 = load i32, i32* %4
%11 = load i32, i32* %2
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %30
13: ; preds = %9
store i32 0, i32* %5
%14 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%16 = load i32, i32* %5
%17 = call %struct.list* @create_new_list_elem(i32 %16)
store %struct.list* %17, %struct.list** %6
%18 = load %struct.list*, %struct.list** %3
%19 = icmp eq %struct.list* %18, null
br i1 %19, label %20, label %22
20: ; preds = %13
%21 = load %struct.list*, %struct.list** %6
store %struct.list* %21, %struct.list** %3
br label %26
22: ; preds = %13
%23 = load %struct.list*, %struct.list** %3
%24 = load %struct.list*, %struct.list** %6
%25 = call i32 @add_to_list(%struct.list* %23, %struct.list* %24)
br label %26
26: ; preds = %22, %20
br label %27
27: ; preds = %26
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %9
30: ; preds = %9
%31 = load %struct.list*, %struct.list** %3
%32 = call i32 @print_list(%struct.list* %31)
%33 = load %struct.list*, %struct.list** %3
%34 = call i32 @clear_list(%struct.list* %33)
ret i32 0
}

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