#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 *);
int main() {
  int n, maior, segMaior, i;
  printf("Entre com um número: ");
  scanf("%d", &maior);
  printf("Entre com um número: ");
  scanf("%d", &n);
  if (n > maior) {
    segMaior = maior;
    maior = n;
  } else {
    segMaior = n;
  }
  for (i = 0; 8 > i; i++) {
    printf("Entre com um número: ");
    scanf("%d", &n);
    if (n > maior) {
      segMaior = maior;
      maior = n;
    } else if (n > segMaior) {
      segMaior = n;
    }
  };
  printf("O segundo maior número é: %d \n", segMaior);
  printf("O maior número é: %d \n", maior);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1188 <main+0x68>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    118e <main+0x6e>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x8,%eax
cmp    -0x14(%rbp),%eax
jle    1208 <main+0xe8>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5f(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11de <main+0xbe>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11f5 <main+0xd5>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11f0 <main+0xd0>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11f5 <main+0xd5>
jmp    11fa <main+0xda>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1195 <main+0x75>
mov    -0x10(%rbp),%esi
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed1(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed7(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
mov    0x8(%rsp),%ebp
cmp    %ebp,%eax
jle    1176 <main+0x56>
mov    %eax,0x8(%rsp)
jmp    1178 <main+0x58>
mov    %eax,%ebp
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe8a(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
mov    0x8(%rsp),%ebx
cmp    %ebx,%eax
jle    11a9 <main+0x89>
mov    %eax,0x8(%rsp)
jmp    11b0 <main+0x90>
cmp    %ebp,%eax
cmovg  %eax,%ebp
mov    %ebp,%ebx
lea    0xe49(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe52(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
mov    0x8(%rsp),%ebp
cmp    %ebp,%eax
jle    11e1 <main+0xc1>
mov    %eax,0x8(%rsp)
jmp    11e8 <main+0xc8>
cmp    %ebx,%eax
cmovg  %eax,%ebx
mov    %ebx,%ebp
lea    0xe11(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe1a(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
mov    0x8(%rsp),%ebx
cmp    %ebx,%eax
jle    1219 <main+0xf9>
mov    %eax,0x8(%rsp)
jmp    1220 <main+0x100>
cmp    %ebp,%eax
cmovg  %eax,%ebp
mov    %ebp,%ebx
lea    0xdd9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xde2(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
mov    0x8(%rsp),%ebp
cmp    %ebp,%eax
jle    1251 <main+0x131>
mov    %eax,0x8(%rsp)
jmp    1258 <main+0x138>
cmp    %ebx,%eax
cmovg  %eax,%ebx
mov    %ebx,%ebp
lea    0xda1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xdaa(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
mov    0x8(%rsp),%ebx
cmp    %ebx,%eax
jle    1289 <main+0x169>
mov    %eax,0x8(%rsp)
jmp    1290 <main+0x170>
cmp    %ebp,%eax
cmovg  %eax,%ebp
mov    %ebp,%ebx
lea    0xd69(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xd72(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
mov    0x8(%rsp),%ebp
cmp    %ebp,%eax
jle    12c1 <main+0x1a1>
mov    %eax,0x8(%rsp)
jmp    12c8 <main+0x1a8>
cmp    %ebx,%eax
cmovg  %eax,%ebx
mov    %ebx,%ebp
lea    0xd31(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xd3a(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
mov    0x8(%rsp),%ebx
cmp    %ebx,%eax
jle    12f9 <main+0x1d9>
mov    %eax,0x8(%rsp)
jmp    1300 <main+0x1e0>
cmp    %ebp,%eax
cmovg  %eax,%ebp
mov    %ebp,%ebx
lea    0xcf9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xd02(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
mov    0x8(%rsp),%esi
cmp    %esi,%eax
jle    1331 <main+0x211>
mov    %eax,0x8(%rsp)
jmp    1338 <main+0x218>
cmp    %ebx,%eax
cmovg  %eax,%ebx
mov    %ebx,%esi
lea    0xcdb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%esi
lea    0xcea(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Entre com um n\C3\BAmero: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"O segundo maior n\C3\BAmero \C3\A9: %d \0A\00"
@.str.3 = [25 x i8] c"O maior n\C3\BAmero \C3\A9: %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = icmp sgt i32 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = load i32, i32* %3
store i32 %14, i32* %4
%15 = load i32, i32* %2
store i32 %15, i32* %3
br label %18
16: ; preds = %0
%17 = load i32, i32* %2
store i32 %17, i32* %4
br label %18
18: ; preds = %16, %13
store i32 0, i32* %5
br label %19
19: ; preds = %39, %18
%20 = load i32, i32* %5
%21 = icmp sgt i32 8, %20
br i1 %21, label %22, label %42
22: ; preds = %19
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = icmp sgt i32 %25, %26
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = load i32, i32* %3
store i32 %29, i32* %4
%30 = load i32, i32* %2
store i32 %30, i32* %3
br label %38
31: ; preds = %22
%32 = load i32, i32* %2
%33 = load i32, i32* %4
%34 = icmp sgt i32 %32, %33
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = load i32, i32* %2
store i32 %36, i32* %4
br label %37
37: ; preds = %35, %31
br label %38
38: ; preds = %37, %28
br label %39
39: ; preds = %38
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %19
42: ; preds = %19
%43 = load i32, i32* %4
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %3
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %45)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Entre com um n\C3\BAmero: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"O segundo maior n\C3\BAmero \C3\A9: %d \0A\00"
@.str.3 = [25 x i8] c"O maior n\C3\BAmero \C3\A9: %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = icmp sgt i32 %9, %10
br i1 %11, label %12, label %13
12: ; preds = %0
store i32 %9, i32* %2
br label %13
13: ; preds = %0, %12
%14 = phi i32 [ %10, %12 ], [ %9, %0 ]
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = icmp sgt i32 %17, %18
br i1 %19, label %20, label %21
20: ; preds = %13
store i32 %17, i32* %2
br label %24
21: ; preds = %13
%22 = icmp sgt i32 %17, %14
%23 = select i1 %22, i32 %17, i32 %14
br label %24
24: ; preds = %21, %20
%25 = phi i32 [ %18, %20 ], [ %23, %21 ]
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%28 = load i32, i32* %1
%29 = load i32, i32* %2
%30 = icmp sgt i32 %28, %29
br i1 %30, label %34, label %31
31: ; preds = %24
%32 = icmp sgt i32 %28, %25
%33 = select i1 %32, i32 %28, i32 %25
br label %35
34: ; preds = %24
store i32 %28, i32* %2
br label %35
35: ; preds = %34, %31
%36 = phi i32 [ %29, %34 ], [ %33, %31 ]
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%38 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%39 = load i32, i32* %1
%40 = load i32, i32* %2
%41 = icmp sgt i32 %39, %40
br i1 %41, label %45, label %42
42: ; preds = %35
%43 = icmp sgt i32 %39, %36
%44 = select i1 %43, i32 %39, i32 %36
br label %46
45: ; preds = %35
store i32 %39, i32* %2
br label %46
46: ; preds = %45, %42
%47 = phi i32 [ %40, %45 ], [ %44, %42 ]
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%49 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%50 = load i32, i32* %1
%51 = load i32, i32* %2
%52 = icmp sgt i32 %50, %51
br i1 %52, label %56, label %53
53: ; preds = %46
%54 = icmp sgt i32 %50, %47
%55 = select i1 %54, i32 %50, i32 %47
br label %57
56: ; preds = %46
store i32 %50, i32* %2
br label %57
57: ; preds = %56, %53
%58 = phi i32 [ %51, %56 ], [ %55, %53 ]
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%60 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%61 = load i32, i32* %1
%62 = load i32, i32* %2
%63 = icmp sgt i32 %61, %62
br i1 %63, label %67, label %64
64: ; preds = %57
%65 = icmp sgt i32 %61, %58
%66 = select i1 %65, i32 %61, i32 %58
br label %68
67: ; preds = %57
store i32 %61, i32* %2
br label %68
68: ; preds = %67, %64
%69 = phi i32 [ %62, %67 ], [ %66, %64 ]
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%71 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%72 = load i32, i32* %1
%73 = load i32, i32* %2
%74 = icmp sgt i32 %72, %73
br i1 %74, label %78, label %75
75: ; preds = %68
%76 = icmp sgt i32 %72, %69
%77 = select i1 %76, i32 %72, i32 %69
br label %79
78: ; preds = %68
store i32 %72, i32* %2
br label %79
79: ; preds = %78, %75
%80 = phi i32 [ %73, %78 ], [ %77, %75 ]
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%82 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%83 = load i32, i32* %1
%84 = load i32, i32* %2
%85 = icmp sgt i32 %83, %84
br i1 %85, label %89, label %86
86: ; preds = %79
%87 = icmp sgt i32 %83, %80
%88 = select i1 %87, i32 %83, i32 %80
br label %90
89: ; preds = %79
store i32 %83, i32* %2
br label %90
90: ; preds = %89, %86
%91 = phi i32 [ %84, %89 ], [ %88, %86 ]
%92 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%93 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%94 = load i32, i32* %1
%95 = load i32, i32* %2
%96 = icmp sgt i32 %94, %95
br i1 %96, label %100, label %97
97: ; preds = %90
%98 = icmp sgt i32 %94, %91
%99 = select i1 %98, i32 %94, i32 %91
br label %101
100: ; preds = %90
store i32 %94, i32* %2
br label %101
101: ; preds = %100, %97
%102 = phi i32 [ %95, %100 ], [ %99, %97 ]
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %102)
%104 = load i32, i32* %2
%105 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %104)
ret i32 0
}