#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int rand();
int /*<<< orphan*/ stackDisplay();
int /*<<< orphan*/ stackEmpty();
int /*<<< orphan*/ stackFull();
int /*<<< orphan*/ stackInit(int);
int /*<<< orphan*/ stackPop();
int /*<<< orphan*/ stackPush(int);
int main(void) {
  int i;
  stackInit(100);
  for (i = 0; i < 10; i++)
    if (!stackFull())
      stackPush(rand() % 100);
  printf("Initial Contents: ");
  stackDisplay();
  for (i = 0; i < 5; i++)
    if (!stackEmpty())
      stackPop();
  printf("Contents after poping off 5 items: ");
  stackDisplay();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x64,%edi
call   1070 <stackInit@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11e3 <main+0x63>
mov    $0x0,%al
call   1040 <stackFull@plt>
cmp    $0x0,%eax
jne    11d0 <main+0x50>
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   10a0 <stackPush@plt>
jmp    11d5 <main+0x55>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a0 <main+0x20>
lea    0xe16(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <stackDisplay@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    1231 <main+0xb1>
mov    $0x0,%al
call   1050 <stackEmpty@plt>
cmp    $0x0,%eax
jne    121e <main+0x9e>
mov    $0x0,%al
call   1080 <stackPop@plt>
jmp    1223 <main+0xa3>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11fd <main+0x7d>
lea    0xddb(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <stackDisplay@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x64,%edi
call   1070 <stackInit@plt>
xor    %eax,%eax
call   1040 <stackFull@plt>
test   %eax,%eax
jne    11be <main+0x3e>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rdi
imul   $0x51eb851f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
call   10a0 <stackPush@plt>
xor    %eax,%eax
call   1040 <stackFull@plt>
test   %eax,%eax
jne    11f1 <main+0x71>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rdi
imul   $0x51eb851f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
call   10a0 <stackPush@plt>
xor    %eax,%eax
call   1040 <stackFull@plt>
test   %eax,%eax
jne    1224 <main+0xa4>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rdi
imul   $0x51eb851f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
call   10a0 <stackPush@plt>
xor    %eax,%eax
call   1040 <stackFull@plt>
test   %eax,%eax
jne    1257 <main+0xd7>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rdi
imul   $0x51eb851f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
call   10a0 <stackPush@plt>
xor    %eax,%eax
call   1040 <stackFull@plt>
test   %eax,%eax
jne    128a <main+0x10a>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rdi
imul   $0x51eb851f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
call   10a0 <stackPush@plt>
xor    %eax,%eax
call   1040 <stackFull@plt>
test   %eax,%eax
jne    12bd <main+0x13d>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rdi
imul   $0x51eb851f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
call   10a0 <stackPush@plt>
xor    %eax,%eax
call   1040 <stackFull@plt>
test   %eax,%eax
jne    12f0 <main+0x170>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rdi
imul   $0x51eb851f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
call   10a0 <stackPush@plt>
xor    %eax,%eax
call   1040 <stackFull@plt>
test   %eax,%eax
jne    1323 <main+0x1a3>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rdi
imul   $0x51eb851f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
call   10a0 <stackPush@plt>
xor    %eax,%eax
call   1040 <stackFull@plt>
test   %eax,%eax
jne    1356 <main+0x1d6>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rdi
imul   $0x51eb851f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
call   10a0 <stackPush@plt>
xor    %eax,%eax
call   1040 <stackFull@plt>
test   %eax,%eax
jne    1389 <main+0x209>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rdi
imul   $0x51eb851f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
call   10a0 <stackPush@plt>
lea    0xc70(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <stackDisplay@plt>
xor    %eax,%eax
call   1050 <stackEmpty@plt>
test   %eax,%eax
jne    13ae <main+0x22e>
xor    %eax,%eax
call   1080 <stackPop@plt>
xor    %eax,%eax
call   1050 <stackEmpty@plt>
test   %eax,%eax
jne    13c0 <main+0x240>
xor    %eax,%eax
call   1080 <stackPop@plt>
xor    %eax,%eax
call   1050 <stackEmpty@plt>
test   %eax,%eax
jne    13d2 <main+0x252>
xor    %eax,%eax
call   1080 <stackPop@plt>
xor    %eax,%eax
call   1050 <stackEmpty@plt>
test   %eax,%eax
jne    13e4 <main+0x264>
xor    %eax,%eax
call   1080 <stackPop@plt>
xor    %eax,%eax
call   1050 <stackEmpty@plt>
test   %eax,%eax
jne    13f6 <main+0x276>
xor    %eax,%eax
call   1080 <stackPop@plt>
lea    0xc16(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <stackDisplay@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Initial Contents: \00"
@.str.1 = [36 x i8] c"Contents after poping off 5 items: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @stackInit(i32 100)
store i32 0, i32* %2
br label %4
4: ; preds = %15, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 10
br i1 %6, label %7, label %18
7: ; preds = %4
%8 = call i32 (...) @stackFull()
%9 = icmp ne i32 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = call i32 (...) @rand()
%12 = srem i32 %11, 100
%13 = call i32 @stackPush(i32 %12)
br label %14
14: ; preds = %10, %7
br label %15
15: ; preds = %14
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %4
18: ; preds = %4
%19 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%20 = call i32 (...) @stackDisplay()
store i32 0, i32* %2
br label %21
21: ; preds = %30, %18
%22 = load i32, i32* %2
%23 = icmp slt i32 %22, 5
br i1 %23, label %24, label %33
24: ; preds = %21
%25 = call i32 (...) @stackEmpty()
%26 = icmp ne i32 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %24
%28 = call i32 (...) @stackPop()
br label %29
29: ; preds = %27, %24
br label %30
30: ; preds = %29
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2
br label %21
33: ; preds = %21
%34 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%35 = call i32 (...) @stackDisplay()
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Initial Contents: \00"
@.str.1 = [36 x i8] c"Contents after poping off 5 items: \00"
define i32 @main() {
%1 = tail call i32 @stackInit(i32 100)
%2 = tail call i32 (...) @stackFull()
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %0
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 100
%7 = tail call i32 @stackPush(i32 %6)
br label %8
8: ; preds = %0, %4
%9 = tail call i32 (...) @stackFull()
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, 100
%14 = tail call i32 @stackPush(i32 %13)
br label %15
15: ; preds = %11, %8
%16 = tail call i32 (...) @stackFull()
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = tail call i32 (...) @rand()
%20 = srem i32 %19, 100
%21 = tail call i32 @stackPush(i32 %20)
br label %22
22: ; preds = %18, %15
%23 = tail call i32 (...) @stackFull()
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = tail call i32 (...) @rand()
%27 = srem i32 %26, 100
%28 = tail call i32 @stackPush(i32 %27)
br label %29
29: ; preds = %25, %22
%30 = tail call i32 (...) @stackFull()
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = tail call i32 (...) @rand()
%34 = srem i32 %33, 100
%35 = tail call i32 @stackPush(i32 %34)
br label %36
36: ; preds = %32, %29
%37 = tail call i32 (...) @stackFull()
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %36
%40 = tail call i32 (...) @rand()
%41 = srem i32 %40, 100
%42 = tail call i32 @stackPush(i32 %41)
br label %43
43: ; preds = %39, %36
%44 = tail call i32 (...) @stackFull()
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %43
%47 = tail call i32 (...) @rand()
%48 = srem i32 %47, 100
%49 = tail call i32 @stackPush(i32 %48)
br label %50
50: ; preds = %46, %43
%51 = tail call i32 (...) @stackFull()
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %50
%54 = tail call i32 (...) @rand()
%55 = srem i32 %54, 100
%56 = tail call i32 @stackPush(i32 %55)
br label %57
57: ; preds = %53, %50
%58 = tail call i32 (...) @stackFull()
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %64
60: ; preds = %57
%61 = tail call i32 (...) @rand()
%62 = srem i32 %61, 100
%63 = tail call i32 @stackPush(i32 %62)
br label %64
64: ; preds = %60, %57
%65 = tail call i32 (...) @stackFull()
%66 = icmp eq i32 %65, 0
br i1 %66, label %67, label %71
67: ; preds = %64
%68 = tail call i32 (...) @rand()
%69 = srem i32 %68, 100
%70 = tail call i32 @stackPush(i32 %69)
br label %71
71: ; preds = %67, %64
%72 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%73 = tail call i32 (...) @stackDisplay()
%74 = tail call i32 (...) @stackEmpty()
%75 = icmp eq i32 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %71
%77 = tail call i32 (...) @stackPop()
br label %78
78: ; preds = %71, %76
%79 = tail call i32 (...) @stackEmpty()
%80 = icmp eq i32 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %78
%82 = tail call i32 (...) @stackPop()
br label %83
83: ; preds = %81, %78
%84 = tail call i32 (...) @stackEmpty()
%85 = icmp eq i32 %84, 0
br i1 %85, label %86, label %88
86: ; preds = %83
%87 = tail call i32 (...) @stackPop()
br label %88
88: ; preds = %86, %83
%89 = tail call i32 (...) @stackEmpty()
%90 = icmp eq i32 %89, 0
br i1 %90, label %91, label %93
91: ; preds = %88
%92 = tail call i32 (...) @stackPop()
br label %93
93: ; preds = %91, %88
%94 = tail call i32 (...) @stackEmpty()
%95 = icmp eq i32 %94, 0
br i1 %95, label %96, label %98
96: ; preds = %93
%97 = tail call i32 (...) @stackPop()
br label %98
98: ; preds = %96, %93
%99 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%100 = tail call i32 (...) @stackDisplay()
ret i32 0
}