#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 */
double pow(float, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  char operacao;
  float num1, num2, num3;
  printf("Escolha a média que deseja calcular: \n a - Geométrica \n b - "
         "Ponderada \n c - Harmônica \n d - Aritmética \n Operação:_");
  scanf("%c", &operacao);
  printf("Digite o 1o numero inteiro positivo: ");
  scanf("%f", &num1);
  printf("Digite o 2o numero inteiro positivo: ");
  scanf("%f", &num2);
  printf("Digite o 3o numero inteiro positivo: ");
  scanf("%f", &num3);
  switch (operacao) {
  case 'a':
    printf("Média geométrica: %.2f\n", pow(num1 * num2 * num3, 1.0 / 3.0));
    break;
  case 'b':
    printf(" Média Ponderada: %.2f", (num1 + 2 * num2 + 3 * num3) / 6.0);
    break;
  case 'c':
    printf("Média harmônica: %.2f\n",
           1.0 / ((1.0 / num1) + (1.0 / num2) + (1.0 / num3)));
    break;
  case 'd':
    printf(" Média Aritmética: %.2f", (num1 + num2 + num3) / 3.0);
    break;
  default:
    printf("Operação inválida!");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeee(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x21(%rbp)
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xf54(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x21(%rbp),%al
lea    0xf44(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xf5b(%rip),%rdi
mov    %rdi,-0x30(%rbp)
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x21(%rbp),%al
lea    0xf47(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x21(%rbp),%al
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x21(%rbp),%al
lea    0xf4e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x21(%rbp),%al
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     1302 <main+0x1d2>
mov    -0x20(%rbp),%rax
lea    0xe3c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0xc(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movsd  0xe10(%rip),%xmm1
call   1050 <pow@plt>
lea    0xf12(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1310 <main+0x1e0>
movss  -0xc(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
addss  %xmm1,%xmm1
addss  %xmm0,%xmm1
movss  -0x14(%rbp),%xmm0
movss  0xde1(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdbd(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xee2(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1310 <main+0x1e0>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd8d(%rip),%xmm1
divsd  %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm2
movsd  0xd78(%rip),%xmm0
divsd  %xmm2,%xmm0
addsd  %xmm0,%xmm1
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm2
movsd  0xd5f(%rip),%xmm0
divsd  %xmm2,%xmm0
addsd  %xmm0,%xmm1
movsd  0xd4f(%rip),%xmm0
divsd  %xmm1,%xmm0
lea    0xe94(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1310 <main+0x1e0>
movss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd15(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe7b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1310 <main+0x1e0>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xf08(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf74(%rip),%rdi
lea    0x3(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xf64(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf7c(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xf69(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xf72(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
movsbl 0x3(%rsp),%eax
add    $0xffffff9f,%eax
cmp    $0x3,%eax
ja     11fc <main+0xcc>
lea    0xe6c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  0xc(%rsp),%xmm0
mulss  0x8(%rsp),%xmm0
mulss  0x4(%rsp),%xmm0
movsd  0xe2d(%rip),%xmm1
call   1050 <pow@plt>
lea    0xf3f(%rip),%rdi
jmp    12bf <main+0x18f>
lea    0xf98(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    12c6 <main+0x196>
movss  0x8(%rsp),%xmm0
addss  %xmm0,%xmm0
addss  0xc(%rsp),%xmm0
movss  0x4(%rsp),%xmm1
mulss  0xe03(%rip),%xmm1
addss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
divsd  0xdd0(%rip),%xmm0
lea    0xf09(%rip),%rdi
jmp    12bf <main+0x18f>
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xdad(%rip),%xmm0
movapd %xmm0,%xmm2
divsd  %xmm1,%xmm2
movss  0x4(%rsp),%xmm1
movss  0xc(%rsp),%xmm3
unpcklps %xmm1,%xmm3
cvtps2pd %xmm3,%xmm1
movapd 0xda3(%rip),%xmm3
divpd  %xmm1,%xmm3
addsd  %xmm3,%xmm2
unpckhpd %xmm3,%xmm3
addsd  %xmm2,%xmm3
divsd  %xmm3,%xmm0
lea    0xed0(%rip),%rdi
jmp    12bf <main+0x18f>
movss  0xc(%rsp),%xmm0
addss  0x8(%rsp),%xmm0
addss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  0xd48(%rip),%xmm0
lea    0xec2(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [122 x i8] c"Escolha a m\C3\A9dia que deseja calcular: \0A a - Geom\C3\A9trica \0A b - Ponderada \0A c - Harm\C3\B4nica \0A d - Aritm\C3\A9tica \0A Opera\C3\A7\C3\A3o:_\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [38 x i8] c"Digite o 1o numero inteiro positivo: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [38 x i8] c"Digite o 2o numero inteiro positivo: \00"
@.str.5 = [38 x i8] c"Digite o 3o numero inteiro positivo: \00"
@.str.6 = [26 x i8] c"M\C3\A9dia geom\C3\A9trica: %.2f\0A\00"
@.str.7 = [24 x i8] c" M\C3\A9dia Ponderada: %.2f\00"
@.str.8 = [25 x i8] c"M\C3\A9dia harm\C3\B4nica: %.2f\0A\00"
@.str.9 = [26 x i8] c" M\C3\A9dia Aritm\C3\A9tica: %.2f\00"
@.str.10 = [22 x i8] c"Opera\C3\A7\C3\A3o inv\C3\A1lida!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca float
%4 = alloca float
%5 = alloca float
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([122 x i8], [122 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), i8* %2)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 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), float* %3)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %5)
%14 = load i8, i8* %2
%15 = sext i8 %14 to i32
switch i32 %15, label %56 [
i32 97, label %16
i32 98, label %24
i32 99, label %33
i32 100, label %47
]
16: ; preds = %0
%17 = load float, float* %3
%18 = load float, float* %4
%19 = fmul float %17, %18
%20 = load float, float* %5
%21 = fmul float %19, %20
%22 = call double @pow(float %21, double 0x3FD5555555555555)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), double %22)
br label %58
24: ; preds = %0
%25 = load float, float* %3
%26 = load float, float* %4
%27 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %26, float %25)
%28 = load float, float* %5
%29 = call float @llvm.fmuladd.f32(float 3.000000e+00, float %28, float %27)
%30 = fpext float %29 to double
%31 = fdiv double %30, 6.000000e+00
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), double %31)
br label %58
33: ; preds = %0
%34 = load float, float* %3
%35 = fpext float %34 to double
%36 = fdiv double 1.000000e+00, %35
%37 = load float, float* %4
%38 = fpext float %37 to double
%39 = fdiv double 1.000000e+00, %38
%40 = fadd double %36, %39
%41 = load float, float* %5
%42 = fpext float %41 to double
%43 = fdiv double 1.000000e+00, %42
%44 = fadd double %40, %43
%45 = fdiv double 1.000000e+00, %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), double %45)
br label %58
47: ; preds = %0
%48 = load float, float* %3
%49 = load float, float* %4
%50 = fadd float %48, %49
%51 = load float, float* %5
%52 = fadd float %50, %51
%53 = fpext float %52 to double
%54 = fdiv double %53, 3.000000e+00
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), double %54)
br label %58
56: ; preds = %0
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0))
br label %58
58: ; preds = %56, %47, %33, %24, %16
ret i32 0
}

LLVM IR (-O2):
@.str = [122 x i8] c"Escolha a m\C3\A9dia que deseja calcular: \0A a - Geom\C3\A9trica \0A b - Ponderada \0A c - Harm\C3\B4nica \0A d - Aritm\C3\A9tica \0A Opera\C3\A7\C3\A3o:_\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [38 x i8] c"Digite o 1o numero inteiro positivo: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [38 x i8] c"Digite o 2o numero inteiro positivo: \00"
@.str.5 = [38 x i8] c"Digite o 3o numero inteiro positivo: \00"
@.str.6 = [26 x i8] c"M\C3\A9dia geom\C3\A9trica: %.2f\0A\00"
@.str.7 = [24 x i8] c" M\C3\A9dia Ponderada: %.2f\00"
@.str.8 = [25 x i8] c"M\C3\A9dia harm\C3\B4nica: %.2f\0A\00"
@.str.9 = [26 x i8] c" M\C3\A9dia Aritm\C3\A9tica: %.2f\00"
@.str.10 = [22 x i8] c"Opera\C3\A7\C3\A3o inv\C3\A1lida!\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = bitcast float* %4 to i8*
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([122 x i8], [122 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %2)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
%16 = load i8, i8* %1
%17 = sext i8 %16 to i32
switch i32 %17, label %60 [
i32 97, label %18
i32 98, label %26
i32 99, label %35
i32 100, label %51
]
18: ; preds = %0
%19 = load float, float* %2
%20 = load float, float* %3
%21 = fmul float %19, %20
%22 = load float, float* %4
%23 = fmul float %21, %22
%24 = call double @pow(float %23, double 0x3FD5555555555555)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), double %24)
br label %62
26: ; preds = %0
%27 = load float, float* %2
%28 = load float, float* %3
%29 = call float @llvm.fmuladd.f32(float %28, float 2.000000e+00, float %27)
%30 = load float, float* %4
%31 = call float @llvm.fmuladd.f32(float %30, float 3.000000e+00, float %29)
%32 = fpext float %31 to double
%33 = fdiv double %32, 6.000000e+00
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), double %33)
br label %62
35: ; preds = %0
%36 = load float, float* %2
%37 = load float, float* %3
%38 = fpext float %37 to double
%39 = fdiv double 1.000000e+00, %38
%40 = load float, float* %4
%41 = insertelement <2 x float> poison, float %36, i64 0
%42 = insertelement <2 x float> %41, float %40, i64 1
%43 = fpext <2 x float> %42 to <2 x double>
%44 = fdiv <2 x double> <double 1.000000e+00, double 1.000000e+00>, %43
%45 = extractelement <2 x double> %44, i64 0
%46 = fadd double %45, %39
%47 = extractelement <2 x double> %44, i64 1
%48 = fadd double %46, %47
%49 = fdiv double 1.000000e+00, %48
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), double %49)
br label %62
51: ; preds = %0
%52 = load float, float* %2
%53 = load float, float* %3
%54 = fadd float %52, %53
%55 = load float, float* %4
%56 = fadd float %54, %55
%57 = fpext float %56 to double
%58 = fdiv double %57, 3.000000e+00
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), double %58)
br label %62
60: ; preds = %0
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0))
br label %62
62: ; preds = %60, %51, %35, %26, %18
ret i32 0
}