#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*/ scanf(char *, int *);
void alturaArvore(int *altura, int *maior) {
  int i = 0, n;
  scanf("%d", &n);
  if (*altura > *maior)
    *maior = *altura;
  while (i < n) {
    *altura = *altura + 1;
    alturaArvore(altura, maior);
    i++;
  }
  *altura = *altura - 1;
}


x86 assembly (clang, -O0):
<alturaArvore>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xec2(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <scanf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jle    1165 <alturaArvore+0x45>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    116a <alturaArvore+0x4a>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11a0 <alturaArvore+0x80>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <alturaArvore@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116a <alturaArvore+0x4a>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alturaArvore>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xecb(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1030 <scanf@plt>
mov    (%rbx),%eax
cmp    (%r14),%eax
jle    1149 <alturaArvore+0x29>
mov    %eax,(%r14)
cmpl   $0x0,0xc(%rsp)
jle    1177 <alturaArvore+0x57>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
addl   $0x1,(%rbx)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <alturaArvore@plt>
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jl     1160 <alturaArvore+0x40>
addl   $0xffffffff,(%rbx)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define void @alturaArvore(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %5
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%8 = load i32*, i32** %3
%9 = load i32, i32* %8
%10 = load i32*, i32** %4
%11 = load i32, i32* %10
%12 = icmp sgt i32 %9, %11
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i32*, i32** %3
%15 = load i32, i32* %14
%16 = load i32*, i32** %4
store i32 %15, i32* %16
br label %17
17: ; preds = %13, %2
br label %18
18: ; preds = %22, %17
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = load i32*, i32** %3
%24 = load i32, i32* %23
%25 = add nsw i32 %24, 1
%26 = load i32*, i32** %3
store i32 %25, i32* %26
%27 = load i32*, i32** %3
%28 = load i32*, i32** %4
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %18
31: ; preds = %18
%32 = load i32*, i32** %3
%33 = load i32, i32* %32
%34 = sub nsw i32 %33, 1
%35 = load i32*, i32** %3
store i32 %34, i32* %35
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @alturaArvore(i32* nocapture %0, i32* nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = load i32, i32* %0
%7 = load i32, i32* %1
%8 = icmp sgt i32 %6, %7
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 %6, i32* %1
br label %10
10: ; preds = %9, %2
%11 = load i32, i32* %3
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %10, %13
%14 = phi i32 [ %17, %13 ], [ 0, %10 ]
%15 = load i32, i32* %0
%16 = add nsw i32 %15, 1
store i32 %16, i32* %0
%17 = add nuw nsw i32 %14, 1
%18 = load i32, i32* %3
%19 = icmp slt i32 %17, %18
br i1 %19, label %13, label %20
20: ; preds = %13, %10
%21 = load i32, i32* %0
%22 = add nsw i32 %21, -1
store i32 %22, i32* %0
ret void
}