#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 main() {
  int n1, n2, p1, p2, m1, m2;
  char nome1[21], nome2[21];
  printf("Quem foi melhor na escola?\nDigite o nome de duas pessoas que terao "
         "suas notas comparadas:\n");
  scanf("%s"
        "%s",
        &nome1, &nome2);
  printf("Digite agora as duas notas do %s\n", nome1);
  scanf("%d"
        "%d",
        &n1, &n2);
  printf("Digite agora as duas notas do %s\n", nome2);
  scanf("%d"
        "%d",
        &p1, &p2);
  m1 = (n1 + n2) / 2;
  m2 = (p1 + p2) / 2;
  if (m1 > m2) {
    printf("O aluno %s teve media superior a do aluno %s\n", nome1, nome2);
  } else {
    printf("O aluno %s teve media superior a do aluno %s\n", nome2, nome1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf17(%rip),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x60(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
lea    -0x40(%rbp),%rsi
lea    0xf02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf16(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
lea    -0x60(%rbp),%rsi
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeee(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    11ec <main+0xcc>
lea    -0x40(%rbp),%rsi
lea    -0x60(%rbp),%rdx
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1202 <main+0xe2>
lea    -0x60(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
lea    0xf1a(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb4(%rip),%rdi
lea    0x30(%rsp),%rbx
lea    0x10(%rsp),%r14
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe9b(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea9(%rip),%rbx
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x8(%rsp),%eax
add    0xc(%rsp),%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
mov    (%rsp),%eax
add    0x4(%rsp),%eax
mov    %eax,%edx
shr    $0x1f,%edx
add    %eax,%edx
sar    %edx
lea    0xe53(%rip),%rdi
cmp    %edx,%ecx
jle    11e9 <main+0xb9>
lea    0x30(%rsp),%rsi
lea    0x10(%rsp),%rdx
jmp    11f3 <main+0xc3>
lea    0x10(%rsp),%rsi
lea    0x30(%rsp),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [91 x i8] c"Quem foi melhor na escola?\0ADigite o nome de duas pessoas que terao suas notas comparadas:\0A\00"
@.str.1 = [5 x i8] c"%s%s\00"
@.str.2 = [34 x i8] c"Digite agora as duas notas do %s\0A\00"
@.str.3 = [5 x i8] c"%d%d\00"
@.str.4 = [46 x i8] c"O aluno %s teve media superior a do aluno %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [21 x i8]
%9 = alloca [21 x i8]
store i32 0, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), [21 x i8]* %8, [21 x i8]* %9)
%12 = getelementptr inbounds [21 x i8], [21 x i8]* %8, i64 0, i64 0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32* %2, i32* %3)
%15 = getelementptr inbounds [21 x i8], [21 x i8]* %9, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32* %4, i32* %5)
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = add nsw i32 %18, %19
%21 = sdiv i32 %20, 2
store i32 %21, i32* %6
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = add nsw i32 %22, %23
%25 = sdiv i32 %24, 2
store i32 %25, i32* %7
%26 = load i32, i32* %6
%27 = load i32, i32* %7
%28 = icmp sgt i32 %26, %27
br i1 %28, label %29, label %33
29: ; preds = %0
%30 = getelementptr inbounds [21 x i8], [21 x i8]* %8, i64 0, i64 0
%31 = getelementptr inbounds [21 x i8], [21 x i8]* %9, i64 0, i64 0
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i8* %30, i8* %31)
br label %37
33: ; preds = %0
%34 = getelementptr inbounds [21 x i8], [21 x i8]* %9, i64 0, i64 0
%35 = getelementptr inbounds [21 x i8], [21 x i8]* %8, i64 0, i64 0
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i8* %34, i8* %35)
br label %37
37: ; preds = %33, %29
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%s%s\00"
@.str.2 = [34 x i8] c"Digite agora as duas notas do %s\0A\00"
@.str.3 = [5 x i8] c"%d%d\00"
@.str.4 = [46 x i8] c"O aluno %s teve media superior a do aluno %s\0A\00"
@str = [90 x i8] c"Quem foi melhor na escola?\0ADigite o nome de duas pessoas que terao suas notas comparadas:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [21 x i8]
%6 = alloca [21 x i8]
%7 = bitcast i32* %1 to i8*
%8 = bitcast i32* %2 to i8*
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = getelementptr inbounds [21 x i8], [21 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [21 x i8], [21 x i8]* %6, i64 0, i64 0
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([90 x i8], [90 x i8]* @str, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), [21 x i8]* %5, [21 x i8]* %6)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32* %1, i32* %2)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32* %3, i32* %4)
%19 = load i32, i32* %1
%20 = load i32, i32* %2
%21 = add nsw i32 %20, %19
%22 = sdiv i32 %21, 2
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = add nsw i32 %24, %23
%26 = sdiv i32 %25, 2
%27 = icmp sgt i32 %22, %26
br i1 %27, label %28, label %30
28: ; preds = %0
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i8* %11, i8* %12)
br label %32
30: ; preds = %0
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i8* %12, i8* %11)
br label %32
32: ; preds = %30, %28
ret i32 0
}