#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 DynArrayStack {
  int dummy;
};

/* Variables and functions */
struct DynArrayStack *CreateStack();
int /*<<< orphan*/ DeleteDynStack(struct DynArrayStack *);
int /*<<< orphan*/ IsEmptyStack(struct DynArrayStack *);
int Pop(struct DynArrayStack *);
int /*<<< orphan*/ Push(struct DynArrayStack *, int);
int /*<<< orphan*/ printf(char *, int);
void testDynamicStack() {
  struct DynArrayStack *s = CreateStack();
  Push(s, 10);
  Push(s, 1);
  Push(s, 11);
  Push(s, 2);
  Push(s, 10);
  Push(s, 50);
  while (!IsEmptyStack(s)) {
    printf("%d\n", Pop(s));
  }
  DeleteDynStack(s);
}


x86 assembly (clang, -O0):
<testDynamicStack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1060 <CreateStack@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0xa,%esi
call   1070 <Push@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1070 <Push@plt>
mov    -0x8(%rbp),%rdi
mov    $0xb,%esi
call   1070 <Push@plt>
mov    -0x8(%rbp),%rdi
mov    $0x2,%esi
call   1070 <Push@plt>
mov    -0x8(%rbp),%rdi
mov    $0xa,%esi
call   1070 <Push@plt>
mov    -0x8(%rbp),%rdi
mov    $0x32,%esi
call   1070 <Push@plt>
mov    -0x8(%rbp),%rdi
call   1080 <IsEmptyStack@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11e5 <testDynamicStack+0x85>
jmp    1201 <testDynamicStack+0xa1>
mov    -0x8(%rbp),%rdi
call   1050 <Pop@plt>
mov    %eax,%esi
lea    0xe09(%rip),%rdi
call   1040 <printf@plt>
jmp    11c7 <testDynamicStack+0x67>
mov    -0x8(%rbp),%rdi
call   1030 <DeleteDynStack@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testDynamicStack>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <CreateStack@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0xa,%esi
call   1070 <Push@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1070 <Push@plt>
mov    %rbx,%rdi
mov    $0xb,%esi
call   1070 <Push@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1070 <Push@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1070 <Push@plt>
mov    %rbx,%rdi
mov    $0x32,%esi
call   1070 <Push@plt>
mov    %rbx,%rdi
call   1080 <IsEmptyStack@plt>
test   %eax,%eax
jne    11ee <testDynamicStack+0x8e>
lea    0xe31(%rip),%r14
nop
mov    %rbx,%rdi
call   1050 <Pop@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1080 <IsEmptyStack@plt>
test   %eax,%eax
je     11d0 <testDynamicStack+0x70>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <DeleteDynStack@plt>

LLVM IR (-O0):
%struct.DynArrayStack = type { i32 }
@.str = [4 x i8] c"%d\0A\00"
define void @testDynamicStack() {
%1 = alloca %struct.DynArrayStack*
%2 = call %struct.DynArrayStack* (...) @CreateStack()
store %struct.DynArrayStack* %2, %struct.DynArrayStack** %1
%3 = load %struct.DynArrayStack*, %struct.DynArrayStack** %1
%4 = call i32 @Push(%struct.DynArrayStack* %3, i32 10)
%5 = load %struct.DynArrayStack*, %struct.DynArrayStack** %1
%6 = call i32 @Push(%struct.DynArrayStack* %5, i32 1)
%7 = load %struct.DynArrayStack*, %struct.DynArrayStack** %1
%8 = call i32 @Push(%struct.DynArrayStack* %7, i32 11)
%9 = load %struct.DynArrayStack*, %struct.DynArrayStack** %1
%10 = call i32 @Push(%struct.DynArrayStack* %9, i32 2)
%11 = load %struct.DynArrayStack*, %struct.DynArrayStack** %1
%12 = call i32 @Push(%struct.DynArrayStack* %11, i32 10)
%13 = load %struct.DynArrayStack*, %struct.DynArrayStack** %1
%14 = call i32 @Push(%struct.DynArrayStack* %13, i32 50)
br label %15
15: ; preds = %20, %0
%16 = load %struct.DynArrayStack*, %struct.DynArrayStack** %1
%17 = call i32 @IsEmptyStack(%struct.DynArrayStack* %16)
%18 = icmp ne i32 %17, 0
%19 = xor i1 %18, true
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load %struct.DynArrayStack*, %struct.DynArrayStack** %1
%22 = call i32 @Pop(%struct.DynArrayStack* %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %15
24: ; preds = %15
%25 = load %struct.DynArrayStack*, %struct.DynArrayStack** %1
%26 = call i32 @DeleteDynStack(%struct.DynArrayStack* %25)
ret void
}

LLVM IR (-O2):
%struct.DynArrayStack = type { i32 }
@.str = [4 x i8] c"%d\0A\00"
define void @testDynamicStack() {
%1 = tail call %struct.DynArrayStack* (...) @CreateStack()
%2 = tail call i32 @Push(%struct.DynArrayStack* %1, i32 10)
%3 = tail call i32 @Push(%struct.DynArrayStack* %1, i32 1)
%4 = tail call i32 @Push(%struct.DynArrayStack* %1, i32 11)
%5 = tail call i32 @Push(%struct.DynArrayStack* %1, i32 2)
%6 = tail call i32 @Push(%struct.DynArrayStack* %1, i32 10)
%7 = tail call i32 @Push(%struct.DynArrayStack* %1, i32 50)
%8 = tail call i32 @IsEmptyStack(%struct.DynArrayStack* %1)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %0, %10
%11 = tail call i32 @Pop(%struct.DynArrayStack* %1)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = tail call i32 @IsEmptyStack(%struct.DynArrayStack* %1)
%14 = icmp eq i32 %13, 0
br i1 %14, label %10, label %15
15: ; preds = %10, %0
%16 = tail call i32 @DeleteDynStack(%struct.DynArrayStack* %1)
ret void
}