#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*/ free(char *);
struct list *init();
int /*<<< orphan*/ kill(struct list *);
char *pop(struct list *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ push(struct list *, char *);
int main(void) {
  struct list *list = init();
  push(list, "123");
  push(list, "456");
  push(list, "789");
  char *string;
  while ((string = pop(list)) != NULL) {
    printf("Last element in the list: %s\n", string);
    free(string);
  }
  push(list, "foo");
  push(list, "bar");
  push(list, "test123");
  push(list, "test456");
  while ((string = pop(list)) != NULL) {
    printf("Last element in the list: %s\n", string);
    free(string);
  }
  push(list, "test");
  push(list, "123");
  while ((string = pop(list)) != NULL) {
    printf("Last element in the list: %s\n", string);
    free(string);
  }
  kill(list);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <init@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1080 <push@plt>
mov    -0x10(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1080 <push@plt>
mov    -0x10(%rbp),%rdi
lea    0xe5b(%rip),%rsi
call   1080 <push@plt>
mov    -0x10(%rbp),%rdi
call   1050 <pop@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11df <main+0x7f>
mov    -0x18(%rbp),%rsi
lea    0xe38(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
jmp    11aa <main+0x4a>
mov    -0x10(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1080 <push@plt>
mov    -0x10(%rbp),%rdi
lea    0xe2c(%rip),%rsi
call   1080 <push@plt>
mov    -0x10(%rbp),%rdi
lea    0xe20(%rip),%rsi
call   1080 <push@plt>
mov    -0x10(%rbp),%rdi
lea    0xe18(%rip),%rsi
call   1080 <push@plt>
mov    -0x10(%rbp),%rdi
call   1050 <pop@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1254 <main+0xf4>
mov    -0x18(%rbp),%rsi
lea    0xdc3(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
jmp    121f <main+0xbf>
mov    -0x10(%rbp),%rdi
lea    0xddb(%rip),%rsi
call   1080 <push@plt>
mov    -0x10(%rbp),%rdi
lea    0xdbf(%rip),%rsi
call   1080 <push@plt>
mov    -0x10(%rbp),%rdi
call   1050 <pop@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     12a9 <main+0x149>
mov    -0x18(%rbp),%rsi
lea    0xd6e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
jmp    1274 <main+0x114>
mov    -0x10(%rbp),%rdi
call   1070 <kill@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1060 <init@plt>
mov    %rax,%r15
lea    0xeb8(%rip),%rsi
mov    %rax,%rdi
call   1080 <push@plt>
lea    0xeb1(%rip),%rsi
mov    %r15,%rdi
call   1080 <push@plt>
lea    0xe6c(%rip),%rsi
mov    %r15,%rdi
call   1080 <push@plt>
mov    %r15,%rdi
call   1050 <pop@plt>
test   %rax,%rax
je     11e3 <main+0x83>
mov    %rax,%rbx
lea    0xe51(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1050 <pop@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11c0 <main+0x60>
lea    0xe38(%rip),%rsi
mov    %r15,%rdi
call   1080 <push@plt>
lea    0xe2d(%rip),%rsi
mov    %r15,%rdi
call   1080 <push@plt>
lea    0xe22(%rip),%rsi
mov    %r15,%rdi
call   1080 <push@plt>
lea    0xe1b(%rip),%rsi
mov    %r15,%rdi
call   1080 <push@plt>
mov    %r15,%rdi
call   1050 <pop@plt>
test   %rax,%rax
je     1263 <main+0x103>
mov    %rax,%rbx
lea    0xdce(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1050 <pop@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1240 <main+0xe0>
lea    0xdd0(%rip),%rsi
mov    %r15,%rdi
call   1080 <push@plt>
lea    0xdb5(%rip),%rsi
mov    %r15,%rdi
call   1080 <push@plt>
mov    %r15,%rdi
call   1050 <pop@plt>
test   %rax,%rax
je     12c3 <main+0x163>
mov    %rax,%rbx
lea    0xd6c(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1050 <pop@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    12a0 <main+0x140>
mov    %r15,%rdi
call   1070 <kill@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.list = type { i32 }
@.str = [4 x i8] c"123\00"
@.str.1 = [4 x i8] c"456\00"
@.str.2 = [4 x i8] c"789\00"
@.str.3 = [30 x i8] c"Last element in the list: %s\0A\00"
@.str.4 = [4 x i8] c"foo\00"
@.str.5 = [4 x i8] c"bar\00"
@.str.6 = [8 x i8] c"test123\00"
@.str.7 = [8 x i8] c"test456\00"
@.str.8 = [5 x i8] c"test\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.list*
%3 = alloca i8*
store i32 0, i32* %1
%4 = call %struct.list* (...) @init()
store %struct.list* %4, %struct.list** %2
%5 = load %struct.list*, %struct.list** %2
%6 = call i32 @push(%struct.list* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = load %struct.list*, %struct.list** %2
%8 = call i32 @push(%struct.list* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%9 = load %struct.list*, %struct.list** %2
%10 = call i32 @push(%struct.list* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %15, %0
%12 = load %struct.list*, %struct.list** %2
%13 = call i8* @pop(%struct.list* %12)
store i8* %13, i8** %3
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = load i8*, i8** %3
%17 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %16)
%18 = load i8*, i8** %3
%19 = call i32 @free(i8* %18)
br label %11
20: ; preds = %11
%21 = load %struct.list*, %struct.list** %2
%22 = call i32 @push(%struct.list* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%23 = load %struct.list*, %struct.list** %2
%24 = call i32 @push(%struct.list* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%25 = load %struct.list*, %struct.list** %2
%26 = call i32 @push(%struct.list* %25, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%27 = load %struct.list*, %struct.list** %2
%28 = call i32 @push(%struct.list* %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
br label %29
29: ; preds = %33, %20
%30 = load %struct.list*, %struct.list** %2
%31 = call i8* @pop(%struct.list* %30)
store i8* %31, i8** %3
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %38
33: ; preds = %29
%34 = load i8*, i8** %3
%35 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %34)
%36 = load i8*, i8** %3
%37 = call i32 @free(i8* %36)
br label %29
38: ; preds = %29
%39 = load %struct.list*, %struct.list** %2
%40 = call i32 @push(%struct.list* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%41 = load %struct.list*, %struct.list** %2
%42 = call i32 @push(%struct.list* %41, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %43
43: ; preds = %47, %38
%44 = load %struct.list*, %struct.list** %2
%45 = call i8* @pop(%struct.list* %44)
store i8* %45, i8** %3
%46 = icmp ne i8* %45, null
br i1 %46, label %47, label %52
47: ; preds = %43
%48 = load i8*, i8** %3
%49 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %48)
%50 = load i8*, i8** %3
%51 = call i32 @free(i8* %50)
br label %43
52: ; preds = %43
%53 = load %struct.list*, %struct.list** %2
%54 = call i32 @kill(%struct.list* %53)
ret i32 0
}

LLVM IR (-O2):
%struct.list = type { i32 }
@.str = [4 x i8] c"123\00"
@.str.1 = [4 x i8] c"456\00"
@.str.2 = [4 x i8] c"789\00"
@.str.3 = [30 x i8] c"Last element in the list: %s\0A\00"
@.str.4 = [4 x i8] c"foo\00"
@.str.5 = [4 x i8] c"bar\00"
@.str.6 = [8 x i8] c"test123\00"
@.str.7 = [8 x i8] c"test456\00"
@.str.8 = [5 x i8] c"test\00"
define i32 @main() {
%1 = tail call %struct.list* (...) @init()
%2 = tail call i32 @push(%struct.list* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @push(%struct.list* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @push(%struct.list* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i8* @pop(%struct.list* %1)
%6 = icmp eq i8* %5, null
br i1 %6, label %13, label %7
7: ; preds = %0, %7
%8 = phi i8* [ %11, %7 ], [ %5, %0 ]
%9 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%10 = tail call i32 @free(i8* %8)
%11 = tail call i8* @pop(%struct.list* %1)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %7
13: ; preds = %7, %0
%14 = tail call i32 @push(%struct.list* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%15 = tail call i32 @push(%struct.list* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%16 = tail call i32 @push(%struct.list* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%17 = tail call i32 @push(%struct.list* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%18 = tail call i8* @pop(%struct.list* %1)
%19 = icmp eq i8* %18, null
br i1 %19, label %26, label %20
20: ; preds = %13, %20
%21 = phi i8* [ %24, %20 ], [ %18, %13 ]
%22 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %21)
%23 = tail call i32 @free(i8* %21)
%24 = tail call i8* @pop(%struct.list* %1)
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %20
26: ; preds = %20, %13
%27 = tail call i32 @push(%struct.list* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%28 = tail call i32 @push(%struct.list* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%29 = tail call i8* @pop(%struct.list* %1)
%30 = icmp eq i8* %29, null
br i1 %30, label %37, label %31
31: ; preds = %26, %31
%32 = phi i8* [ %35, %31 ], [ %29, %26 ]
%33 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %32)
%34 = tail call i32 @free(i8* %32)
%35 = tail call i8* @pop(%struct.list* %1)
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %31
37: ; preds = %31, %26
%38 = tail call i32 @kill(%struct.list* %1)
ret i32 0
}