#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 *);
void ex2() {
  int codigo, haula, sexo;
  float desconto[2] = {0.9, 0.95}, salariob, salariol, m = 0, f = 0, mbruto = 0,
        mliq = 0;
  while (1) {
    printf("Informe o codigo do professor(a): ");
    scanf("%d", &codigo);
    if (codigo == 99999)
      break;
    printf("Informe o sexo (0 = M, 1 = F): ");
    scanf("%d", &sexo);
    printf("Informe a quantidade de horas-aula mensal: ");
    scanf("%d", &haula);
    salariob = haula * 38.5;
    salariol = salariob * desconto[sexo];
    printf("Codigo: %d\n\tSalario Bruto: %.2f\n\tSalario Liquido: %.2f\n",
           codigo, salariob, salariol);
    if (!sexo) {
      mliq += salariol;
      m++;
    } else {
      mbruto += salariob;
      f++;
    }
  }
  printf("Media de salario bruto de professores do sexo feminino: %.2f\n",
         mbruto / f);
  printf("Media de salario liquido de professores do sexo masculino: %.2f\n",
         mliq / m);
}


x86 assembly (clang, -O0):
<ex2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xed9(%rip),%rax
mov    %rax,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1869f,-0x4(%rbp)
jne    1183 <ex2+0x63>
jmp    1266 <ex2+0x146>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9f(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe81(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe34(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movslq -0xc(%rbp),%rax
mulss  -0x14(%rbp,%rax,4),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x4(%rbp),%esi
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe7d(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    1240 <ex2+0x120>
movss  -0x1c(%rbp),%xmm0
addss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  0xddf(%rip),%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    1261 <ex2+0x141>
movss  -0x18(%rbp),%xmm0
addss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  0xdb9(%rip),%xmm0
addss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
jmp    1153 <ex2+0x33>
movss  -0x28(%rbp),%xmm0
divss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe43(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x2c(%rbp),%xmm0
divss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe65(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xee7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xefc(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1869f,0x8(%rsp)
jne    116a <ex2+0x4a>
movsd  0xea1(%rip),%xmm0
xorps  %xmm2,%xmm2
xorps  %xmm1,%xmm1
jmp    12d5 <ex2+0x1b5>
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
lea    0xec5(%rip),%rbx
lea    0x24(%rsp),%r13
lea    0xe8a(%rip),%r12
lea    0xf01(%rip),%rbp
lea    0xe88(%rip),%r14
lea    0x8(%rsp),%r15
xorps  %xmm0,%xmm0
movss  %xmm0,0x14(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
jmp    1209 <ex2+0xe9>
cs nopw 0x0(%rax,%rax,1)
movss  0x14(%rsp),%xmm0
addss  0x20(%rsp),%xmm0
movss  %xmm0,0x14(%rsp)
movss  0x10(%rsp),%xmm0
addss  0xe38(%rip),%xmm0
movss  %xmm0,0x10(%rsp)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
cmpl   $0x1869f,0x8(%rsp)
je     12b9 <ex2+0x199>
lea    0xe32(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
lea    0x18(%rsp),%rsi
call   1040 <scanf@plt>
lea    0xe37(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
cvtsi2sdl 0x24(%rsp),%xmm0
mulsd  0xdba(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movslq 0x18(%rsp),%rax
movss  (%r12,%rax,4),%xmm1
mulss  %xmm0,%xmm1
mov    0x8(%rsp),%esi
movss  %xmm0,0x20(%rsp)
cvtss2sd %xmm0,%xmm0
movss  %xmm1,0x1c(%rsp)
cvtss2sd %xmm1,%xmm1
mov    %rbp,%rdi
mov    $0x2,%al
call   1030 <printf@plt>
cmpl   $0x0,0x18(%rsp)
jne    11c0 <ex2+0xa0>
movss  0x4(%rsp),%xmm0
addss  0x1c(%rsp),%xmm0
movss  %xmm0,0x4(%rsp)
movss  0xc(%rsp),%xmm0
addss  0xd6a(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
jmp    11e6 <ex2+0xc6>
movss  0x14(%rsp),%xmm0
divss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x4(%rsp),%xmm1
movss  0xc(%rsp),%xmm2
divss  %xmm2,%xmm1
movss  %xmm1,0x4(%rsp)
lea    0xde0(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe06(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.ex2.desconto = [2 x float] [float 0x3FECCCCCC0000000, float 0x3FEE666660000000]
@.str = [35 x i8] c"Informe o codigo do professor(a): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"Informe o sexo (0 = M, 1 = F): \00"
@.str.3 = [44 x i8] c"Informe a quantidade de horas-aula mensal: \00"
@.str.4 = [56 x i8] c"Codigo: %d\0A\09Salario Bruto: %.2f\0A\09Salario Liquido: %.2f\0A\00"
@.str.5 = [62 x i8] c"Media de salario bruto de professores do sexo feminino: %.2f\0A\00"
@.str.6 = [65 x i8] c"Media de salario liquido de professores do sexo masculino: %.2f\0A\00"
define void @ex2() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [2 x float]
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = bitcast [2 x float]* %4 to i8*
store float 0.000000e+00, float* %7
store float 0.000000e+00, float* %8
store float 0.000000e+00, float* %9
store float 0.000000e+00, float* %10
br label %12
12: ; preds = %0, %53
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = icmp eq i32 %15, 99999
br i1 %16, label %17, label %18
17: ; preds = %12
br label %54
18: ; preds = %12
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%23 = load i32, i32* %2
%24 = sitofp i32 %23 to double
%25 = fmul double %24, 3.850000e+01
%26 = fptrunc double %25 to float
store float %26, float* %5
%27 = load float, float* %5
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [2 x float], [2 x float]* %4, i64 0, i64 %29
%31 = load float, float* %30
%32 = fmul float %27, %31
store float %32, float* %6
%33 = load i32, i32* %1
%34 = load float, float* %5
%35 = fpext float %34 to double
%36 = load float, float* %6
%37 = fpext float %36 to double
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0), i32 %33, double %35, double %37)
%39 = load i32, i32* %3
%40 = icmp ne i32 %39, 0
br i1 %40, label %47, label %41
41: ; preds = %18
%42 = load float, float* %6
%43 = load float, float* %10
%44 = fadd float %43, %42
store float %44, float* %10
%45 = load float, float* %7
%46 = fadd float %45, 1.000000e+00
store float %46, float* %7
br label %53
47: ; preds = %18
%48 = load float, float* %5
%49 = load float, float* %9
%50 = fadd float %49, %48
store float %50, float* %9
%51 = load float, float* %8
%52 = fadd float %51, 1.000000e+00
store float %52, float* %8
br label %53
53: ; preds = %47, %41
br label %12
54: ; preds = %17
%55 = load float, float* %9
%56 = load float, float* %8
%57 = fdiv float %55, %56
%58 = fpext float %57 to double
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.5, i64 0, i64 0), double %58)
%60 = load float, float* %10
%61 = load float, float* %7
%62 = fdiv float %60, %61
%63 = fpext float %62 to double
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.6, i64 0, i64 0), double %63)
ret void
}

LLVM IR (-O2):
@__const.ex2.desconto = [2 x float] [float 0x3FECCCCCC0000000, float 0x3FEE666660000000]
@.str = [35 x i8] c"Informe o codigo do professor(a): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"Informe o sexo (0 = M, 1 = F): \00"
@.str.3 = [44 x i8] c"Informe a quantidade de horas-aula mensal: \00"
@.str.4 = [56 x i8] c"Codigo: %d\0A\09Salario Bruto: %.2f\0A\09Salario Liquido: %.2f\0A\00"
@.str.5 = [62 x i8] c"Media de salario bruto de professores do sexo feminino: %.2f\0A\00"
@.str.6 = [65 x i8] c"Media de salario liquido de professores do sexo masculino: %.2f\0A\00"
define void @ex2() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 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 = icmp eq i32 %9, 99999
br i1 %10, label %53, label %11
11: ; preds = %0, %41
%12 = phi float [ %45, %41 ], [ 0.000000e+00, %0 ]
%13 = phi float [ %44, %41 ], [ 0.000000e+00, %0 ]
%14 = phi float [ %43, %41 ], [ 0.000000e+00, %0 ]
%15 = phi float [ %42, %41 ], [ 0.000000e+00, %0 ]
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%20 = load i32, i32* %2
%21 = sitofp i32 %20 to double
%22 = fmul double %21, 3.850000e+01
%23 = fptrunc double %22 to float
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [2 x float], [2 x float]* @__const.ex2.desconto, i64 0, i64 %25
%27 = load float, float* %26
%28 = fmul float %27, %23
%29 = load i32, i32* %1
%30 = fpext float %23 to double
%31 = fpext float %28 to double
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0), i32 %29, double %30, double %31)
%33 = load i32, i32* %3
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %11
%36 = fadd float %12, %28
%37 = fadd float %15, 1.000000e+00
br label %41
38: ; preds = %11
%39 = fadd float %13, %23
%40 = fadd float %14, 1.000000e+00
br label %41
41: ; preds = %38, %35
%42 = phi float [ %15, %38 ], [ %37, %35 ]
%43 = phi float [ %40, %38 ], [ %14, %35 ]
%44 = phi float [ %39, %38 ], [ %13, %35 ]
%45 = phi float [ %12, %38 ], [ %36, %35 ]
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%47 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%48 = load i32, i32* %1
%49 = icmp eq i32 %48, 99999
br i1 %49, label %50, label %11
50: ; preds = %41
%51 = fdiv float %44, %43
%52 = fpext float %51 to double
br label %53
53: ; preds = %50, %0
%54 = phi float [ 0.000000e+00, %0 ], [ %42, %50 ]
%55 = phi float [ 0.000000e+00, %0 ], [ %45, %50 ]
%56 = phi double [ 0x7FF8000000000000, %0 ], [ %52, %50 ]
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.5, i64 0, i64 0), double %56)
%58 = fdiv float %55, %54
%59 = fpext float %58 to double
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.6, i64 0, i64 0), double %59)
ret void
}