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

/* Variables and functions */
int /*<<< orphan*/ DESCRIBE(char *);
int /*<<< orphan*/ THEN(char *);
int /*<<< orphan*/ WHEN(char *);
struct pilha *create();
int /*<<< orphan*/ destroy(struct pilha *);
int /*<<< orphan*/ isEqual(int /*<<< orphan*/, int);
int /*<<< orphan*/ pop(struct pilha *);
int /*<<< orphan*/ push(struct pilha *, int);
int /*<<< orphan*/ top(struct pilha *);
int /*<<< orphan*/ vazia(struct pilha *);
test_pop() {
  int i, val;
  struct pilha *p = create();
  DESCRIBE("REMOVE ELEMENTOS");
  WHEN("Eu removo os elementos de uma pilha");
  for (i = 1; i <= 5; i++) {
    push(p, i);
  }
  for (i = 5; i > 0; i--) {
    THEN("Deve ter topo igual a i");
    isEqual(top(p), i);
    THEN("Deve remover");
    isEqual(pop(p), 1);
  }
  THEN("Deve ser vazia");
  isEqual(vazia(p), 1);
  destroy(p);
}


x86 assembly (clang, -O0):
<test_pop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1060 <create@plt>
mov    %rax,-0x18(%rbp)
lea    0xe46(%rip),%rdi
call   1090 <DESCRIBE@plt>
lea    0xe4b(%rip),%rdi
call   10c0 <WHEN@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jg     11f6 <test_pop+0x56>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   10a0 <push@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11d2 <test_pop+0x32>
movl   $0x5,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    1255 <test_pop+0xb5>
lea    0xe27(%rip),%rdi
call   1040 <THEN@plt>
mov    -0x18(%rbp),%rdi
call   1080 <top@plt>
mov    %eax,%edi
mov    -0x8(%rbp),%esi
call   10b0 <isEqual@plt>
lea    0xe20(%rip),%rdi
call   1040 <THEN@plt>
mov    -0x18(%rbp),%rdi
call   1050 <pop@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   10b0 <isEqual@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    11fd <test_pop+0x5d>
lea    0xdfe(%rip),%rdi
call   1040 <THEN@plt>
mov    -0x18(%rbp),%rdi
call   1030 <vazia@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   10b0 <isEqual@plt>
mov    -0x18(%rbp),%rdi
call   1070 <destroy@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_pop>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1060 <create@plt>
mov    %rax,%rbx
lea    0xe4a(%rip),%rdi
call   1090 <DESCRIBE@plt>
lea    0xe4f(%rip),%rdi
call   10c0 <WHEN@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   10a0 <push@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   10a0 <push@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   10a0 <push@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   10a0 <push@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   10a0 <push@plt>
lea    0xe26(%rip),%r14
mov    %r14,%rdi
call   1040 <THEN@plt>
mov    %rbx,%rdi
call   1080 <top@plt>
mov    %eax,%edi
mov    $0x5,%esi
call   10b0 <isEqual@plt>
lea    0xe1b(%rip),%r15
mov    %r15,%rdi
call   1040 <THEN@plt>
mov    %rbx,%rdi
call   1050 <pop@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   10b0 <isEqual@plt>
mov    %r14,%rdi
call   1040 <THEN@plt>
mov    %rbx,%rdi
call   1080 <top@plt>
mov    %eax,%edi
mov    $0x4,%esi
call   10b0 <isEqual@plt>
mov    %r15,%rdi
call   1040 <THEN@plt>
mov    %rbx,%rdi
call   1050 <pop@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   10b0 <isEqual@plt>
mov    %r14,%rdi
call   1040 <THEN@plt>
mov    %rbx,%rdi
call   1080 <top@plt>
mov    %eax,%edi
mov    $0x3,%esi
call   10b0 <isEqual@plt>
mov    %r15,%rdi
call   1040 <THEN@plt>
mov    %rbx,%rdi
call   1050 <pop@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   10b0 <isEqual@plt>
mov    %r14,%rdi
call   1040 <THEN@plt>
mov    %rbx,%rdi
call   1080 <top@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   10b0 <isEqual@plt>
mov    %r15,%rdi
call   1040 <THEN@plt>
mov    %rbx,%rdi
call   1050 <pop@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   10b0 <isEqual@plt>
mov    %r14,%rdi
call   1040 <THEN@plt>
mov    %rbx,%rdi
call   1080 <top@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   10b0 <isEqual@plt>
mov    %r15,%rdi
call   1040 <THEN@plt>
mov    %rbx,%rdi
call   1050 <pop@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   10b0 <isEqual@plt>
lea    0xd25(%rip),%rdi
call   1040 <THEN@plt>
mov    %rbx,%rdi
call   1030 <vazia@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   10b0 <isEqual@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1070 <destroy@plt>

