#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 */
scalar_t__ isEmpty();
int pop();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(int);
int /*<<< orphan*/ stack_print();
int tops();
int main() {
  int i;
  printf("is stack empty? \n");
  printf("%s\n", (isEmpty()) ? "true" : "false");
  push(10);
  printf("top is at %d\n", tops());
  push(11);
  push(12);
  push(15);
  i = pop();
  printf("Popped data is %d\n", i);
  printf("top is at %d\n", tops());
  stack_print();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <isEmpty@plt>
mov    %rax,%rcx
lea    0xe8d(%rip),%rsi
lea    0xe81(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xa,%edi
call   1070 <push@plt>
mov    $0x0,%al
call   1080 <tops@plt>
mov    %eax,%esi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xb,%edi
call   1070 <push@plt>
mov    $0xc,%edi
call   1070 <push@plt>
mov    $0xf,%edi
call   1070 <push@plt>
mov    $0x0,%al
call   1040 <pop@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1080 <tops@plt>
mov    %eax,%esi
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <stack_print@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <isEmpty@plt>
test   %rax,%rax
lea    0xe77(%rip),%rax
lea    0xe6b(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    $0xa,%edi
call   1080 <push@plt>
xor    %eax,%eax
call   1090 <tops@plt>
lea    0xe55(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xb,%edi
call   1080 <push@plt>
mov    $0xc,%edi
call   1080 <push@plt>
mov    $0xf,%edi
call   1080 <push@plt>
xor    %eax,%eax
call   1050 <pop@plt>
lea    0xe2b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1090 <tops@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <stack_print@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"is stack empty? \0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [5 x i8] c"true\00"
@.str.3 = [6 x i8] c"false\00"
@.str.4 = [14 x i8] c"top is at %d\0A\00"
@.str.5 = [19 x i8] c"Popped data is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = call i64 (...) @isEmpty()
%5 = icmp ne i64 %4, 0
%6 = zext i1 %5 to i64
%7 = select i1 %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = call i32 @push(i32 10)
%10 = call i32 (...) @tops()
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %10)
%12 = call i32 @push(i32 11)
%13 = call i32 @push(i32 12)
%14 = call i32 @push(i32 15)
%15 = call i32 (...) @pop()
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %16)
%18 = call i32 (...) @tops()
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %18)
%20 = call i32 (...) @stack_print()
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [5 x i8] c"true\00"
@.str.3 = [6 x i8] c"false\00"
@.str.4 = [14 x i8] c"top is at %d\0A\00"
@.str.5 = [19 x i8] c"Popped data is %d\0A\00"
@str = [17 x i8] c"is stack empty? \00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%2 = tail call i64 (...) @isEmpty()
%3 = icmp eq i64 %2, 0
%4 = select i1 %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%5 = tail call i32 @puts(i8* dereferenceable(1) %4)
%6 = tail call i32 @push(i32 10)
%7 = tail call i32 (...) @tops()
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %7)
%9 = tail call i32 @push(i32 11)
%10 = tail call i32 @push(i32 12)
%11 = tail call i32 @push(i32 15)
%12 = tail call i32 (...) @pop()
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %12)
%14 = tail call i32 (...) @tops()
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %14)
%16 = tail call i32 (...) @stack_print()
ret i32 0
}