#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, posicao;
  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];
      posicao = contador;
    }
  }
  printf("O maior numero dado e o: %d, que foi o %d numero digitado.", maior,
         posicao + 1);
  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    1209 <main+0xd9>
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    0xea9(%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    11f0 <main+0xc0>
movslq -0x88(%rbp),%rax
mov    -0x80(%rbp,%rax,4),%eax
mov    %eax,-0x84(%rbp)
mov    -0x88(%rbp),%eax
mov    %eax,-0x90(%rbp)
jmp    11f5 <main+0xc5>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    116e <main+0x3e>
mov    -0x84(%rbp),%esi
mov    -0x90(%rbp),%edx
add    $0x1,%edx
lea    0xe35(%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   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xef6(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
lea    0xea9(%rip),%r12
xor    %r13d,%r13d
xor    %ebp,%ebp
nopl   0x0(%rax)
lea    0x1(%r13),%r15
lea    0xe85(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    (%rbx),%eax
cmp    %ebp,%eax
cmovg  %eax,%ebp
cmovg  %r13d,%r14d
add    $0x4,%rbx
mov    %r15,%r13
cmp    $0x1e,%r15
jne    1170 <main+0x30>
add    $0x1,%r14d
lea    0xe5d(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <getch@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
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 = [59 x i8] c"O maior numero dado e o: %d, que foi o %d numero digitado.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [30 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 1, i32* %5
%7 = 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 %8
8: ; preds = %33, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 30
br i1 %10, label %11, label %36
11: ; preds = %8
%12 = load i32, i32* %5
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 %15
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %16)
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
store i32 %19, i32* %5
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = load i32, i32* %3
%25 = icmp sgt i32 %23, %24
br i1 %25, label %26, label %32
26: ; preds = %11
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 %28
%30 = load i32, i32* %29
store i32 %30, i32* %3
%31 = load i32, i32* %4
store i32 %31, i32* %6
br label %32
32: ; preds = %26, %11
br label %33
33: ; preds = %32
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %8
36: ; preds = %8
%37 = load i32, i32* %3
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0), i32 %37, i32 %39)
%41 = 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 = [59 x i8] c"O maior numero dado e o: %d, que foi o %d numero digitado.\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 ], [ %18, %4 ]
%6 = phi i32 [ undef, %0 ], [ %17, %4 ]
%7 = phi i32 [ 1, %0 ], [ %12, %4 ]
%8 = phi i32 [ 0, %0 ], [ %15, %4 ]
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%10 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 %5
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %10)
%12 = add nuw nsw i32 %7, 1
%13 = load i32, i32* %10
%14 = icmp sgt i32 %13, %8
%15 = select i1 %14, i32 %13, i32 %8
%16 = trunc i64 %5 to i32
%17 = select i1 %14, i32 %16, i32 %6
%18 = add nuw nsw i64 %5, 1
%19 = icmp eq i64 %18, 30
br i1 %19, label %20, label %4
20: ; preds = %4
%21 = add nsw i32 %17, 1
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0), i32 %15, i32 %21)
%23 = call i32 (...) @getch()
ret i32 0
}