#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 main() {
  double number1 = 1.0;
  double number2 = 2.0;
  char operation = '+';
  char answer = 0;
  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\aDivision by zero error!\n");
    else
      printf("= %lf\n", number1 / number2);
    break;
  case '%':
    if ((long)number2 == 0)
      printf("\n\n\aDivision by zero error!\n");
    else
      printf("= %ld\n", (long)number1 % (long)number2);
    break;
  default:
    printf("\n\n\aIllegal operation!\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movabs $0x3ff0000000000000,%rax
mov    %rax,-0x10(%rbp)
movabs $0x4000000000000000,%rax
mov    %rax,-0x18(%rbp)
movb   $0x2b,-0x19(%rbp)
movb   $0x0,-0x1a(%rbp)
movsbl -0x19(%rbp),%eax
add    $0xffffffdb,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0xa,%eax
ja     1256 <main+0x146>
mov    -0x28(%rbp),%rax
lea    0xe9c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
lea    0xeae(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1264 <main+0x154>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
lea    0xe91(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1264 <main+0x154>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
lea    0xe74(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1264 <main+0x154>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11ef <main+0xdf>
jp     11ef <main+0xdf>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1207 <main+0xf7>
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
lea    0xe2c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1264 <main+0x154>
cvttsd2si -0x18(%rbp),%rax
cmp    $0x0,%rax
jne    122f <main+0x11f>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1251 <main+0x141>
cvttsd2si -0x10(%rbp),%rax
cvttsd2si -0x18(%rbp),%rcx
cqto
idiv   %rcx
mov    %rdx,%rsi
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1264 <main+0x154>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xef0(%rip),%rdi
movsd  0xee0(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"= %lf\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double 3.000000e+00)
ret i32 0
}