#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__ is_empty();
int pop();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(int);
int main(int argc, char *argv[]) {
  push(1);
  push(2);
  push(3);
  push(4);
  push(5);
  printf("Stack elements: \n");
  while (!is_empty())
    printf("%d\n", pop());
  if (is_empty())
    printf("Stack empty!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%edi
call   1060 <push@plt>
mov    $0x2,%edi
call   1060 <push@plt>
mov    $0x3,%edi
call   1060 <push@plt>
mov    $0x4,%edi
call   1060 <push@plt>
mov    $0x5,%edi
call   1060 <push@plt>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <is_empty@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11b3 <main+0x73>
jmp    11cf <main+0x8f>
mov    $0x0,%al
call   1050 <pop@plt>
mov    %eax,%esi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1196 <main+0x56>
mov    $0x0,%al
call   1040 <is_empty@plt>
cmp    $0x0,%rax
je     11ee <main+0xae>
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x1,%edi
call   1070 <push@plt>
mov    $0x2,%edi
call   1070 <push@plt>
mov    $0x3,%edi
call   1070 <push@plt>
mov    $0x4,%edi
call   1070 <push@plt>
mov    $0x5,%edi
call   1070 <push@plt>
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <is_empty@plt>
test   %rax,%rax
jne    11cf <main+0x7f>
lea    0xe5e(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <pop@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <is_empty@plt>
test   %rax,%rax
je     11b0 <main+0x60>
xor    %eax,%eax
call   1050 <is_empty@plt>
test   %rax,%rax
je     11e7 <main+0x97>
lea    0xe33(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Stack elements: \0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [14 x i8] c"Stack empty!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 @push(i32 1)
%7 = call i32 @push(i32 2)
%8 = call i32 @push(i32 3)
%9 = call i32 @push(i32 4)
%10 = call i32 @push(i32 5)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %16, %2
%13 = call i64 (...) @is_empty()
%14 = icmp ne i64 %13, 0
%15 = xor i1 %14, true
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = call i32 (...) @pop()
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %12
19: ; preds = %12
%20 = call i64 (...) @is_empty()
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %24
24: ; preds = %22, %19
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d\0A\00"
@str = [17 x i8] c"Stack elements: \00"
@str.3 = [13 x i8] c"Stack empty!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @push(i32 1)
%4 = tail call i32 @push(i32 2)
%5 = tail call i32 @push(i32 3)
%6 = tail call i32 @push(i32 4)
%7 = tail call i32 @push(i32 5)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%9 = tail call i64 (...) @is_empty()
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %2, %11
%12 = tail call i32 (...) @pop()
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = tail call i64 (...) @is_empty()
%15 = icmp eq i64 %14, 0
br i1 %15, label %11, label %16
16: ; preds = %11, %2
%17 = tail call i64 (...) @is_empty()
%18 = icmp eq i64 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.3, i64 0, i64 0))
br label %21
21: ; preds = %19, %16
ret i32 0
}