#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 *, ...);
void empilha(int *pilha, int *topo, int valor) {
  printf("%d na posição %d ", valor, *topo);
  if (*topo < 2) {
    pilha[*topo] = valor;
    (*topo)++;
  } else {
    printf("Pilha Cheia\n");
  }
}


x86 assembly (clang, -O0):
<empilha>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
cmpl   $0x2,(%rax)
jge    1168 <empilha+0x58>
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1176 <empilha+0x66>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<empilha>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rsi),%edx
lea    0xecb(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movslq (%rbx),%rax
cmp    $0x1,%rax
jg     1153 <empilha+0x33>
mov    %ebp,(%r14,%rax,4)
addl   $0x1,(%rbx)
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xeba(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"%d na posi\C3\A7\C3\A3o %d \00"
@.str.1 = [13 x i8] c"Pilha Cheia\0A\00"
define void @empilha(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
%8 = load i32*, i32** %5
%9 = load i32, i32* %8
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %9)
%11 = load i32*, i32** %5
%12 = load i32, i32* %11
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %24
14: ; preds = %3
%15 = load i32, i32* %6
%16 = load i32*, i32** %4
%17 = load i32*, i32** %5
%18 = load i32, i32* %17
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %16, i64 %19
store i32 %15, i32* %20
%21 = load i32*, i32** %5
%22 = load i32, i32* %21
%23 = add nsw i32 %22, 1
store i32 %23, i32* %21
br label %26
24: ; preds = %3
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %24, %14
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"%d na posi\C3\A7\C3\A3o %d \00"
@str = [12 x i8] c"Pilha Cheia\00"
define void @empilha(i32* nocapture writeonly %0, i32* nocapture %1, i32 %2) {
%4 = load i32, i32* %1
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %4)
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %13
8: ; preds = %3
%9 = sext i32 %6 to i64
%10 = getelementptr inbounds i32, i32* %0, i64 %9
store i32 %2, i32* %10
%11 = load i32, i32* %1
%12 = add nsw i32 %11, 1
store i32 %12, i32* %1
br label %15
13: ; preds = %3
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %15
15: ; preds = %13, %8
ret void
}