#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 */
struct node *BuildOneTwoThreeFourFive();
int GetNth(struct node *, int);
int Length(struct node *);
int /*<<< orphan*/ Pop(struct node **);
int /*<<< orphan*/ Push(struct node **, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  struct node *start;
  start = BuildOneTwoThreeFourFive();
  printf("start length is %d\n", Length(start));
  Push(&start, 6);
  printf("start length is %d\n", Length(start));
  int i;
  for (i = 0; i < 6; i++) {
    printf(" %d", GetNth(start, i));
  }
  printf("\n");
  Pop(&start);
  printf("start length is %d\n", Length(start));
  for (i = 0; i < 5; i++) {
    printf(" %d", GetNth(start, i));
  }
  printf("\n");
  Pop(&start);
  printf("start length is %d\n", Length(start));
  for (i = 0; i < 4; i++) {
    printf(" %d", GetNth(start, i));
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <BuildOneTwoThreeFourFive@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <Length@plt>
mov    %eax,%esi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x10(%rbp),%rdi
mov    $0x6,%esi
call   1060 <Push@plt>
mov    -0x10(%rbp),%rdi
call   1070 <Length@plt>
mov    %eax,%esi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jge    11f5 <main+0x95>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1080 <GetNth@plt>
mov    %eax,%esi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c1 <main+0x61>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x10(%rbp),%rdi
call   1050 <Pop@plt>
mov    -0x10(%rbp),%rdi
call   1070 <Length@plt>
mov    %eax,%esi
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    1260 <main+0x100>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1080 <GetNth@plt>
mov    %eax,%esi
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    122c <main+0xcc>
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x10(%rbp),%rdi
call   1050 <Pop@plt>
mov    -0x10(%rbp),%rdi
call   1070 <Length@plt>
mov    %eax,%esi
lea    0xd77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    12cb <main+0x16b>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1080 <GetNth@plt>
mov    %eax,%esi
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1297 <main+0x137>
lea    0xd40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1050 <BuildOneTwoThreeFourFive@plt>
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
call   1080 <Length@plt>
lea    0xe6c(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%r15
mov    %r15,%rdi
mov    $0x6,%esi
call   1070 <Push@plt>
mov    0x8(%rsp),%rdi
call   1080 <Length@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
xor    %esi,%esi
call   1090 <GetNth@plt>
lea    0xe39(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
mov    $0x1,%esi
call   1090 <GetNth@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
mov    $0x2,%esi
call   1090 <GetNth@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
mov    $0x3,%esi
call   1090 <GetNth@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
mov    $0x4,%esi
call   1090 <GetNth@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
mov    $0x5,%esi
call   1090 <GetNth@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
call   1060 <Pop@plt>
mov    0x8(%rsp),%rdi
call   1080 <Length@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
xor    %esi,%esi
call   1090 <GetNth@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
mov    $0x1,%esi
call   1090 <GetNth@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
mov    $0x2,%esi
call   1090 <GetNth@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
mov    $0x3,%esi
call   1090 <GetNth@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
mov    $0x4,%esi
call   1090 <GetNth@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
call   1060 <Pop@plt>
mov    0x8(%rsp),%rdi
call   1080 <Length@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
xor    %esi,%esi
call   1090 <GetNth@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
mov    $0x1,%esi
call   1090 <GetNth@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
mov    $0x2,%esi
call   1090 <GetNth@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
mov    $0x3,%esi
call   1090 <GetNth@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@.str = [20 x i8] c"start length is %d\0A\00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.node*
%3 = alloca i32
store i32 0, i32* %1
%4 = call %struct.node* (...) @BuildOneTwoThreeFourFive()
store %struct.node* %4, %struct.node** %2
%5 = load %struct.node*, %struct.node** %2
%6 = call i32 @Length(%struct.node* %5)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call i32 @Push(%struct.node** %2, i32 6)
%9 = load %struct.node*, %struct.node** %2
%10 = call i32 @Length(%struct.node* %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %10)
store i32 0, i32* %3
br label %12
12: ; preds = %20, %0
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 6
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = load %struct.node*, %struct.node** %2
%17 = load i32, i32* %3
%18 = call i32 @GetNth(%struct.node* %16, i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %15
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %12
23: ; preds = %12
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @Pop(%struct.node** %2)
%26 = load %struct.node*, %struct.node** %2
%27 = call i32 @Length(%struct.node* %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %27)
store i32 0, i32* %3
br label %29
29: ; preds = %37, %23
%30 = load i32, i32* %3
%31 = icmp slt i32 %30, 5
br i1 %31, label %32, label %40
32: ; preds = %29
%33 = load %struct.node*, %struct.node** %2
%34 = load i32, i32* %3
%35 = call i32 @GetNth(%struct.node* %33, i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %32
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %29
40: ; preds = %29
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%42 = call i32 @Pop(%struct.node** %2)
%43 = load %struct.node*, %struct.node** %2
%44 = call i32 @Length(%struct.node* %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %44)
store i32 0, i32* %3
br label %46
46: ; preds = %54, %40
%47 = load i32, i32* %3
%48 = icmp slt i32 %47, 4
br i1 %48, label %49, label %57
49: ; preds = %46
%50 = load %struct.node*, %struct.node** %2
%51 = load i32, i32* %3
%52 = call i32 @GetNth(%struct.node* %50, i32 %51)
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %52)
br label %54
54: ; preds = %49
%55 = load i32, i32* %3
%56 = add nsw i32 %55, 1
store i32 %56, i32* %3
br label %46
57: ; preds = %46
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.node = type { i32 }
@.str = [20 x i8] c"start length is %d\0A\00"
@.str.1 = [4 x i8] c" %d\00"
define i32 @main() {
%1 = alloca %struct.node*
%2 = bitcast %struct.node** %1 to i8*
%3 = tail call %struct.node* (...) @BuildOneTwoThreeFourFive()
store %struct.node* %3, %struct.node** %1
%4 = tail call i32 @Length(%struct.node* %3)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = call i32 @Push(%struct.node** %1, i32 6)
%7 = load %struct.node*, %struct.node** %1
%8 = call i32 @Length(%struct.node* %7)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load %struct.node*, %struct.node** %1
%11 = call i32 @GetNth(%struct.node* %10, i32 0)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = load %struct.node*, %struct.node** %1
%14 = call i32 @GetNth(%struct.node* %13, i32 1)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load %struct.node*, %struct.node** %1
%17 = call i32 @GetNth(%struct.node* %16, i32 2)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = load %struct.node*, %struct.node** %1
%20 = call i32 @GetNth(%struct.node* %19, i32 3)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = load %struct.node*, %struct.node** %1
%23 = call i32 @GetNth(%struct.node* %22, i32 4)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = load %struct.node*, %struct.node** %1
%26 = call i32 @GetNth(%struct.node* %25, i32 5)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = call i32 @putchar(i32 10)
%29 = call i32 @Pop(%struct.node** %1)
%30 = load %struct.node*, %struct.node** %1
%31 = call i32 @Length(%struct.node* %30)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %31)
%33 = load %struct.node*, %struct.node** %1
%34 = call i32 @GetNth(%struct.node* %33, i32 0)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = load %struct.node*, %struct.node** %1
%37 = call i32 @GetNth(%struct.node* %36, i32 1)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %37)
%39 = load %struct.node*, %struct.node** %1
%40 = call i32 @GetNth(%struct.node* %39, i32 2)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%42 = load %struct.node*, %struct.node** %1
%43 = call i32 @GetNth(%struct.node* %42, i32 3)
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %43)
%45 = load %struct.node*, %struct.node** %1
%46 = call i32 @GetNth(%struct.node* %45, i32 4)
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %46)
%48 = call i32 @putchar(i32 10)
%49 = call i32 @Pop(%struct.node** %1)
%50 = load %struct.node*, %struct.node** %1
%51 = call i32 @Length(%struct.node* %50)
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %51)
%53 = load %struct.node*, %struct.node** %1
%54 = call i32 @GetNth(%struct.node* %53, i32 0)
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %54)
%56 = load %struct.node*, %struct.node** %1
%57 = call i32 @GetNth(%struct.node* %56, i32 1)
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %57)
%59 = load %struct.node*, %struct.node** %1
%60 = call i32 @GetNth(%struct.node* %59, i32 2)
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %60)
%62 = load %struct.node*, %struct.node** %1
%63 = call i32 @GetNth(%struct.node* %62, i32 3)
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %63)
%65 = call i32 @putchar(i32 10)
ret i32 0
}