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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
struct stack *stack_alloc();
int /*<<< orphan*/ stack_free(struct stack *);
char *stack_pop(struct stack *);
int /*<<< orphan*/ stack_push(struct stack *, char *);
int main(int argc, char *argv[]) {
  struct stack *stackOfStrings = stack_alloc();
  stack_push(stackOfStrings, "Friends, Romans, countrymen, lend me your ears;");
  stack_push(stackOfStrings, "I come to bury Caesar, not to praise him.");
  stack_push(stackOfStrings, "The evil that men do lives after them;");
  stack_push(stackOfStrings, "The good is oft interred with their bones;");
  char *currentString = stack_pop(stackOfStrings);
  while (currentString) {
    printf("The string is: %s\n", currentString);
    currentString = stack_pop(stackOfStrings);
  }
  stack_free(stackOfStrings);
  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)
mov    $0x0,%al
call   1050 <stack_alloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1060 <stack_push@plt>
mov    -0x18(%rbp),%rdi
lea    0xea4(%rip),%rsi
call   1060 <stack_push@plt>
mov    -0x18(%rbp),%rdi
lea    0xebe(%rip),%rsi
call   1060 <stack_push@plt>
mov    -0x18(%rbp),%rdi
lea    0xed5(%rip),%rsi
call   1060 <stack_push@plt>
mov    -0x18(%rbp),%rdi
call   1070 <stack_pop@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11eb <main+0x9b>
mov    -0x20(%rbp),%rsi
lea    0xed8(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <stack_pop@plt>
mov    %rax,-0x20(%rbp)
jmp    11be <main+0x6e>
mov    -0x18(%rbp),%rdi
call   1030 <stack_free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <stack_alloc@plt>
mov    %rax,%rbx
lea    0xe9b(%rip),%rsi
mov    %rax,%rdi
call   1060 <stack_push@plt>
lea    0xebc(%rip),%rsi
mov    %rbx,%rdi
call   1060 <stack_push@plt>
lea    0xed7(%rip),%rsi
mov    %rbx,%rdi
call   1060 <stack_push@plt>
lea    0xeef(%rip),%rsi
mov    %rbx,%rdi
call   1060 <stack_push@plt>
mov    %rbx,%rdi
call   1070 <stack_pop@plt>
test   %rax,%rax
je     11c8 <main+0x78>
lea    0xefe(%rip),%r14
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1070 <stack_pop@plt>
test   %rax,%rax
jne    11b0 <main+0x60>
mov    %rbx,%rdi
call   1030 <stack_free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.stack = type { i32 }
@.str = [48 x i8] c"Friends, Romans, countrymen, lend me your ears;\00"
@.str.1 = [42 x i8] c"I come to bury Caesar, not to praise him.\00"
@.str.2 = [39 x i8] c"The evil that men do lives after them;\00"
@.str.3 = [43 x i8] c"The good is oft interred with their bones;\00"
@.str.4 = [19 x i8] c"The string is: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stack*
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call %struct.stack* (...) @stack_alloc()
store %struct.stack* %8, %struct.stack** %6
%9 = load %struct.stack*, %struct.stack** %6
%10 = call i32 @stack_push(%struct.stack* %9, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%11 = load %struct.stack*, %struct.stack** %6
%12 = call i32 @stack_push(%struct.stack* %11, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%13 = load %struct.stack*, %struct.stack** %6
%14 = call i32 @stack_push(%struct.stack* %13, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%15 = load %struct.stack*, %struct.stack** %6
%16 = call i32 @stack_push(%struct.stack* %15, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
%17 = load %struct.stack*, %struct.stack** %6
%18 = call i8* @stack_pop(%struct.stack* %17)
store i8* %18, i8** %7
br label %19
19: ; preds = %22, %2
%20 = load i8*, i8** %7
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i8*, i8** %7
%24 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %23)
%25 = load %struct.stack*, %struct.stack** %6
%26 = call i8* @stack_pop(%struct.stack* %25)
store i8* %26, i8** %7
br label %19
27: ; preds = %19
%28 = load %struct.stack*, %struct.stack** %6
%29 = call i32 @stack_free(%struct.stack* %28)
ret i32 0
}

LLVM IR (-O2):
%struct.stack = type { i32 }
@.str = [48 x i8] c"Friends, Romans, countrymen, lend me your ears;\00"
@.str.1 = [42 x i8] c"I come to bury Caesar, not to praise him.\00"
@.str.2 = [39 x i8] c"The evil that men do lives after them;\00"
@.str.3 = [43 x i8] c"The good is oft interred with their bones;\00"
@.str.4 = [19 x i8] c"The string is: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call %struct.stack* (...) @stack_alloc()
%4 = tail call i32 @stack_push(%struct.stack* %3, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @stack_push(%struct.stack* %3, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @stack_push(%struct.stack* %3, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 @stack_push(%struct.stack* %3, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
%8 = tail call i8* @stack_pop(%struct.stack* %3)
%9 = icmp eq i8* %8, null
br i1 %9, label %15, label %10
10: ; preds = %2, %10
%11 = phi i8* [ %13, %10 ], [ %8, %2 ]
%12 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %11)
%13 = tail call i8* @stack_pop(%struct.stack* %3)
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %10
15: ; preds = %10, %2
%16 = tail call i32 @stack_free(%struct.stack* %3)
ret i32 0
}