#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 *);
int /*<<< orphan*/ scanf(char *, int *);
void inserir(int vet[10], int *topo) {
  if (*topo == 10 - 1) {
    printf("\n\a\tA pilha esta cheia!\n");
    return;
  }
  int val = 0;
  printf("\n\tDigite um valor -> ");
  scanf("%d", &val);
  vet[++(*topo)] = val;
  return;
}


x86 assembly (clang, -O0):
<inserir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x9,(%rax)
jne    114e <inserir+0x2e>
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
jmp    1189 <inserir+0x69>
movl   $0x0,-0x14(%rbp)
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rsi
mov    (%rsi),%ecx
add    $0x1,%ecx
mov    %ecx,(%rsi)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inserir>:
push   %r14
push   %rbx
push   %rax
cmpl   $0x9,(%rsi)
jne    114c <inserir+0x1c>
lea    0xed9(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <puts@plt>
mov    %rsi,%rbx
mov    %rdi,%r14
movl   $0x0,0x4(%rsp)
lea    0xe9f(%rip),%rdi
call   1040 <printf@plt>
lea    0xea9(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
movslq (%rbx),%rcx
lea    0x1(%rcx),%rdx
mov    %edx,(%rbx)
mov    %eax,0x4(%r14,%rcx,4)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [24 x i8] c"\0A\07\09A pilha esta cheia!\0A\00"
@.str.1 = [22 x i8] c"\0A\09Digite um valor -> \00"
@.str.2 = [3 x i8] c"%d\00"
define void @inserir(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = load i32*, i32** %4
%7 = load i32, i32* %6
%8 = icmp eq i32 %7, 9
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %21
11: ; preds = %2
store i32 0, i32* %5
%12 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%14 = load i32, i32* %5
%15 = load i32*, i32** %3
%16 = load i32*, i32** %4
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 1
store i32 %18, i32* %16
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %15, i64 %19
store i32 %14, i32* %20
br label %21
21: ; preds = %11, %9
ret void
}

LLVM IR (-O2):
@.str.1 = [22 x i8] c"\0A\09Digite um valor -> \00"
@.str.2 = [3 x i8] c"%d\00"
@str = [23 x i8] c"\0A\07\09A pilha esta cheia!\00"
define void @inserir(i32* nocapture writeonly %0, i32* nocapture %1) {
%3 = alloca i32
%4 = load i32, i32* %1
%5 = icmp eq i32 %4, 9
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %17
8: ; preds = %2
%9 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%10 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%12 = load i32, i32* %3
%13 = load i32, i32* %1
%14 = add nsw i32 %13, 1
store i32 %14, i32* %1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %0, i64 %15
store i32 %12, i32* %16
br label %17
17: ; preds = %8, %6
ret void
}