#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 *, double *, char *, double *);
int main() {
  double number1 = 0.0;
  double number2 = 0.0;
  char operation = 0;
  printf("\nEnter the calculaton\n");
  scanf("%lf%c%lf", &number1, &operation, &number2);
  switch (operation) {
  case '+':
    printf("=%lf\n", number1 + number2);
    break;
  case '-':
    printf("=%lf\n", number1 - number2);
    break;
  case '*':
    printf("=%lf\n", number1 * number2);
    break;
  case '/':
    if (number2 == 0) {
      printf("\n\n\aDavision by zero error!\n");
    } else {
      printf("=%lf\n", number1 / number2);
    }
    break;
  case '%':
    if ((long)number2 == 0) {
      printf("\n\n\aDavision by zero error!\n");
    } else {
      printf("=%ld\n", (long)number1 % (long)number2);
    }
    break;
  default:
    printf("Invalid input detected");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movb   $0x0,-0x19(%rbp)
lea    0xee2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeeb(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x19(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1040 <scanf@plt>
movsbl -0x19(%rbp),%eax
add    $0xffffffdb,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0xa,%eax
ja     127c <main+0x15c>
mov    -0x28(%rbp),%rax
lea    0xe76(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
lea    0xea8(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    128a <main+0x16a>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
lea    0xe8b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    128a <main+0x16a>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
lea    0xe6e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    128a <main+0x16a>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1215 <main+0xf5>
jp     1215 <main+0xf5>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122d <main+0x10d>
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
lea    0xe26(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    128a <main+0x16a>
cvttsd2si -0x18(%rbp),%rax
cmp    $0x0,%rax
jne    1255 <main+0x135>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1277 <main+0x157>
cvttsd2si -0x10(%rbp),%rax
cvttsd2si -0x18(%rbp),%rcx
cqto
idiv   %rcx
mov    %rdx,%rsi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128a <main+0x16a>
lea    0xdf1(%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
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
movb   $0x0,0x7(%rsp)
lea    0xf06(%rip),%rdi
call   1030 <puts@plt>
lea    0xece(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x7(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1050 <scanf@plt>
movsbl 0x7(%rsp),%eax
add    $0xffffffdb,%eax
cmp    $0xa,%eax
ja     11b9 <main+0x89>
lea    0xe7a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cvttsd2si 0x8(%rsp),%rcx
test   %rcx,%rcx
je     1205 <main+0xd5>
cvttsd2si 0x10(%rsp),%rax
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
je     1232 <main+0x102>
cqto
idiv   %rcx
jmp    1236 <main+0x106>
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    122b <main+0xfb>
movsd  0x10(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
jmp    121d <main+0xed>
movsd  0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
jmp    121d <main+0xed>
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
jmp    121d <main+0xed>
movsd  0x8(%rsp),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1213 <main+0xe3>
jp     1213 <main+0xe3>
lea    0xe62(%rip),%rdi
call   1030 <puts@plt>
jmp    122b <main+0xfb>
movsd  0x10(%rsp),%xmm0
divsd  %xmm1,%xmm0
lea    0xe11(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
xor    %edx,%edx
div    %ecx
lea    0xdfe(%rip),%rdi
mov    %rdx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    122b <main+0xfb>

LLVM IR (-O0):
@.str = [23 x i8] c"\0AEnter the calculaton\0A\00"
@.str.1 = [9 x i8] c"%lf%c%lf\00"
@.str.2 = [6 x i8] c"=%lf\0A\00"
@.str.3 = [28 x i8] c"\0A\0A\07Davision by zero error!\0A\00"
@.str.4 = [6 x i8] c"=%ld\0A\00"
@.str.5 = [23 x i8] c"Invalid input detected\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i8
store i32 0, i32* %1
store double 0.000000e+00, double* %2
store double 0.000000e+00, double* %3
store i8 0, i8* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), double* %2, i8* %4, double* %3)
%7 = load i8, i8* %4
%8 = sext i8 %7 to i32
switch i32 %8, label %49 [
i32 43, label %9
i32 45, label %14
i32 42, label %19
i32 47, label %24
i32 37, label %35
]
9: ; preds = %0
%10 = load double, double* %2
%11 = load double, double* %3
%12 = fadd double %10, %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %12)
br label %51
14: ; preds = %0
%15 = load double, double* %2
%16 = load double, double* %3
%17 = fsub double %15, %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %17)
br label %51
19: ; preds = %0
%20 = load double, double* %2
%21 = load double, double* %3
%22 = fmul double %20, %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %22)
br label %51
24: ; preds = %0
%25 = load double, double* %3
%26 = fcmp oeq double %25, 0.000000e+00
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %34
29: ; preds = %24
%30 = load double, double* %2
%31 = load double, double* %3
%32 = fdiv double %30, %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %32)
br label %34
34: ; preds = %29, %27
br label %51
35: ; preds = %0
%36 = load double, double* %3
%37 = fptosi double %36 to i64
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %48
41: ; preds = %35
%42 = load double, double* %2
%43 = fptosi double %42 to i64
%44 = load double, double* %3
%45 = fptosi double %44 to i64
%46 = srem i64 %43, %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i64 %46)
br label %48
48: ; preds = %41, %39
br label %51
49: ; preds = %0
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
br label %51
51: ; preds = %49, %48, %34, %19, %14, %9
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"%lf%c%lf\00"
@.str.2 = [6 x i8] c"=%lf\0A\00"
@.str.4 = [6 x i8] c"=%ld\0A\00"
@.str.5 = [23 x i8] c"Invalid input detected\00"
@str = [22 x i8] c"\0AEnter the calculaton\00"
@str.7 = [27 x i8] c"\0A\0A\07Davision by zero error!\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca i8
%4 = bitcast double* %1 to i8*
store double 0.000000e+00, double* %1
%5 = bitcast double* %2 to i8*
store double 0.000000e+00, double* %2
store i8 0, i8* %3
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), double* %1, i8* %3, double* %2)
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
switch i32 %9, label %45 [
i32 43, label %10
i32 45, label %15
i32 42, label %20
i32 47, label %25
i32 37, label %34
]
10: ; preds = %0
%11 = load double, double* %1
%12 = load double, double* %2
%13 = fadd double %11, %12
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %13)
br label %47
15: ; preds = %0
%16 = load double, double* %1
%17 = load double, double* %2
%18 = fsub double %16, %17
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %18)
br label %47
20: ; preds = %0
%21 = load double, double* %1
%22 = load double, double* %2
%23 = fmul double %21, %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %23)
br label %47
25: ; preds = %0
%26 = load double, double* %2
%27 = fcmp oeq double %26, 0.000000e+00
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.7, i64 0, i64 0))
br label %47
30: ; preds = %25
%31 = load double, double* %1
%32 = fdiv double %31, %26
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %32)
br label %47
34: ; preds = %0
%35 = load double, double* %2
%36 = fptosi double %35 to i64
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.7, i64 0, i64 0))
br label %47
40: ; preds = %34
%41 = load double, double* %1
%42 = fptosi double %41 to i64
%43 = srem i64 %42, %36
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i64 %43)
br label %47
45: ; preds = %0
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
br label %47
47: ; preds = %38, %40, %28, %30, %45, %20, %15, %10
ret i32 0
}