#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ system(char *);
main() {
  float altura, peso_ideal;
  char flag_sexo;
  char *nome_sexo;
  printf("Qual a sua altura? ");
  scanf("%f", &altura);
  printf("Digite 'M' para mulher ou 'H' para homem: ");
  scanf("%c", &flag_sexo);
  flag_sexo = getchar();
  if ((altura > 0) && (flag_sexo == 'M' || flag_sexo == 'm' ||
                       flag_sexo == 'H' || flag_sexo == 'h')) {
    if (flag_sexo == 'M' || flag_sexo == 'm') {
      nome_sexo = "Mulher";
      peso_ideal = (62.1 * altura) - 44.7;
    } else if (flag_sexo == 'H' || flag_sexo == 'h') {
      nome_sexo = "Homem";
      peso_ideal = (72.7 * altura) - 58;
    }
    printf("[%s] O seu peso ideal deve ser: %.3f kg.\n", nome_sexo, peso_ideal);
  } else {
    printf("\nDados invalidos!");
  }
  system("pause");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed0(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xede(%rip),%rdi
lea    -0xd(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0xd(%rbp)
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    12a6 <main+0x166>
movsbl -0xd(%rbp),%eax
cmp    $0x4d,%eax
je     11de <main+0x9e>
movsbl -0xd(%rbp),%eax
cmp    $0x6d,%eax
je     11de <main+0x9e>
movsbl -0xd(%rbp),%eax
cmp    $0x48,%eax
je     11de <main+0x9e>
movsbl -0xd(%rbp),%eax
cmp    $0x68,%eax
jne    12a6 <main+0x166>
movsbl -0xd(%rbp),%eax
cmp    $0x4d,%eax
je     11f8 <main+0xb8>
movsbl -0xd(%rbp),%eax
cmp    $0x6d,%eax
jne    1232 <main+0xf2>
lea    0xe66(%rip),%rax
mov    %rax,-0x18(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdfc(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdf8(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    1286 <main+0x146>
movsbl -0xd(%rbp),%eax
cmp    $0x48,%eax
je     124c <main+0x10c>
movsbl -0xd(%rbp),%eax
cmp    $0x68,%eax
jne    1281 <main+0x141>
lea    0xe19(%rip),%rax
mov    %rax,-0x18(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd98(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd94(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    1286 <main+0x146>
mov    -0x18(%rbp),%rsi
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdd8(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    12b4 <main+0x174>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdf3(%rip),%rdi
call   1030 <system@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xede(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xece(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeeb(%rip),%rdi
lea    0x3(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %al,0x3(%rsp)
movss  0x4(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    11da <main+0x9a>
lea    -0x48(%rax),%ecx
cmp    $0x25,%cl
ja     11da <main+0x9a>
movzbl %cl,%ecx
movabs $0x2100000021,%rdx
bt     %rcx,%rdx
jae    11da <main+0x9a>
and    $0xdf,%al
cvtss2sd %xmm0,%xmm0
cmp    $0x4d,%al
jne    11ea <main+0xaa>
mulsd  0xe47(%rip),%xmm0
addsd  0xe47(%rip),%xmm0
lea    0xe8d(%rip),%rsi
jmp    1201 <main+0xc1>
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1217 <main+0xd7>
mulsd  0xe0e(%rip),%xmm0
addsd  0xe0e(%rip),%xmm0
lea    0xe6b(%rip),%rsi
cvtsd2ss %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe62(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe90(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Qual a sua altura? \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [43 x i8] c"Digite 'M' para mulher ou 'H' para homem: \00"
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [7 x i8] c"Mulher\00"
@.str.5 = [6 x i8] c"Homem\00"
@.str.6 = [42 x i8] c"[%s] O seu peso ideal deve ser: %.3f kg.\0A\00"
@.str.7 = [18 x i8] c"\0ADados invalidos!\00"
@.str.8 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca i8
%5 = alloca i8*
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%10 = call signext i8 (...) @getchar()
store i8 %10, i8* %4
%11 = load float, float* %2
%12 = fcmp ogt float %11, 0.000000e+00
br i1 %12, label %13, label %61
13: ; preds = %0
%14 = load i8, i8* %4
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 77
br i1 %16, label %29, label %17
17: ; preds = %13
%18 = load i8, i8* %4
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 109
br i1 %20, label %29, label %21
21: ; preds = %17
%22 = load i8, i8* %4
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 72
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = load i8, i8* %4
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 104
br i1 %28, label %29, label %61
29: ; preds = %25, %21, %17, %13
%30 = load i8, i8* %4
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 77
br i1 %32, label %37, label %33
33: ; preds = %29
%34 = load i8, i8* %4
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 109
br i1 %36, label %37, label %42
37: ; preds = %33, %29
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8** %5
%38 = load float, float* %2
%39 = fpext float %38 to double
%40 = call double @llvm.fmuladd.f64(double 6.210000e+01, double %39, double -4.470000e+01)
%41 = fptrunc double %40 to float
store float %41, float* %3
br label %56
42: ; preds = %33
%43 = load i8, i8* %4
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 72
br i1 %45, label %50, label %46
46: ; preds = %42
%47 = load i8, i8* %4
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 104
br i1 %49, label %50, label %55
50: ; preds = %46, %42
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8** %5
%51 = load float, float* %2
%52 = fpext float %51 to double
%53 = call double @llvm.fmuladd.f64(double 7.270000e+01, double %52, double -5.800000e+01)
%54 = fptrunc double %53 to float
store float %54, float* %3
br label %55
55: ; preds = %50, %46
br label %56
56: ; preds = %55, %37
%57 = load i8*, i8** %5
%58 = load float, float* %3
%59 = fpext float %58 to double
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0), i8* %57, double %59)
br label %63
61: ; preds = %25, %0
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
br label %63
63: ; preds = %61, %56
%64 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%65 = load i32, i32* %1
ret i32 %65
}

LLVM IR (-O2):
@.str = [20 x i8] c"Qual a sua altura? \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [43 x i8] c"Digite 'M' para mulher ou 'H' para homem: \00"
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [7 x i8] c"Mulher\00"
@.str.5 = [6 x i8] c"Homem\00"
@.str.6 = [42 x i8] c"[%s] O seu peso ideal deve ser: %.3f kg.\0A\00"
@.str.7 = [18 x i8] c"\0ADados invalidos!\00"
@.str.8 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca float
%2 = alloca i8
%3 = bitcast float* %1 to i8*
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%8 = call signext i8 (...) @getchar()
store i8 %8, i8* %2
%9 = load float, float* %1
%10 = fcmp ogt float %9, 0.000000e+00
br i1 %10, label %11, label %28
11: ; preds = %0
%12 = and i8 %8, -33
switch i8 %8, label %28 [
i8 109, label %13
i8 104, label %13
i8 77, label %13
i8 72, label %13
]
13: ; preds = %11, %11, %11, %11
%14 = icmp eq i8 %12, 77
br i1 %14, label %15, label %18
15: ; preds = %13
%16 = fpext float %9 to double
%17 = call double @llvm.fmuladd.f64(double %16, double 6.210000e+01, double -4.470000e+01)
br label %22
18: ; preds = %13
%19 = icmp eq i8 %12, 72
%20 = fpext float %9 to double
%21 = call double @llvm.fmuladd.f64(double %20, double 7.270000e+01, double -5.800000e+01)
br label %22
22: ; preds = %18, %15
%23 = phi double [ %17, %15 ], [ %21, %18 ]
%24 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), %15 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), %18 ]
%25 = fptrunc double %23 to float
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0), i8* %24, double %26)
br label %30
28: ; preds = %11, %0
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
br label %30
30: ; preds = %28, %22
%31 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}