#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() {
  char oper;
  double num1, num2;
  printf("Dwse arithmo praji arithmo\n");
  scanf("%lf %c %lf", &num1, &oper, &num2);
  switch (oper) {
  case '+':
    printf("apotelesma = %.2lf", num1 + num2);
    break;
  case '-':
    printf("apotelesma = %.2lf", num1 - num2);
    break;
  case '*':
    printf("apotelesma = %.2lf", num1 * num2);
    break;
  case '/':
    if (num2 != 0)
      printf("apotelesma = %.2lf", num1 / num2);
    else
      printf("Divide with zero is not allowed");
    break;
  default:
    printf("Wrong operator. Please try again");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xee2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef0(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x5(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x5,%eax
ja     1223 <main+0x103>
mov    -0x20(%rbp),%rax
lea    0xe8a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
lea    0xeaf(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1231 <main+0x111>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
lea    0xe92(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1231 <main+0x111>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
lea    0xe75(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1231 <main+0x111>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11f3 <main+0xd3>
jp     11f3 <main+0xd3>
jmp    1210 <main+0xf0>
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
lea    0xe3b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    121e <main+0xfe>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1231 <main+0x111>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xf3c(%rip),%rdi
call   1030 <puts@plt>
lea    0xed1(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x7(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1050 <scanf@plt>
movsbl 0x7(%rsp),%eax
add    $0xffffffd6,%eax
cmp    $0x5,%eax
ja     1194 <main+0x64>
lea    0xe91(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  0x10(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
jmp    11c7 <main+0x97>
movsd  0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
jmp    11c7 <main+0x97>
lea    0xebb(%rip),%rdi
jmp    11de <main+0xae>
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
jmp    11c7 <main+0x97>
movsd  0x8(%rsp),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    11bd <main+0x8d>
jnp    11d7 <main+0xa7>
movsd  0x10(%rsp),%xmm0
divsd  %xmm1,%xmm0
lea    0xe55(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    11e5 <main+0xb5>
lea    0xe58(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Dwse arithmo praji arithmo\0A\00"
@.str.1 = [11 x i8] c"%lf %c %lf\00"
@.str.2 = [19 x i8] c"apotelesma = %.2lf\00"
@.str.3 = [32 x i8] c"Divide with zero is not allowed\00"
@.str.4 = [33 x i8] c"Wrong operator. Please try again\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 ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), double* %3, i8* %2, double* %4)
%7 = load i8, i8* %2
%8 = sext i8 %7 to i32
switch i32 %8, label %35 [
i32 43, label %9
i32 45, label %14
i32 42, label %19
i32 47, label %24
]
9: ; preds = %0
%10 = load double, double* %3
%11 = load double, double* %4
%12 = fadd double %10, %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), double %12)
br label %37
14: ; preds = %0
%15 = load double, double* %3
%16 = load double, double* %4
%17 = fsub double %15, %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), double %17)
br label %37
19: ; preds = %0
%20 = load double, double* %3
%21 = load double, double* %4
%22 = fmul double %20, %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), double %22)
br label %37
24: ; preds = %0
%25 = load double, double* %4
%26 = fcmp une double %25, 0.000000e+00
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = load double, double* %3
%29 = load double, double* %4
%30 = fdiv double %28, %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), double %30)
br label %34
32: ; preds = %24
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %34
34: ; preds = %32, %27
br label %37
35: ; preds = %0
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
br label %37
37: ; preds = %35, %34, %19, %14, %9
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c"%lf %c %lf\00"
@.str.2 = [19 x i8] c"apotelesma = %.2lf\00"
@.str.3 = [32 x i8] c"Divide with zero is not allowed\00"
@.str.4 = [33 x i8] c"Wrong operator. Please try again\00"
@str = [27 x i8] c"Dwse arithmo praji arithmo\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 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), double* %2, i8* %1, double* %3)
%8 = load i8, i8* %1
%9 = sext i8 %8 to i32
switch i32 %9, label %34 [
i32 43, label %10
i32 45, label %15
i32 42, label %20
i32 47, label %25
]
10: ; preds = %0
%11 = load double, double* %2
%12 = load double, double* %3
%13 = fadd double %11, %12
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), double %13)
br label %36
15: ; preds = %0
%16 = load double, double* %2
%17 = load double, double* %3
%18 = fsub double %16, %17
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), double %18)
br label %36
20: ; preds = %0
%21 = load double, double* %2
%22 = load double, double* %3
%23 = fmul double %21, %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), double %23)
br label %36
25: ; preds = %0
%26 = load double, double* %3
%27 = fcmp une double %26, 0.000000e+00
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load double, double* %2
%30 = fdiv double %29, %26
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), double %30)
br label %36
32: ; preds = %25
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %36
34: ; preds = %0
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
br label %36
36: ; preds = %28, %32, %34, %20, %15, %10
ret i32 0
}