#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 */
struct Stack *createStack(int);
int peek(struct Stack *);
int pop(struct Stack *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ push(struct Stack *, int);
int main() {
  struct Stack *stack = createStack(100);
  push(stack, 10);
  push(stack, 20);
  push(stack, 30);
  printf("%d popped from stack\n", pop(stack));
  printf("Top item is %d\n", peek(stack));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x64,%edi
call   1060 <createStack@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1070 <push@plt>
mov    -0x10(%rbp),%rdi
mov    $0x14,%esi
call   1070 <push@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1e,%esi
call   1070 <push@plt>
mov    -0x10(%rbp),%rdi
call   1050 <pop@plt>
mov    %eax,%esi
lea    0xe57(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <peek@plt>
mov    %eax,%esi
lea    0xe56(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x64,%edi
call   1060 <createStack@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0xa,%esi
call   1070 <push@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   1070 <push@plt>
mov    %rbx,%rdi
mov    $0x1e,%esi
call   1070 <push@plt>
mov    %rbx,%rdi
call   1050 <pop@plt>
lea    0xe6c(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <peek@plt>
lea    0xe6c(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.Stack = type { i32 }
@.str = [22 x i8] c"%d popped from stack\0A\00"
@.str.1 = [16 x i8] c"Top item is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.Stack*
store i32 0, i32* %1
%3 = call %struct.Stack* @createStack(i32 100)
store %struct.Stack* %3, %struct.Stack** %2
%4 = load %struct.Stack*, %struct.Stack** %2
%5 = call i32 @push(%struct.Stack* %4, i32 10)
%6 = load %struct.Stack*, %struct.Stack** %2
%7 = call i32 @push(%struct.Stack* %6, i32 20)
%8 = load %struct.Stack*, %struct.Stack** %2
%9 = call i32 @push(%struct.Stack* %8, i32 30)
%10 = load %struct.Stack*, %struct.Stack** %2
%11 = call i32 @pop(%struct.Stack* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load %struct.Stack*, %struct.Stack** %2
%14 = call i32 @peek(%struct.Stack* %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %14)
ret i32 0
}

LLVM IR (-O2):
%struct.Stack = type { i32 }
@.str = [22 x i8] c"%d popped from stack\0A\00"
@.str.1 = [16 x i8] c"Top item is %d\0A\00"
define i32 @main() {
%1 = tail call %struct.Stack* @createStack(i32 100)
%2 = tail call i32 @push(%struct.Stack* %1, i32 10)
%3 = tail call i32 @push(%struct.Stack* %1, i32 20)
%4 = tail call i32 @push(%struct.Stack* %1, i32 30)
%5 = tail call i32 @pop(%struct.Stack* %1)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 @peek(%struct.Stack* %1)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %7)
ret i32 0
}