#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() {
  char o;
  float num1, num2;
  printf("Select an operator either + or - or * or / \n");
  scanf("%c", &o);
  printf("Enter two operands: ");
  scanf("%f%f", &num1, &num2);
  switch (o) {
  case '+':
    printf("%.1f + %.1f = %.1f", num1, num2, num1 + num2);
    break;
  case '-':
    printf("%.1f - %.1f = %.1f", num1, num2, num1 - num2);
    break;
  case '*':
    printf("%.1f * %.1f = %.1f", num1, num2, num1 * num2);
    break;
  case '/':
    printf("%.1f / %.1f = %.1f", num1, num2, num1 / num2);
    break;
  default:
    printf("Error! operator is not correct");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xee2(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x19(%rbp)
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xefb(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x19(%rbp),%al
lea    0xeeb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xef1(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x5,%eax
ja     126f <main+0x14f>
mov    -0x18(%rbp),%rax
lea    0xe66(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0xc(%rbp),%xmm2
addss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe98(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    127d <main+0x15d>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0xc(%rbp),%xmm2
subss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe78(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    127d <main+0x15d>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0xc(%rbp),%xmm2
mulss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe58(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    127d <main+0x15d>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0xc(%rbp),%xmm2
divss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe38(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    127d <main+0x15d>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xf65(%rip),%rdi
call   1030 <puts@plt>
lea    0xed1(%rip),%rdi
lea    0xf(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec8(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
movsbl 0xf(%rsp),%eax
add    $0xffffffd6,%eax
cmp    $0x5,%eax
ja     11e0 <main+0xb0>
lea    0xe73(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  0x14(%rsp),%xmm2
cvtss2sd %xmm2,%xmm0
movss  0x10(%rsp),%xmm3
cvtss2sd %xmm3,%xmm1
mulss  %xmm3,%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xea2(%rip),%rdi
jmp    1238 <main+0x108>
movss  0x14(%rsp),%xmm2
cvtss2sd %xmm2,%xmm0
movss  0x10(%rsp),%xmm3
cvtss2sd %xmm3,%xmm1
addss  %xmm3,%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe57(%rip),%rdi
jmp    1238 <main+0x108>
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    123f <main+0x10f>
movss  0x14(%rsp),%xmm2
cvtss2sd %xmm2,%xmm0
movss  0x10(%rsp),%xmm3
cvtss2sd %xmm3,%xmm1
subss  %xmm3,%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe35(%rip),%rdi
jmp    1238 <main+0x108>
movss  0x14(%rsp),%xmm2
cvtss2sd %xmm2,%xmm0
movss  0x10(%rsp),%xmm3
cvtss2sd %xmm3,%xmm1
divss  %xmm3,%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe36(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [45 x i8] c"Select an operator either + or - or * or / \0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [21 x i8] c"Enter two operands: \00"
@.str.3 = [5 x i8] c"%f%f\00"
@.str.4 = [19 x i8] c"%.1f + %.1f = %.1f\00"
@.str.5 = [19 x i8] c"%.1f - %.1f = %.1f\00"
@.str.6 = [19 x i8] c"%.1f * %.1f = %.1f\00"
@.str.7 = [19 x i8] c"%.1f / %.1f = %.1f\00"
@.str.8 = [31 x i8] c"Error! operator is not correct\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca float
%4 = alloca float
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 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), i8* %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 ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), float* %3, float* %4)
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
switch i32 %10, label %51 [
i32 43, label %11
i32 45, label %21
i32 42, label %31
i32 47, label %41
]
11: ; preds = %0
%12 = load float, float* %3
%13 = fpext float %12 to double
%14 = load float, float* %4
%15 = fpext float %14 to double
%16 = load float, float* %3
%17 = load float, float* %4
%18 = fadd float %16, %17
%19 = fpext float %18 to double
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), double %13, double %15, double %19)
br label %53
21: ; preds = %0
%22 = load float, float* %3
%23 = fpext float %22 to double
%24 = load float, float* %4
%25 = fpext float %24 to double
%26 = load float, float* %3
%27 = load float, float* %4
%28 = fsub float %26, %27
%29 = fpext float %28 to double
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), double %23, double %25, double %29)
br label %53
31: ; preds = %0
%32 = load float, float* %3
%33 = fpext float %32 to double
%34 = load float, float* %4
%35 = fpext float %34 to double
%36 = load float, float* %3
%37 = load float, float* %4
%38 = fmul float %36, %37
%39 = fpext float %38 to double
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), double %33, double %35, double %39)
br label %53
41: ; preds = %0
%42 = load float, float* %3
%43 = fpext float %42 to double
%44 = load float, float* %4
%45 = fpext float %44 to double
%46 = load float, float* %3
%47 = load float, float* %4
%48 = fdiv float %46, %47
%49 = fpext float %48 to double
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), double %43, double %45, double %49)
br label %53
51: ; preds = %0
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0))
br label %53
53: ; preds = %51, %41, %31, %21, %11
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [21 x i8] c"Enter two operands: \00"
@.str.3 = [5 x i8] c"%f%f\00"
@.str.4 = [19 x i8] c"%.1f + %.1f = %.1f\00"
@.str.5 = [19 x i8] c"%.1f - %.1f = %.1f\00"
@.str.6 = [19 x i8] c"%.1f * %.1f = %.1f\00"
@.str.7 = [19 x i8] c"%.1f / %.1f = %.1f\00"
@.str.8 = [31 x i8] c"Error! operator is not correct\00"
@str = [44 x i8] c"Select an operator either + or - or * or / \00"
define i32 @main() {
%1 = alloca i8
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %2 to i8*
%5 = bitcast float* %3 to i8*
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 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* %1)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), float* %2, float* %3)
%10 = load i8, i8* %1
%11 = sext i8 %10 to i32
switch i32 %11, label %44 [
i32 43, label %12
i32 45, label %20
i32 42, label %28
i32 47, label %36
]
12: ; preds = %0
%13 = load float, float* %2
%14 = fpext float %13 to double
%15 = load float, float* %3
%16 = fpext float %15 to double
%17 = fadd float %13, %15
%18 = fpext float %17 to double
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), double %14, double %16, double %18)
br label %46
20: ; preds = %0
%21 = load float, float* %2
%22 = fpext float %21 to double
%23 = load float, float* %3
%24 = fpext float %23 to double
%25 = fsub float %21, %23
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), double %22, double %24, double %26)
br label %46
28: ; preds = %0
%29 = load float, float* %2
%30 = fpext float %29 to double
%31 = load float, float* %3
%32 = fpext float %31 to double
%33 = fmul float %29, %31
%34 = fpext float %33 to double
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), double %30, double %32, double %34)
br label %46
36: ; preds = %0
%37 = load float, float* %2
%38 = fpext float %37 to double
%39 = load float, float* %3
%40 = fpext float %39 to double
%41 = fdiv float %37, %39
%42 = fpext float %41 to double
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), double %38, double %40, double %42)
br label %46
44: ; preds = %0
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0))
br label %46
46: ; preds = %44, %36, %28, %20, %12
ret i32 0
}