#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 a[4], b, c, d, i, e;
  printf("Escriba %d números: ", 4);
  for (i = 0; i < 4; i++) {
    scanf("%d", &a[i]);
  }
  c = a[0];
  for (i = 1; i < 4; i++) {
    if (a[i] > c) {
      e = d;
      d = c;
      c = a[i];
    } else if (a[i] > d) {
      e = d;
      d = a[i];
    } else if (a[i] > e) {
      e = a[i];
    }
  }
  printf("\n");
  printf("\n%d", c);
  printf("\n%d", d);
  printf("\n%d", e);
  printf("\n\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x30(%rbp)
cmpl   $0x4,-0x30(%rbp)
jge    117c <main+0x5c>
movslq -0x30(%rbp),%rax
lea    -0x20(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xeae(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1149 <main+0x29>
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
movl   $0x1,-0x30(%rbp)
cmpl   $0x4,-0x30(%rbp)
jge    1220 <main+0x100>
movslq -0x30(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
cmp    -0x28(%rbp),%eax
jle    11c0 <main+0xa0>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movslq -0x30(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
mov    %eax,-0x28(%rbp)
jmp    120d <main+0xed>
movslq -0x30(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
cmp    -0x2c(%rbp),%eax
jle    11e7 <main+0xc7>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x34(%rbp)
movslq -0x30(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
mov    %eax,-0x2c(%rbp)
jmp    1208 <main+0xe8>
movslq -0x30(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
cmp    -0x34(%rbp),%eax
jle    1203 <main+0xe3>
movslq -0x30(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
mov    %eax,-0x34(%rbp)
jmp    1208 <main+0xe8>
jmp    120d <main+0xed>
jmp    1212 <main+0xf2>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1189 <main+0x69>
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%esi
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xeaf(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb3(%rip),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
cmp    %eax,%ecx
cmovle %eax,%ecx
mov    0x8(%rsp),%ebp
cmp    %eax,%ebp
mov    %eax,%ebx
cmovg  %ebp,%ebx
cmp    %ecx,%ebp
cmovle %ecx,%ebp
cmovg  %ecx,%ebx
mov    0xc(%rsp),%ecx
cmp    %ebp,%ecx
jle    11c2 <main+0x82>
mov    %ecx,%r14d
jmp    11d9 <main+0x99>
cmp    %ebx,%ecx
jle    11cd <main+0x8d>
mov    %ebp,%r14d
mov    %ecx,%ebp
jmp    11d9 <main+0x99>
cmp    %eax,%ecx
cmovg  %ecx,%eax
mov    %ebp,%r14d
mov    %ebx,%ebp
mov    %eax,%ebx
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe2c(%rip),%r15
mov    %r15,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe04(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Escriba %d n\C3\BAmeros: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [4 x i8] c"\0A%d\00"
@.str.4 = [3 x i8] c"\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 4)
store i32 0, i32* %6
br label %9
9: ; preds = %17, %0
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %20
12: ; preds = %9
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %14
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %15)
br label %17
17: ; preds = %12
%18 = load i32, i32* %6
%19 = add nsw i32 %18, 1
store i32 %19, i32* %6
br label %9
20: ; preds = %9
%21 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%22 = load i32, i32* %21
store i32 %22, i32* %4
store i32 1, i32* %6
br label %23
23: ; preds = %68, %20
%24 = load i32, i32* %6
%25 = icmp slt i32 %24, 4
br i1 %25, label %26, label %71
26: ; preds = %23
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = load i32, i32* %4
%32 = icmp sgt i32 %30, %31
br i1 %32, label %33, label %40
33: ; preds = %26
%34 = load i32, i32* %5
store i32 %34, i32* %7
%35 = load i32, i32* %4
store i32 %35, i32* %5
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %37
%39 = load i32, i32* %38
store i32 %39, i32* %4
br label %67
40: ; preds = %26
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = load i32, i32* %5
%46 = icmp sgt i32 %44, %45
br i1 %46, label %47, label %53
47: ; preds = %40
%48 = load i32, i32* %5
store i32 %48, i32* %7
%49 = load i32, i32* %6
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %50
%52 = load i32, i32* %51
store i32 %52, i32* %5
br label %66
53: ; preds = %40
%54 = load i32, i32* %6
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %55
%57 = load i32, i32* %56
%58 = load i32, i32* %7
%59 = icmp sgt i32 %57, %58
br i1 %59, label %60, label %65
60: ; preds = %53
%61 = load i32, i32* %6
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %62
%64 = load i32, i32* %63
store i32 %64, i32* %7
br label %65
65: ; preds = %60, %53
br label %66
66: ; preds = %65, %47
br label %67
67: ; preds = %66, %33
br label %68
68: ; preds = %67
%69 = load i32, i32* %6
%70 = add nsw i32 %69, 1
store i32 %70, i32* %6
br label %23
71: ; preds = %23
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%73 = load i32, i32* %4
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %73)
%75 = load i32, i32* %5
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %75)
%77 = load i32, i32* %7
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %77)
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%80 = load i32, i32* %1
ret i32 %80
}

LLVM IR (-O2):
@.str = [22 x i8] c"Escriba %d n\C3\BAmeros: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"\0A%d\00"
@str = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca [4 x i32]
%2 = bitcast [4 x i32]* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 4)
%4 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%6 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 1
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 2
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 3
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %10)
%12 = load i32, i32* %4
%13 = load i32, i32* %6
%14 = icmp sgt i32 %13, %12
%15 = select i1 %14, i32 %13, i32 %12
%16 = load i32, i32* %8
%17 = icmp sgt i32 %16, %15
%18 = icmp sgt i32 %16, %12
%19 = select i1 %18, i32 %16, i32 %12
%20 = select i1 %17, i32 %16, i32 %15
%21 = select i1 %17, i32 %15, i32 %19
%22 = load i32, i32* %10
%23 = icmp sgt i32 %22, %20
br i1 %23, label %29, label %24
24: ; preds = %0
%25 = icmp sgt i32 %22, %21
br i1 %25, label %29, label %26
26: ; preds = %24
%27 = icmp sgt i32 %22, %12
%28 = select i1 %27, i32 %22, i32 %12
br label %29
29: ; preds = %26, %24, %0
%30 = phi i32 [ %22, %0 ], [ %20, %24 ], [ %20, %26 ]
%31 = phi i32 [ %20, %0 ], [ %22, %24 ], [ %21, %26 ]
%32 = phi i32 [ %21, %0 ], [ %21, %24 ], [ %28, %26 ]
%33 = call i32 @putchar(i32 10)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %31)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret i32 0
}