#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*/ assert(int);
struct stack *create_stack();
int first(struct stack *);
int pop(struct stack *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ push(struct stack *, int);
int main() {
  int test_data[7] = {6, 4, -656, 34, 33, 1, 0};
  struct stack *stack = create_stack();
  int i = 0;
  for (; i < 7; ++i) {
    push(stack, test_data[i]);
  }
  for (--i; i > -1; --i) {
    printf("%d\n", first(stack));
    assert(pop(stack) == test_data[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe8a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe87(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe84(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xe82(%rip),%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1050 <create_stack@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x7,-0x2c(%rbp)
jge    11d4 <main+0x74>
mov    -0x28(%rbp),%rdi
movslq -0x2c(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%esi
call   1070 <push@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11ab <main+0x4b>
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jle    122a <main+0xca>
mov    -0x28(%rbp),%rdi
call   1080 <first@plt>
mov    %eax,%esi
lea    0xe23(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <pop@plt>
movslq -0x2c(%rbp),%rcx
cmp    -0x20(%rbp,%rcx,4),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
jmp    11dd <main+0x7d>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <create_stack@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x6,%esi
call   1070 <push@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1070 <push@plt>
mov    %rbx,%rdi
mov    $0xfffffd70,%esi
call   1070 <push@plt>
mov    %rbx,%rdi
mov    $0x22,%esi
call   1070 <push@plt>
mov    %rbx,%rdi
mov    $0x21,%esi
call   1070 <push@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1070 <push@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <push@plt>
mov    %rbx,%rdi
call   1080 <first@plt>
lea    0xe2b(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <pop@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
call   1080 <first@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <pop@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
call   1080 <first@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <pop@plt>
xor    %edi,%edi
cmp    $0x21,%eax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
call   1080 <first@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <pop@plt>
xor    %edi,%edi
cmp    $0x22,%eax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
call   1080 <first@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <pop@plt>
xor    %edi,%edi
cmp    $0xfffffd70,%eax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
call   1080 <first@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <pop@plt>
xor    %edi,%edi
cmp    $0x4,%eax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
call   1080 <first@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <pop@plt>
xor    %edi,%edi
cmp    $0x6,%eax
sete   %dil
call   1060 <assert@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.stack = type { i32 }
@__const.main.test_data = [7 x i32] [i32 6, i32 4, i32 -656, i32 34, i32 33, i32 1, i32 0]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [7 x i32]
%3 = alloca %struct.stack*
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [7 x i32]* %2 to i8*
%6 = call %struct.stack* (...) @create_stack()
store %struct.stack* %6, %struct.stack** %3
store i32 0, i32* %4
br label %7
7: ; preds = %17, %0
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 7
br i1 %9, label %10, label %20
10: ; preds = %7
%11 = load %struct.stack*, %struct.stack** %3
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = call i32 @push(%struct.stack* %11, i32 %15)
br label %17
17: ; preds = %10
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
br label %7
20: ; preds = %7
%21 = load i32, i32* %4
%22 = add nsw i32 %21, -1
store i32 %22, i32* %4
br label %23
23: ; preds = %39, %20
%24 = load i32, i32* %4
%25 = icmp sgt i32 %24, -1
br i1 %25, label %26, label %42
26: ; preds = %23
%27 = load %struct.stack*, %struct.stack** %3
%28 = call i32 @first(%struct.stack* %27)
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = load %struct.stack*, %struct.stack** %3
%31 = call i32 @pop(%struct.stack* %30)
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = icmp eq i32 %31, %35
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
br label %39
39: ; preds = %26
%40 = load i32, i32* %4
%41 = add nsw i32 %40, -1
store i32 %41, i32* %4
br label %23
42: ; preds = %23
ret i32 0
}

LLVM IR (-O2):
%struct.stack = type { i32 }
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call %struct.stack* (...) @create_stack()
%2 = tail call i32 @push(%struct.stack* %1, i32 6)
%3 = tail call i32 @push(%struct.stack* %1, i32 4)
%4 = tail call i32 @push(%struct.stack* %1, i32 -656)
%5 = tail call i32 @push(%struct.stack* %1, i32 34)
%6 = tail call i32 @push(%struct.stack* %1, i32 33)
%7 = tail call i32 @push(%struct.stack* %1, i32 1)
%8 = tail call i32 @push(%struct.stack* %1, i32 0)
%9 = tail call i32 @first(%struct.stack* %1)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = tail call i32 @pop(%struct.stack* %1)
%12 = icmp eq i32 %11, 0
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = tail call i32 @first(%struct.stack* %1)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = tail call i32 @pop(%struct.stack* %1)
%18 = icmp eq i32 %17, 1
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
%21 = tail call i32 @first(%struct.stack* %1)
%22 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = tail call i32 @pop(%struct.stack* %1)
%24 = icmp eq i32 %23, 33
%25 = zext i1 %24 to i32
%26 = tail call i32 @assert(i32 %25)
%27 = tail call i32 @first(%struct.stack* %1)
%28 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = tail call i32 @pop(%struct.stack* %1)
%30 = icmp eq i32 %29, 34
%31 = zext i1 %30 to i32
%32 = tail call i32 @assert(i32 %31)
%33 = tail call i32 @first(%struct.stack* %1)
%34 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %33)
%35 = tail call i32 @pop(%struct.stack* %1)
%36 = icmp eq i32 %35, -656
%37 = zext i1 %36 to i32
%38 = tail call i32 @assert(i32 %37)
%39 = tail call i32 @first(%struct.stack* %1)
%40 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %39)
%41 = tail call i32 @pop(%struct.stack* %1)
%42 = icmp eq i32 %41, 4
%43 = zext i1 %42 to i32
%44 = tail call i32 @assert(i32 %43)
%45 = tail call i32 @first(%struct.stack* %1)
%46 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %45)
%47 = tail call i32 @pop(%struct.stack* %1)
%48 = icmp eq i32 %47, 6
%49 = zext i1 %48 to i32
%50 = tail call i32 @assert(i32 %49)
ret i32 0
}