#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 *, ...);
void calc_habitante(float *mf, float *maiorS, float *mediaS, float *pp) {
  float salario;
  int filho, flg;
  *pp = 0;
  for (int i = 0;; i++) {
    printf("Informe o numero de filhos: ");
    scanf("%d", &filho);
    *mf += filho;
    printf("Informe o salario: ");
    scanf("%f", &salario);
    *mediaS += salario;
    if (i == 0) {
      *maiorS = salario;
    } else if (salario > *maiorS) {
      *maiorS = salario;
    }
    if (salario <= 350) {
      *pp += 1;
    }
    printf("Informar novo habitante?\n1 - Sim\n2 - Nao\n");
    scanf("%d", &flg);
    if (flg == 2) {
      *mf /= i;
      *mediaS /= i;
      *pp /= i;
      break;
    }
  }
}


x86 assembly (clang, -O0):
<calc_habitante>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
movl   $0x0,-0x30(%rbp)
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cvtsi2ssl -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
addss  (%rax),%xmm0
movss  %xmm0,(%rax)
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x24(%rbp),%xmm0
mov    -0x18(%rbp),%rax
addss  (%rax),%xmm0
movss  %xmm0,(%rax)
cmpl   $0x0,-0x30(%rbp)
jne    11c4 <calc_habitante+0xa4>
movss  -0x24(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
jmp    11e8 <calc_habitante+0xc8>
movss  -0x24(%rbp),%xmm0
mov    -0x10(%rbp),%rax
ucomiss (%rax),%xmm0
jbe    11e3 <calc_habitante+0xc3>
movss  -0x24(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
jmp    11e8 <calc_habitante+0xc8>
movss  0xe10(%rip),%xmm0
ucomiss -0x24(%rbp),%xmm0
jb     120e <calc_habitante+0xee>
mov    -0x20(%rbp),%rax
movss  0xdfe(%rip),%xmm0
addss  (%rax),%xmm0
movss  %xmm0,(%rax)
lea    0xe2a(%rip),%rdi
call   1030 <printf@plt>
lea    0xe04(%rip),%rdi
lea    -0x2c(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x2,-0x2c(%rbp)
jne    127a <calc_habitante+0x15a>
cvtsi2ssl -0x30(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,(%rax)
cvtsi2ssl -0x30(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,(%rax)
cvtsi2ssl -0x30(%rbp),%xmm1
mov    -0x20(%rbp),%rax
movss  (%rax),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,(%rax)
jmp    128d <calc_habitante+0x16d>
jmp    127f <calc_habitante+0x15f>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    114a <calc_habitante+0x2a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_habitante>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
movl   $0x0,(%rcx)
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
lea    0xec2(%rip),%rdi
xor    %r13d,%r13d
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cvtsi2ssl 0x10(%rsp),%xmm0
addss  (%rbx),%xmm0
movss  %xmm0,(%rbx)
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
lea    0xea9(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x14(%rsp),%xmm0
movss  (%r15),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,(%r15)
movss  %xmm0,(%r12)
movss  0xe3f(%rip),%xmm1
ucomiss %xmm0,%xmm1
jb     11d8 <calc_habitante+0xa8>
movss  (%r14),%xmm0
addss  0xe31(%rip),%xmm0
movss  %xmm0,(%r14)
lea    0xe60(%rip),%rdi
call   1030 <puts@plt>
lea    0xe3a(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x2,0xc(%rsp)
jne    123d <calc_habitante+0x10d>
xorps  %xmm0,%xmm0
cvtsi2ss %r13d,%xmm0
movss  (%rbx),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,(%rbx)
movss  (%r15),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,(%r15)
movss  (%r14),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xde1(%rip),%rbp
xor    %r13d,%r13d
jmp    1276 <calc_habitante+0x146>
nopl   0x0(%rax)
lea    0xde8(%rip),%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%r13d
cmpl   $0x2,0xc(%rsp)
je     11fe <calc_habitante+0xce>
lea    0xd8b(%rip),%rdi
call   1040 <printf@plt>
mov    %rbp,%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
xorps  %xmm0,%xmm0
cvtsi2ssl 0x10(%rsp),%xmm0
addss  (%rbx),%xmm0
movss  %xmm0,(%rbx)
lea    0xd7f(%rip),%rdi
call   1040 <printf@plt>
lea    0xd87(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x14(%rsp),%xmm0
movss  (%r15),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,(%r15)
ucomiss (%r12),%xmm0
jbe    12e2 <calc_habitante+0x1b2>
movss  %xmm0,(%r12)
movss  0xd16(%rip),%xmm1
ucomiss %xmm0,%xmm1
jb     1250 <calc_habitante+0x120>
movss  (%r14),%xmm0
addss  0xd04(%rip),%xmm0
movss  %xmm0,(%r14)
jmp    1250 <calc_habitante+0x120>

LLVM IR (-O0):
@.str = [29 x i8] c"Informe o numero de filhos: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"Informe o salario: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [42 x i8] c"Informar novo habitante?\0A1 - Sim\0A2 - Nao\0A\00"
define void @calc_habitante(float* %0, float* %1, float* %2, float* %3) {
%5 = alloca float*
%6 = alloca float*
%7 = alloca float*
%8 = alloca float*
%9 = alloca float
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store float* %0, float** %5
store float* %1, float** %6
store float* %2, float** %7
store float* %3, float** %8
%13 = load float*, float** %8
store float 0.000000e+00, float* %13
store i32 0, i32* %12
br label %14
14: ; preds = %71, %4
%15 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %10)
%17 = load i32, i32* %10
%18 = sitofp i32 %17 to float
%19 = load float*, float** %5
%20 = load float, float* %19
%21 = fadd float %20, %18
store float %21, float* %19
%22 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %9)
%24 = load float, float* %9
%25 = load float*, float** %7
%26 = load float, float* %25
%27 = fadd float %26, %24
store float %27, float* %25
%28 = load i32, i32* %12
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %14
%31 = load float, float* %9
%32 = load float*, float** %6
store float %31, float* %32
br label %42
33: ; preds = %14
%34 = load float, float* %9
%35 = load float*, float** %6
%36 = load float, float* %35
%37 = fcmp ogt float %34, %36
br i1 %37, label %38, label %41
38: ; preds = %33
%39 = load float, float* %9
%40 = load float*, float** %6
store float %39, float* %40
br label %41
41: ; preds = %38, %33
br label %42
42: ; preds = %41, %30
%43 = load float, float* %9
%44 = fcmp ole float %43, 3.500000e+02
br i1 %44, label %45, label %49
45: ; preds = %42
%46 = load float*, float** %8
%47 = load float, float* %46
%48 = fadd float %47, 1.000000e+00
store float %48, float* %46
br label %49
49: ; preds = %45, %42
%50 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
%51 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %11)
%52 = load i32, i32* %11
%53 = icmp eq i32 %52, 2
br i1 %53, label %54, label %70
54: ; preds = %49
%55 = load i32, i32* %12
%56 = sitofp i32 %55 to float
%57 = load float*, float** %5
%58 = load float, float* %57
%59 = fdiv float %58, %56
store float %59, float* %57
%60 = load i32, i32* %12
%61 = sitofp i32 %60 to float
%62 = load float*, float** %7
%63 = load float, float* %62
%64 = fdiv float %63, %61
store float %64, float* %62
%65 = load i32, i32* %12
%66 = sitofp i32 %65 to float
%67 = load float*, float** %8
%68 = load float, float* %67
%69 = fdiv float %68, %66
store float %69, float* %67
br label %74
70: ; preds = %49
br label %71
71: ; preds = %70
%72 = load i32, i32* %12
%73 = add nsw i32 %72, 1
store i32 %73, i32* %12
br label %14
74: ; preds = %54
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"Informe o numero de filhos: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"Informe o salario: \00"
@.str.3 = [3 x i8] c"%f\00"
@str = [41 x i8] c"Informar novo habitante?\0A1 - Sim\0A2 - Nao\00"
define void @calc_habitante(float* nocapture %0, float* nocapture %1, float* nocapture %2, float* nocapture %3) {
%5 = alloca float
%6 = alloca i32
%7 = alloca i32
%8 = bitcast float* %5 to i8*
%9 = bitcast i32* %6 to i8*
%10 = bitcast i32* %7 to i8*
store float 0.000000e+00, float* %3
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%13 = load i32, i32* %6
%14 = sitofp i32 %13 to float
%15 = load float, float* %0
%16 = fadd float %15, %14
store float %16, float* %0
%17 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %5)
%19 = load float, float* %5
%20 = load float, float* %2
%21 = fadd float %19, %20
store float %21, float* %2
store float %19, float* %1
%22 = fcmp ugt float %19, 3.500000e+02
br i1 %22, label %26, label %23
23: ; preds = %4
%24 = load float, float* %3
%25 = fadd float %24, 1.000000e+00
store float %25, float* %3
br label %26
26: ; preds = %23, %4
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%29 = load i32, i32* %7
%30 = icmp eq i32 %29, 2
br i1 %30, label %58, label %31
31: ; preds = %26, %52
%32 = phi i32 [ %57, %52 ], [ 1, %26 ]
%33 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%35 = load i32, i32* %6
%36 = sitofp i32 %35 to float
%37 = load float, float* %0
%38 = fadd float %37, %36
store float %38, float* %0
%39 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%40 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %5)
%41 = load float, float* %5
%42 = load float, float* %2
%43 = fadd float %41, %42
store float %43, float* %2
%44 = load float, float* %1
%45 = fcmp ogt float %41, %44
br i1 %45, label %46, label %47
46: ; preds = %31
store float %41, float* %1
br label %47
47: ; preds = %31, %46
%48 = fcmp ugt float %41, 3.500000e+02
br i1 %48, label %52, label %49
49: ; preds = %47
%50 = load float, float* %3
%51 = fadd float %50, 1.000000e+00
store float %51, float* %3
br label %52
52: ; preds = %49, %47
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%54 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%55 = load i32, i32* %7
%56 = icmp eq i32 %55, 2
%57 = add nuw nsw i32 %32, 1
br i1 %56, label %58, label %31
58: ; preds = %52, %26
%59 = phi i32 [ 0, %26 ], [ %32, %52 ]
%60 = sitofp i32 %59 to float
%61 = load float, float* %0
%62 = fdiv float %61, %60
store float %62, float* %0
%63 = load float, float* %2
%64 = fdiv float %63, %60
store float %64, float* %2
%65 = load float, float* %3
%66 = fdiv float %65, %60
store float %66, float* %3
ret void
}