#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(int argc, char *argv[]) {
  double num1 = 0.0;
  double num2 = 0.0;
  char opera;
  printf("\nPlease input the calc:\n");
  scanf("%lf %c %lf", &num1, &opera, &num2);
  switch (opera) {
  case '+':
    printf("= %lf\n", num1 + num2);
    break;
  case '-':
    printf("= %lf\n", num1 - num2);
    break;
  case '*':
    printf("= %lf\n", num1 * num2);
    break;
  case '/':
    if (num2 == 0) {
      printf("\nDevision by zero error!!\n");
    } else {
      printf("= %lf\n", num1 - num2);
    }
    break;
  case '%':
    if ((long)num2 == 0) {
      printf("\nDevision by zero error!!\n");
    } else {
      printf("= %ld\n", (long)num1 % (long)num2);
    }
    break;
  default:
    printf("Invalid operation type!\n");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
lea    0xedf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeea(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x21(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1040 <scanf@plt>
movsbl -0x21(%rbp),%eax
add    $0xffffffdb,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0xa,%eax
ja     127f <main+0x15f>
mov    -0x30(%rbp),%rax
lea    0xe73(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
lea    0xea9(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    128d <main+0x16d>
movsd  -0x18(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
lea    0xe8c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    128d <main+0x16d>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
lea    0xe6f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    128d <main+0x16d>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1218 <main+0xf8>
jp     1218 <main+0xf8>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1230 <main+0x110>
movsd  -0x18(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
lea    0xe27(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    128d <main+0x16d>
cvttsd2si -0x20(%rbp),%rax
cmp    $0x0,%rax
jne    1258 <main+0x138>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127a <main+0x15a>
cvttsd2si -0x18(%rbp),%rax
cvttsd2si -0x20(%rbp),%rcx
cqto
idiv   %rcx
mov    %rdx,%rsi
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128d <main+0x16d>
lea    0xdf3(%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)
lea    0xef8(%rip),%rdi
call   1030 <puts@plt>
lea    0xed3(%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     11b0 <main+0x80>
lea    0xe7f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cvttsd2si 0x8(%rsp),%rcx
test   %rcx,%rcx
je     11f5 <main+0xc5>
cvttsd2si 0x10(%rsp),%rax
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
je     1222 <main+0xf2>
cqto
idiv   %rcx
jmp    1226 <main+0xf6>
lea    0xec0(%rip),%rdi
jmp    11fc <main+0xcc>
movsd  0x10(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
jmp    120d <main+0xdd>
movsd  0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
jmp    120d <main+0xdd>
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
jmp    120d <main+0xdd>
movsd  0x8(%rsp),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1203 <main+0xd3>
jp     1203 <main+0xd3>
lea    0xe61(%rip),%rdi
call   1030 <puts@plt>
jmp    121b <main+0xeb>
movsd  0x10(%rsp),%xmm0
subsd  %xmm1,%xmm0
lea    0xe23(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
xor    %edx,%edx
div    %ecx
lea    0xe11(%rip),%rdi
mov    %rdx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    121b <main+0xeb>

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

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