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

/* Variables and functions */
int /*<<< orphan*/ add_to_list(struct llist_t *, int);
int atoi(char *);
int /*<<< orphan*/ free_list(struct llist_t *);
int /*<<< orphan*/ make_list(struct llist_t **);
int /*<<< orphan*/ print_list(struct llist_t *);
int /*<<< orphan*/ print_list_backwards(struct llist_t *);
int main(int argc, char **argsv) {
  struct llist_t *myList;
  int i, a;
  make_list(&myList);
  for (i = 1; i < argc; i++) {
    a = atoi(argsv[i]);
    add_to_list(myList, a);
  }
  print_list(myList);
  print_list_backwards(myList);
  free_list(myList);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
call   1040 <make_list@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c0 <main+0x60>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1070 <add_to_list@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1186 <main+0x26>
mov    -0x18(%rbp),%rdi
call   1030 <print_list@plt>
mov    -0x18(%rbp),%rdi
call   1060 <print_list_backwards@plt>
mov    -0x18(%rbp),%rdi
call   1050 <free_list@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
lea    0x8(%rsp),%rdi
call   1040 <make_list@plt>
cmp    $0x2,%ebp
jl     11ae <main+0x4e>
mov    %ebp,%ebp
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r14,%rbx,8),%rdi
call   1080 <atoi@plt>
mov    0x8(%rsp),%rdi
mov    %eax,%esi
call   1070 <add_to_list@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1190 <main+0x30>
mov    0x8(%rsp),%rdi
call   1030 <print_list@plt>
mov    0x8(%rsp),%rdi
call   1060 <print_list_backwards@plt>
mov    0x8(%rsp),%rdi
call   1050 <free_list@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.llist_t = type { i32 }
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.llist_t*
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @make_list(%struct.llist_t** %6)
store i32 1, i32* %7
br label %10
10: ; preds = %24, %2
%11 = load i32, i32* %7
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %27
14: ; preds = %10
%15 = load i8**, i8*** %5
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %8
%21 = load %struct.llist_t*, %struct.llist_t** %6
%22 = load i32, i32* %8
%23 = call i32 @add_to_list(%struct.llist_t* %21, i32 %22)
br label %24
24: ; preds = %14
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %10
27: ; preds = %10
%28 = load %struct.llist_t*, %struct.llist_t** %6
%29 = call i32 @print_list(%struct.llist_t* %28)
%30 = load %struct.llist_t*, %struct.llist_t** %6
%31 = call i32 @print_list_backwards(%struct.llist_t* %30)
%32 = load %struct.llist_t*, %struct.llist_t** %6
%33 = call i32 @free_list(%struct.llist_t* %32)
ret i32 0
}

LLVM IR (-O2):
%struct.llist_t = type { i32 }
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.llist_t*
%4 = bitcast %struct.llist_t** %3 to i8*
%5 = call i32 @make_list(%struct.llist_t** %3)
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %18
7: ; preds = %2
%8 = zext i32 %0 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 1, %7 ], [ %16, %9 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
%12 = load i8*, i8** %11
%13 = call i32 @atoi(i8* %12)
%14 = load %struct.llist_t*, %struct.llist_t** %3
%15 = call i32 @add_to_list(%struct.llist_t* %14, i32 %13)
%16 = add nuw nsw i64 %10, 1
%17 = icmp eq i64 %16, %8
br i1 %17, label %18, label %9
18: ; preds = %9, %2
%19 = load %struct.llist_t*, %struct.llist_t** %3
%20 = call i32 @print_list(%struct.llist_t* %19)
%21 = load %struct.llist_t*, %struct.llist_t** %3
%22 = call i32 @print_list_backwards(%struct.llist_t* %21)
%23 = load %struct.llist_t*, %struct.llist_t** %3
%24 = call i32 @free_list(%struct.llist_t* %23)
ret i32 0
}