#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*/ getch();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int dados[30];
  int maior, contador, ordem;
  maior = 0;
  ordem = 1;
  printf(
      "Qual o maior numero que voce me dara?\nDigite 30 que eu te falarei!\n");
  for (contador = 0; contador < 30; contador++) {
    printf("Numero %d:  ", ordem);
    scanf("%d", &dados[contador]);
    ordem++;
    if (dados[contador] > maior) {
      maior = dados[contador];
    }
  }
  printf("O maior numero dado e o: %d", maior);
  getch();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x84(%rbp)
movl   $0x1,-0x8c(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x88(%rbp)
cmpl   $0x1e,-0x88(%rbp)
jge    11fd <main+0xcd>
mov    -0x8c(%rbp),%esi
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x88(%rbp),%rax
lea    -0x80(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xec2(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
movslq -0x88(%rbp),%rax
mov    -0x80(%rbp,%rax,4),%eax
cmp    -0x84(%rbp),%eax
jle    11e4 <main+0xb4>
movslq -0x88(%rbp),%rax
mov    -0x80(%rbp,%rax,4),%eax
mov    %eax,-0x84(%rbp)
jmp    11e9 <main+0xb9>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    116e <main+0x3e>
mov    -0x84(%rbp),%esi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getch@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x80,%rsp
lea    0xed3(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    $0xffffffffffffffe2,%rbp
lea    0xe94(%rip),%r14
lea    0xeb3(%rip),%r15
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
lea    0x1f(%rbp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    (%rbx),%eax
cmp    %r12d,%eax
cmovg  %eax,%r12d
add    $0x4,%rbx
inc    %rbp
jne    1180 <main+0x40>
lea    0xe5c(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <getch@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [68 x i8] c"Qual o maior numero que voce me dara?\0ADigite 30 que eu te falarei!\0A\00"
@.str.1 = [13 x i8] c"Numero %d: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [28 x i8] c"O maior numero dado e o: %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [30 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 1, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %7
7: ; preds = %31, %0
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 30
br i1 %9, label %10, label %34
10: ; preds = %7
%11 = load i32, i32* %5
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 %14
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %15)
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = load i32, i32* %3
%24 = icmp sgt i32 %22, %23
br i1 %24, label %25, label %30
25: ; preds = %10
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 %27
%29 = load i32, i32* %28
store i32 %29, i32* %3
br label %30
30: ; preds = %25, %10
br label %31
31: ; preds = %30
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %7
34: ; preds = %7
%35 = load i32, i32* %3
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %35)
%37 = call i32 (...) @getch()
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [13 x i8] c"Numero %d: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [28 x i8] c"O maior numero dado e o: %d\00"
@str = [67 x i8] c"Qual o maior numero que voce me dara?\0ADigite 30 que eu te falarei!\00"
define i32 @main() {
%1 = alloca [30 x i32]
%2 = bitcast [30 x i32]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %0, %4
%5 = phi i64 [ 0, %0 ], [ %15, %4 ]
%6 = phi i32 [ 1, %0 ], [ %11, %4 ]
%7 = phi i32 [ 0, %0 ], [ %14, %4 ]
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%9 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 %5
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %9)
%11 = add nuw nsw i32 %6, 1
%12 = load i32, i32* %9
%13 = icmp sgt i32 %12, %7
%14 = select i1 %13, i32 %12, i32 %7
%15 = add nuw nsw i64 %5, 1
%16 = icmp eq i64 %15, 30
br i1 %16, label %17, label %4
17: ; preds = %4
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%19 = call i32 (...) @getch()
ret i32 0
}