#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() {
  double a, b;
  char c;
  printf("Enter the operation you want (+ - * / ): \n");
  scanf("%c", &c);
  printf("Enter two numbers: \n");
  scanf("%lf %lf", &a, &b);
  switch (c) {
  case '+':
    printf("%lf", a + b);
    break;
  case '-':
    printf("%lf", a - b);
    break;
  case '*':
    printf("%lf", a * b);
    break;
  case '/':
    printf("%lf", a / b);
    break;
  default:
    printf("You didn't enter a valid operation\n");
    break;
  }
  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,-0x29(%rbp)
call   1030 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xef9(%rip),%rdi
lea    -0x19(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x29(%rbp),%al
lea    0xee9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xeef(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <scanf@plt>
movsbl -0x19(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x5,%eax
ja     1217 <main+0xf7>
mov    -0x28(%rbp),%rax
lea    0xe66(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
lea    0xeab(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1225 <main+0x105>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
lea    0xe8e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1225 <main+0x105>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
lea    0xe71(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1225 <main+0x105>
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
lea    0xe54(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1225 <main+0x105>
lea    0xe45(%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    0xee8(%rip),%rdi
call   1030 <puts@plt>
lea    0xed1(%rip),%rdi
lea    0x7(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xef3(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb5(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
movsbl 0x7(%rsp),%eax
add    $0xffffffd6,%eax
cmp    $0x5,%eax
ja     11b0 <main+0x80>
lea    0xe75(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  0x10(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
jmp    11d8 <main+0xa8>
movsd  0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
jmp    11d8 <main+0xa8>
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
jmp    11e6 <main+0xb6>
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
jmp    11d8 <main+0xa8>
movsd  0x10(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
lea    0xe40(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"Enter the operation you want (+ - * / ): \0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [21 x i8] c"Enter two numbers: \0A\00"
@.str.3 = [8 x i8] c"%lf %lf\00"
@.str.4 = [4 x i8] c"%lf\00"
@.str.5 = [36 x i8] c"You didn't enter a valid operation\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i8
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 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* %4)
%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 ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double* %2, double* %3)
%9 = load i8, i8* %4
%10 = sext i8 %9 to i32
switch i32 %10, label %31 [
i32 43, label %11
i32 45, label %16
i32 42, label %21
i32 47, label %26
]
11: ; preds = %0
%12 = load double, double* %2
%13 = load double, double* %3
%14 = fadd double %12, %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double %14)
br label %33
16: ; preds = %0
%17 = load double, double* %2
%18 = load double, double* %3
%19 = fsub double %17, %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double %19)
br label %33
21: ; preds = %0
%22 = load double, double* %2
%23 = load double, double* %3
%24 = fmul double %22, %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double %24)
br label %33
26: ; preds = %0
%27 = load double, double* %2
%28 = load double, double* %3
%29 = fdiv double %27, %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double %29)
br label %33
31: ; preds = %0
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
br label %33
33: ; preds = %31, %26, %21, %16, %11
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%c\00"
@.str.3 = [8 x i8] c"%lf %lf\00"
@.str.4 = [4 x i8] c"%lf\00"
@str = [42 x i8] c"Enter the operation you want (+ - * / ): \00"
@str.6 = [20 x i8] c"Enter two numbers: \00"
@str.7 = [35 x i8] c"You didn't enter a valid operation\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca i8
%4 = bitcast double* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 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* %3)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.6, 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* %1, double* %2)
%10 = load i8, i8* %3
%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* %1
%14 = load double, double* %2
%15 = fadd double %13, %14
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double %15)
br label %34
17: ; preds = %0
%18 = load double, double* %1
%19 = load double, double* %2
%20 = fsub double %18, %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double %20)
br label %34
22: ; preds = %0
%23 = load double, double* %1
%24 = load double, double* %2
%25 = fmul double %23, %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double %25)
br label %34
27: ; preds = %0
%28 = load double, double* %1
%29 = load double, double* %2
%30 = fdiv double %28, %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double %30)
br label %34
32: ; preds = %0
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.7, i64 0, i64 0))
br label %34
34: ; preds = %32, %27, %22, %17, %12
ret i32 0
}