LLVM IR (-O0):
%struct.pilha = type { i32 }
@.str = [17 x i8] c"REMOVE ELEMENTOS\00"
@.str.1 = [36 x i8] c"Eu removo os elementos de uma pilha\00"
@.str.2 = [24 x i8] c"Deve ter topo igual a i\00"
@.str.3 = [13 x i8] c"Deve remover\00"
@.str.4 = [15 x i8] c"Deve ser vazia\00"
define i32 @test_pop() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.pilha*
%5 = call %struct.pilha* (...) @create()
store %struct.pilha* %5, %struct.pilha** %4
%6 = call i32 @DESCRIBE(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @WHEN(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %2
br label %8
8: ; preds = %15, %0
%9 = load i32, i32* %2
%10 = icmp sle i32 %9, 5
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = load %struct.pilha*, %struct.pilha** %4
%13 = load i32, i32* %2
%14 = call i32 @push(%struct.pilha* %12, i32 %13)
br label %15
15: ; preds = %11
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %8
18: ; preds = %8
store i32 5, i32* %2
br label %19
19: ; preds = %32, %18
%20 = load i32, i32* %2
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %35
22: ; preds = %19
%23 = call i32 @THEN(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%24 = load %struct.pilha*, %struct.pilha** %4
%25 = call i32 @top(%struct.pilha* %24)
%26 = load i32, i32* %2
%27 = call i32 @isEqual(i32 %25, i32 %26)
%28 = call i32 @THEN(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%29 = load %struct.pilha*, %struct.pilha** %4
%30 = call i32 @pop(%struct.pilha* %29)
%31 = call i32 @isEqual(i32 %30, i32 1)
br label %32
32: ; preds = %22
%33 = load i32, i32* %2
%34 = add nsw i32 %33, -1
store i32 %34, i32* %2
br label %19
35: ; preds = %19
%36 = call i32 @THEN(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%37 = load %struct.pilha*, %struct.pilha** %4
%38 = call i32 @vazia(%struct.pilha* %37)
%39 = call i32 @isEqual(i32 %38, i32 1)
%40 = load %struct.pilha*, %struct.pilha** %4
%41 = call i32 @destroy(%struct.pilha* %40)
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
%struct.pilha = type { i32 }
@.str = [17 x i8] c"REMOVE ELEMENTOS\00"
@.str.1 = [36 x i8] c"Eu removo os elementos de uma pilha\00"
@.str.2 = [24 x i8] c"Deve ter topo igual a i\00"
@.str.3 = [13 x i8] c"Deve remover\00"
@.str.4 = [15 x i8] c"Deve ser vazia\00"
define i32 @test_pop() {
%1 = tail call %struct.pilha* (...) @create()
%2 = tail call i32 @DESCRIBE(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @WHEN(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @push(%struct.pilha* %1, i32 1)
%5 = tail call i32 @push(%struct.pilha* %1, i32 2)
%6 = tail call i32 @push(%struct.pilha* %1, i32 3)
%7 = tail call i32 @push(%struct.pilha* %1, i32 4)
%8 = tail call i32 @push(%struct.pilha* %1, i32 5)
%9 = tail call i32 @THEN(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 @top(%struct.pilha* %1)
%11 = tail call i32 @isEqual(i32 %10, i32 5)
%12 = tail call i32 @THEN(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%13 = tail call i32 @pop(%struct.pilha* %1)
%14 = tail call i32 @isEqual(i32 %13, i32 1)
%15 = tail call i32 @THEN(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32 @top(%struct.pilha* %1)
%17 = tail call i32 @isEqual(i32 %16, i32 4)
%18 = tail call i32 @THEN(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%19 = tail call i32 @pop(%struct.pilha* %1)
%20 = tail call i32 @isEqual(i32 %19, i32 1)
%21 = tail call i32 @THEN(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%22 = tail call i32 @top(%struct.pilha* %1)
%23 = tail call i32 @isEqual(i32 %22, i32 3)
%24 = tail call i32 @THEN(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%25 = tail call i32 @pop(%struct.pilha* %1)
%26 = tail call i32 @isEqual(i32 %25, i32 1)
%27 = tail call i32 @THEN(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%28 = tail call i32 @top(%struct.pilha* %1)
%29 = tail call i32 @isEqual(i32 %28, i32 2)
%30 = tail call i32 @THEN(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%31 = tail call i32 @pop(%struct.pilha* %1)
%32 = tail call i32 @isEqual(i32 %31, i32 1)
%33 = tail call i32 @THEN(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%34 = tail call i32 @top(%struct.pilha* %1)
%35 = tail call i32 @isEqual(i32 %34, i32 1)
%36 = tail call i32 @THEN(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%37 = tail call i32 @pop(%struct.pilha* %1)
%38 = tail call i32 @isEqual(i32 %37, i32 1)
%39 = tail call i32 @THEN(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%40 = tail call i32 @vazia(%struct.pilha* %1)
%41 = tail call i32 @isEqual(i32 %40, i32 1)
%42 = tail call i32 @destroy(%struct.pilha* %1)
ret i32 undef
}