#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 operacao;
  float num1, num2;
  printf("Digite um operação Matemática \n 1- Soma \n 2- Subtração \n 3- "
         "Divisão \n 4- Multiplicação \n Operação:_");
  scanf("%d", &operacao);
  printf("Digite o 1o numero: ");
  scanf("%f", &num1);
  printf("Digite o 2o numero: ");
  scanf("%f", &num2);
  switch (operacao) {
  case 1:
    printf(" + : %.2f", num1 + num2);
    break;
  case 2:
    printf(" - : %.2f", num1 - num2);
    break;
  case 3:
    if (num2 != 0) {
      printf(" / : %.2f", num1 / num2);
    } else {
      printf("Divisao por zero não existe!");
    }
    break;
  case 4:
    printf(" * : %.2f", num1 * num2);
    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    0xeda(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x19(%rbp)
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xf34(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x19(%rbp),%al
lea    0xf24(%rip),%rdi
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xf2a(%rip),%rdi
mov    %rdi,-0x28(%rbp)
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x19(%rbp),%al
lea    0xf16(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x19(%rbp),%al
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     1274 <main+0x154>
mov    -0x18(%rbp),%rax
lea    0xe48(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xed8(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1282 <main+0x162>
movss  -0xc(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xec1(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1282 <main+0x162>
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    121f <main+0xff>
jp     121f <main+0xff>
jmp    1240 <main+0x120>
movss  -0xc(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe8e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    124e <main+0x12e>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1282 <main+0x162>
movss  -0xc(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe82(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1282 <main+0x162>
lea    0xe79(%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    0xee4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf44(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xf34(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf3b(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xf28(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     11bc <main+0x9c>
lea    0xe66(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  0x8(%rsp),%xmm0
addss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xef4(%rip),%rdi
jmp    121f <main+0xff>
lea    0xf31(%rip),%rdi
jmp    122f <main+0x10f>
movss  0x8(%rsp),%xmm0
subss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xedc(%rip),%rdi
jmp    121f <main+0xff>
movss  0x4(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11ee <main+0xce>
jnp    1228 <main+0x108>
movss  0x8(%rsp),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xebc(%rip),%rdi
jmp    121f <main+0xff>
movss  0x8(%rsp),%xmm0
mulss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xecb(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1236 <main+0x116>
lea    0xe9d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [110 x i8] c"Digite um opera\C3\A7\C3\A3o Matem\C3\A1tica \0A 1- Soma \0A 2- Subtra\C3\A7\C3\A3o \0A 3- Divis\C3\A3o \0A 4- Multiplica\C3\A7\C3\A3o \0A Opera\C3\A7\C3\A3o:_\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"Digite o 1o numero: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [21 x i8] c"Digite o 2o numero: \00"
@.str.5 = [10 x i8] c" + : %.2f\00"
@.str.6 = [10 x i8] c" - : %.2f\00"
@.str.7 = [10 x i8] c" / : %.2f\00"
@.str.8 = [30 x i8] c"Divisao por zero n\C3\A3o existe!\00"
@.str.9 = [10 x i8] c" * : %.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 i32
%3 = alloca float
%4 = alloca float
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([110 x i8], [110 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
%11 = load i32, i32* %2
switch i32 %11, label %42 [
i32 1, label %12
i32 2, label %18
i32 3, label %24
i32 4, label %36
]
12: ; preds = %0
%13 = load float, float* %3
%14 = load float, float* %4
%15 = fadd float %13, %14
%16 = fpext float %15 to double
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), double %16)
br label %44
18: ; preds = %0
%19 = load float, float* %3
%20 = load float, float* %4
%21 = fsub float %19, %20
%22 = fpext float %21 to double
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), double %22)
br label %44
24: ; preds = %0
%25 = load float, float* %4
%26 = fcmp une float %25, 0.000000e+00
br i1 %26, label %27, label %33
27: ; preds = %24
%28 = load float, float* %3
%29 = load float, float* %4
%30 = fdiv float %28, %29
%31 = fpext float %30 to double
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), double %31)
br label %35
33: ; preds = %24
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
br label %35
35: ; preds = %33, %27
br label %44
36: ; preds = %0
%37 = load float, float* %3
%38 = load float, float* %4
%39 = fmul float %37, %38
%40 = fpext float %39 to double
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), double %40)
br label %44
42: ; preds = %0
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0))
br label %44
44: ; preds = %42, %36, %35, %18, %12
ret i32 0
}

LLVM IR (-O2):
@.str = [110 x i8] c"Digite um opera\C3\A7\C3\A3o Matem\C3\A1tica \0A 1- Soma \0A 2- Subtra\C3\A7\C3\A3o \0A 3- Divis\C3\A3o \0A 4- Multiplica\C3\A7\C3\A3o \0A Opera\C3\A7\C3\A3o:_\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"Digite o 1o numero: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [21 x i8] c"Digite o 2o numero: \00"
@.str.5 = [10 x i8] c" + : %.2f\00"
@.str.6 = [10 x i8] c" - : %.2f\00"
@.str.7 = [10 x i8] c" / : %.2f\00"
@.str.8 = [30 x i8] c"Divisao por zero n\C3\A3o existe!\00"
@.str.9 = [10 x i8] c" * : %.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 float
%3 = alloca float
%4 = bitcast i32* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([110 x i8], [110 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %2)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%13 = load i32, i32* %1
switch i32 %13, label %42 [
i32 1, label %14
i32 2, label %20
i32 3, label %26
i32 4, label %36
]
14: ; preds = %0
%15 = load float, float* %2
%16 = load float, float* %3
%17 = fadd float %15, %16
%18 = fpext float %17 to double
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), double %18)
br label %44
20: ; preds = %0
%21 = load float, float* %2
%22 = load float, float* %3
%23 = fsub float %21, %22
%24 = fpext float %23 to double
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), double %24)
br label %44
26: ; preds = %0
%27 = load float, float* %3
%28 = fcmp une float %27, 0.000000e+00
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = load float, float* %2
%31 = fdiv float %30, %27
%32 = fpext float %31 to double
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), double %32)
br label %44
34: ; preds = %26
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
br label %44
36: ; preds = %0
%37 = load float, float* %2
%38 = load float, float* %3
%39 = fmul float %37, %38
%40 = fpext float %39 to double
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), double %40)
br label %44
42: ; preds = %0
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0))
br label %44
44: ; preds = %29, %34, %42, %36, %20, %14
ret i32 0
}