#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 op;
  double num1, num2;
  printf("Enter an operator (+, -, *,/): ");
  scanf("%c", &op);
  printf("Enter two numbers: ");
  scanf("%lf %lf", &num1, &num2);
  switch (op) {
  case '+':
    printf("The result of the operation %.1lf + %.1lf = %.1lf", num1, num2,
           num1 + num2);
    break;
  case '-':
    printf("The result of the operation %.1lf - %.1lf = %.1lf", num1, num2,
           num1 - num2);
    break;
  case '*':
    printf("The result of the operation %.1lf * %.1lf = %.1lf", num1, num2,
           num1 * num2);
    break;
  case '/':
    printf("The result of the operation %.1lf / %.1lf = %.1lf", num1, num2,
           num1 / num2);
    break;
  default:
    printf("Error! The entered operator is invalid");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xee2(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x21(%rbp)
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xeee(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x21(%rbp),%al
lea    0xede(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xee3(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x5,%eax
ja     123f <main+0x11f>
mov    -0x20(%rbp),%rax
lea    0xe66(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
addsd  -0x18(%rbp),%xmm2
lea    0xe99(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    124d <main+0x12d>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
lea    0xea4(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    124d <main+0x12d>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
mulsd  -0x18(%rbp),%xmm2
lea    0xeaf(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    124d <main+0x12d>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
divsd  -0x18(%rbp),%xmm2
lea    0xeba(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    124d <main+0x12d>
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xeed(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeff(%rip),%rdi
lea    0x7(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xeef(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef5(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
movsbl 0x7(%rsp),%eax
add    $0xffffffd6,%eax
cmp    $0x5,%eax
ja     11c2 <main+0xa2>
lea    0xe81(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movapd %xmm0,%xmm2
mulsd  %xmm1,%xmm2
lea    0xf18(%rip),%rdi
jmp    120a <main+0xea>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movapd %xmm0,%xmm2
addsd  %xmm1,%xmm2
lea    0xe97(%rip),%rdi
jmp    120a <main+0xea>
lea    0xf56(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1211 <main+0xf1>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
lea    0xe9c(%rip),%rdi
jmp    120a <main+0xea>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movapd %xmm0,%xmm2
divsd  %xmm1,%xmm2
lea    0xee3(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
@.str = [32 x i8] c"Enter an operator (+, -, *,/): \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [20 x i8] c"Enter two numbers: \00"
@.str.3 = [8 x i8] c"%lf %lf\00"
@.str.4 = [50 x i8] c"The result of the operation %.1lf + %.1lf = %.1lf\00"
@.str.5 = [50 x i8] c"The result of the operation %.1lf - %.1lf = %.1lf\00"
@.str.6 = [50 x i8] c"The result of the operation %.1lf * %.1lf = %.1lf\00"
@.str.7 = [50 x i8] c"The result of the operation %.1lf / %.1lf = %.1lf\00"
@.str.8 = [39 x i8] c"Error! The entered operator is invalid\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca double
%3 = alloca double
%4 = bitcast double* %2 to i8*
%5 = bitcast double* %3 to i8*
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 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 ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double* %2, double* %3)
%10 = load i8, i8* %1
%11 = sext i8 %10 to i32
switch i32 %11, label %32 [
i32 43, label %12
i32 45, label %17
i32 42, label %22
i32 47, label %27
]
12: ; preds = %0
%13 = load double, double* %2
%14 = load double, double* %3
%15 = fadd double %13, %14
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), double %13, double %14, double %15)
br label %34
17: ; preds = %0
%18 = load double, double* %2
%19 = load double, double* %3
%20 = fsub double %18, %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0), double %18, double %19, double %20)
br label %34
22: ; preds = %0
%23 = load double, double* %2
%24 = load double, double* %3
%25 = fmul double %23, %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), double %23, double %24, double %25)
br label %34
27: ; preds = %0
%28 = load double, double* %2
%29 = load double, double* %3
%30 = fdiv double %28, %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0), double %28, double %29, double %30)
br label %34
32: ; preds = %0
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0))
br label %34
34: ; preds = %32, %27, %22, %17, %12
ret i32 0
}