#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, cont = 0;
  float media, mediatot = 0;
  printf("Entre com a nota n1: ");
  scanf("%d", &n1);
  while (n1 >= 0) {
    printf("Entre com a nota n2: ");
    scanf("%d", &n2);
    media = (n1 * 0.3) + (n2 * 0.7);
    printf("Media = %.1f\n", media);
    if (media >= 60)
      printf("Aluno aprovado\n");
    else
      printf("Aluno em prova final\n");
    mediatot = mediatot + media;
    cont++;
    printf("Entre com a nota n1: ");
    scanf("%d", &n1);
  }
  if (cont > 0) {
    mediatot = mediatot / cont;
    printf("\nMedia da turma = %.1f\n", mediatot);
  } else
    printf("Nao ha alunos a serem processados");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     123c <main+0x11c>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb3(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cvtsi2sdl -0x8(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe7a(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe66(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe84(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x14(%rbp),%xmm0
movss  0xe29(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     11f3 <main+0xd3>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1201 <main+0xe1>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe00(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
jmp    115c <main+0x3c>
cmpl   $0x0,-0x10(%rbp)
jle    1275 <main+0x155>
movss  -0x18(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe12(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1283 <main+0x163>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xecf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed7(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
js     1275 <main+0x145>
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
lea    0xeb2(%rip),%rbx
lea    0xf0c(%rip),%r14
lea    0xf1a(%rip),%r15
lea    0xe87(%rip),%r13
lea    0x8(%rsp),%rbp
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe86(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0x14(%rsp),%rsi
call   1050 <scanf@plt>
xorps  %xmm0,%xmm0
cvtsi2sdl 0x8(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl 0x14(%rsp),%xmm1
mulsd  0xe2b(%rip),%xmm1
mulsd  0xe2b(%rip),%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
cvtss2sd %xmm0,%xmm0
lea    0xe4d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x10(%rsp),%xmm0
ucomiss 0xe06(%rip),%xmm0
mov    %r15,%rdi
cmovb  %r14,%rdi
call   1030 <puts@plt>
movss  0xc(%rsp),%xmm0
addss  0x10(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
add    $0x1,%r12d
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jns    11a0 <main+0x70>
xorps  %xmm0,%xmm0
cvtsi2ss %r12d,%xmm0
movss  0xc(%rsp),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xde5(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1283 <main+0x153>
lea    0xded(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Entre com a nota n1: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"Entre com a nota n2: \00"
@.str.3 = [14 x i8] c"Media = %.1f\0A\00"
@.str.4 = [16 x i8] c"Aluno aprovado\0A\00"
@.str.5 = [22 x i8] c"Aluno em prova final\0A\00"
@.str.6 = [24 x i8] c"\0AMedia da turma = %.1f\0A\00"
@.str.7 = [34 x i8] c"Nao ha alunos a serem processados\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
store i32 0, i32* %4
store float 0.000000e+00, float* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 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* %2)
br label %9
9: ; preds = %31, %0
%10 = load i32, i32* %2
%11 = icmp sge i32 %10, 0
br i1 %11, label %12, label %39
12: ; preds = %9
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %2
%16 = sitofp i32 %15 to double
%17 = load i32, i32* %3
%18 = sitofp i32 %17 to double
%19 = fmul double %18, 0x3FE6666666666666
%20 = call double @llvm.fmuladd.f64(double %16, double 3.000000e-01, double %19)
%21 = fptrunc double %20 to float
store float %21, float* %5
%22 = load float, float* %5
%23 = fpext float %22 to double
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), double %23)
%25 = load float, float* %5
%26 = fcmp oge float %25, 6.000000e+01
br i1 %26, label %27, label %29
27: ; preds = %12
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %31
29: ; preds = %12
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
br label %31
31: ; preds = %29, %27
%32 = load float, float* %6
%33 = load float, float* %5
%34 = fadd float %32, %33
store float %34, float* %6
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 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* %2)
br label %9
39: ; preds = %9
%40 = load i32, i32* %4
%41 = icmp sgt i32 %40, 0
br i1 %41, label %42, label %50
42: ; preds = %39
%43 = load float, float* %6
%44 = load i32, i32* %4
%45 = sitofp i32 %44 to float
%46 = fdiv float %43, %45
store float %46, float* %6
%47 = load float, float* %6
%48 = fpext float %47 to double
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), double %48)
br label %52
50: ; preds = %39
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
br label %52
52: ; preds = %50, %42
%53 = load i32, i32* %1
ret i32 %53
}

LLVM IR (-O2):
@.str = [22 x i8] c"Entre com a nota n1: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"Entre com a nota n2: \00"
@.str.3 = [14 x i8] c"Media = %.1f\0A\00"
@.str.6 = [24 x i8] c"\0AMedia da turma = %.1f\0A\00"
@.str.7 = [34 x i8] c"Nao ha alunos a serem processados\00"
@str = [21 x i8] c"Aluno em prova final\00"
@str.8 = [15 x i8] c"Aluno aprovado\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 ([22 x i8], [22 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* %1)
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, -1
br i1 %8, label %9, label %37
9: ; preds = %0, %9
%10 = phi float [ %26, %9 ], [ 0.000000e+00, %0 ]
%11 = phi i32 [ %27, %9 ], [ 0, %0 ]
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %1
%15 = sitofp i32 %14 to double
%16 = load i32, i32* %2
%17 = sitofp i32 %16 to double
%18 = fmul double %17, 0x3FE6666666666666
%19 = call double @llvm.fmuladd.f64(double %15, double 3.000000e-01, double %18)
%20 = fptrunc double %19 to float
%21 = fpext float %20 to double
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), double %21)
%23 = fcmp ult float %20, 6.000000e+01
%24 = select i1 %23, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str.8, i64 0, i64 0)
%25 = call i32 @puts(i8* dereferenceable(1) %24)
%26 = fadd float %10, %20
%27 = add nuw nsw i32 %11, 1
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%30 = load i32, i32* %1
%31 = icmp sgt i32 %30, -1
br i1 %31, label %9, label %32
32: ; preds = %9
%33 = sitofp i32 %27 to float
%34 = fdiv float %26, %33
%35 = fpext float %34 to double
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), double %35)
br label %39
37: ; preds = %0
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
br label %39
39: ; preds = %37, %32
ret i32 0
}