#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 EXIT_SUCCESS;
double factorial(double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
double gcd(size_t, size_t);
double lcm(size_t, size_t);
double pow(double, double);
int scanf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(void) {
  double a, b, ans;
  int ret;
  char opt;
  while (true) {
    fprintf(stdout, "> ");
    if ((ret = scanf("%lf %lf %c", &a, &b, &opt)) <= 1) {
      scanf("%c", &opt);
      b = a;
      a = ans;
    }
    switch (opt) {
    case 'q':
      return EXIT_SUCCESS;
      break;
    case '+':
      ans = a + b;
      break;
    case '-':
      ans = a - b;
      break;
    case '/':
      if (b != 0) {
        ans = a / b;
      } else {
        fprintf(stderr, "We can not divide by zero\n");
        continue;
      }
      break;
    case '*':
      ans = a * b;
      break;
    case '^':
      ans = pow(a, b);
      break;
    case '%':
      ans = (size_t)a % (size_t)b;
      break;
    case '!':
      ans = factorial((ret == 0) ? a : b);
      break;
    case 'g':
      ans = gcd((size_t)a, (size_t)b);
      break;
    case 'l':
      ans = lcm((size_t)a, (size_t)b);
      break;
    default:
      fprintf(stderr, "Unknow operation\n");
      continue;
      break;
    }
    fprintf(stdout, "%lf\n", ans);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
lea    0xff5(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
lea    0xfea(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x25(%rbp),%rcx
mov    $0x0,%al
call   1060 <scanf@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x1,%eax
jg     11d2 <main+0x72>
lea    0xfcc(%rip),%rdi
lea    -0x25(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsbl -0x25(%rbp),%eax
add    $0xffffffdf,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x50,%eax
ja     1427 <main+0x2c7>
mov    -0x30(%rbp),%rax
lea    0xe3d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2dcd(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1443 <main+0x2e3>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1443 <main+0x2e3>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1250 <main+0xf0>
jp     1250 <main+0xf0>
jmp    1264 <main+0x104>
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1280 <main+0x120>
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
lea    0xf0e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    116f <main+0xf>
jmp    1443 <main+0x2e3>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1443 <main+0x2e3>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1070 <pow@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    1443 <main+0x2e3>
movsd  -0x10(%rbp),%xmm0
movsd  0xd41(%rip),%xmm2
movaps %xmm0,%xmm1
subsd  %xmm2,%xmm1
cvttsd2si %xmm1,%rcx
cvttsd2si %xmm0,%rax
mov    %rax,%rdx
sar    $0x3f,%rdx
and    %rdx,%rcx
or     %rcx,%rax
movsd  -0x18(%rbp),%xmm0
movaps %xmm0,%xmm1
subsd  %xmm2,%xmm1
cvttsd2si %xmm1,%rdx
cvttsd2si %xmm0,%rcx
mov    %rcx,%rsi
sar    $0x3f,%rsi
and    %rsi,%rdx
or     %rdx,%rcx
xor    %edx,%edx
div    %rcx
movq   %rdx,%xmm0
movaps 0xcff(%rip),%xmm1
punpckldq %xmm1,%xmm0
movapd 0xd03(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1443 <main+0x2e3>
cmpl   $0x0,-0x24(%rbp)
jne    134f <main+0x1ef>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1359 <main+0x1f9>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <factorial@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    1443 <main+0x2e3>
movsd  -0x10(%rbp),%xmm0
movsd  0xc86(%rip),%xmm2
movaps %xmm0,%xmm1
subsd  %xmm2,%xmm1
cvttsd2si %xmm1,%rax
cvttsd2si %xmm0,%rdi
mov    %rdi,%rcx
sar    $0x3f,%rcx
and    %rcx,%rax
or     %rax,%rdi
movsd  -0x18(%rbp),%xmm0
movaps %xmm0,%xmm1
subsd  %xmm2,%xmm1
cvttsd2si %xmm1,%rax
cvttsd2si %xmm0,%rsi
mov    %rsi,%rcx
sar    $0x3f,%rcx
and    %rcx,%rax
or     %rax,%rsi
call   1080 <gcd@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    1443 <main+0x2e3>
movsd  -0x10(%rbp),%xmm0
movsd  0xc29(%rip),%xmm2
movaps %xmm0,%xmm1
subsd  %xmm2,%xmm1
cvttsd2si %xmm1,%rax
cvttsd2si %xmm0,%rdi
mov    %rdi,%rcx
sar    $0x3f,%rcx
and    %rcx,%rax
or     %rax,%rdi
movsd  -0x18(%rbp),%xmm0
movaps %xmm0,%xmm1
subsd  %xmm2,%xmm1
cvttsd2si %xmm1,%rax
cvttsd2si %xmm0,%rsi
mov    %rsi,%rcx
sar    $0x3f,%rcx
and    %rcx,%rax
or     %rax,%rsi
call   1040 <lcm@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    1443 <main+0x2e3>
mov    0x2bb2(%rip),%rax
mov    (%rax),%edi
lea    0xd66(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    116f <main+0xf>
mov    0x2b8e(%rip),%rax
mov    (%rax),%edi
movsd  -0x20(%rbp),%xmm0
lea    0xd57(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
jmp    116f <main+0xf>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    0x2e63(%rip),%r14
lea    0x18(%rsp),%r13
lea    0xf(%rsp),%rbx
lea    0x1017(%rip),%r15
lea    0xea3(%rip),%r12
jmp    11a0 <main+0x40>
nop
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r14),%edi
lea    0xfca(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xfbf(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %eax,%ebp
cmp    $0x1,%eax
jg     11fa <main+0x9a>
lea    0xfa7(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
movapd 0x20(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsbl 0xf(%rsp),%eax
add    $0xffffffdf,%eax
mov    %r15,%rsi
cmp    $0x50,%eax
ja     1190 <main+0x30>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
mov    %r15,%rsi
jmp    *%rax
movsd  0x18(%rsp),%xmm1
ucomisd 0xde4(%rip),%xmm1
lea    0xf57(%rip),%rsi
jne    1233 <main+0xd3>
jnp    1190 <main+0x30>
movsd  0x10(%rsp),%xmm0
divsd  %xmm1,%xmm0
jmp    13d2 <main+0x272>
test   %ebp,%ebp
mov    %r13,%rax
lea    0x10(%rsp),%rcx
cmove  %rcx,%rax
movsd  (%rax),%xmm0
call   1030 <factorial@plt>
jmp    13d2 <main+0x272>
movsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%rcx
movsd  0xd8f(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdx
mov    %rcx,%rax
sar    $0x3f,%rax
and    %rdx,%rax
or     %rcx,%rax
movsd  0x18(%rsp),%xmm0
cvttsd2si %xmm0,%rdx
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rsi
mov    %rdx,%rcx
sar    $0x3f,%rcx
and    %rsi,%rcx
or     %rdx,%rcx
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
je     13ad <main+0x24d>
xor    %edx,%edx
div    %rcx
jmp    13b1 <main+0x251>
movsd  0x10(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
jmp    13d2 <main+0x272>
movsd  0x10(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
jmp    13d2 <main+0x272>
movsd  0x10(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
jmp    13d2 <main+0x272>
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
call   1070 <pow@plt>
jmp    13d2 <main+0x272>
movsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%rax
movsd  0xce2(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rcx
mov    %rax,%rdi
sar    $0x3f,%rdi
movsd  0x18(%rsp),%xmm0
cvttsd2si %xmm0,%rdx
and    %rcx,%rdi
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rcx
or     %rax,%rdi
mov    %rdx,%rsi
sar    $0x3f,%rsi
and    %rcx,%rsi
or     %rdx,%rsi
call   1080 <gcd@plt>
jmp    13d2 <main+0x272>
movsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%rax
movsd  0xc91(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rcx
mov    %rax,%rdi
sar    $0x3f,%rdi
movsd  0x18(%rsp),%xmm0
cvttsd2si %xmm0,%rdx
and    %rcx,%rdi
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rcx
or     %rax,%rdi
mov    %rdx,%rsi
sar    $0x3f,%rsi
and    %rcx,%rsi
or     %rdx,%rsi
call   1040 <lcm@plt>
jmp    13d2 <main+0x272>
xor    %edx,%edx
div    %ecx
movq   %rdx,%xmm1
punpckldq 0xc52(%rip),%xmm1
subpd  0xc5a(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
mov    (%r14),%edi
lea    0xdd3(%rip),%rsi
movapd %xmm0,0x20(%rsp)
mov    $0x1,%al
call   1050 <fprintf@plt>
jmp    11a0 <main+0x40>
mov    0x2bdb(%rip),%rax
mov    (%rax),%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [3 x i8] c"> \00"
@.str.1 = [11 x i8] c"%lf %lf %c\00"
@.str.2 = [3 x i8] c"%c\00"
@EXIT_SUCCESS = global i32 0
@stderr = global i32 0
@.str.3 = [27 x i8] c"We can not divide by zero\0A\00"
@.str.4 = [18 x i8] c"Unknow operation\0A\00"
@.str.5 = [5 x i8] c"%lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca i8
store i32 0, i32* %1
br label %7
7: ; preds = %0, %36, %77, %80
%8 = load i32, i32* @stdout
%9 = call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), double* %2, double* %3, i8* %6)
store i32 %10, i32* %5
%11 = icmp sle i32 %10, 1
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%14 = load double, double* %2
store double %14, double* %3
%15 = load double, double* %4
store double %15, double* %2
br label %16
16: ; preds = %12, %7
%17 = load i8, i8* %6
%18 = sext i8 %17 to i32
switch i32 %18, label %77 [
i32 113, label %19
i32 43, label %21
i32 45, label %25
i32 47, label %29
i32 42, label %40
i32 94, label %44
i32 37, label %48
i32 33, label %55
i32 103, label %65
i32 108, label %71
]
19: ; preds = %16
%20 = load i32, i32* @EXIT_SUCCESS
ret i32 %20
21: ; preds = %16
%22 = load double, double* %2
%23 = load double, double* %3
%24 = fadd double %22, %23
store double %24, double* %4
br label %80
25: ; preds = %16
%26 = load double, double* %2
%27 = load double, double* %3
%28 = fsub double %26, %27
store double %28, double* %4
br label %80
29: ; preds = %16
%30 = load double, double* %3
%31 = fcmp une double %30, 0.000000e+00
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = load double, double* %2
%34 = load double, double* %3
%35 = fdiv double %33, %34
store double %35, double* %4
br label %39
36: ; preds = %29
%37 = load i32, i32* @stderr
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %7
39: ; preds = %32
br label %80
40: ; preds = %16
%41 = load double, double* %2
%42 = load double, double* %3
%43 = fmul double %41, %42
store double %43, double* %4
br label %80
44: ; preds = %16
%45 = load double, double* %2
%46 = load double, double* %3
%47 = call double @pow(double %45, double %46)
store double %47, double* %4
br label %80
48: ; preds = %16
%49 = load double, double* %2
%50 = fptoui double %49 to i64
%51 = load double, double* %3
%52 = fptoui double %51 to i64
%53 = urem i64 %50, %52
%54 = uitofp i64 %53 to double
store double %54, double* %4
br label %80
55: ; preds = %16
%56 = load i32, i32* %5
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %55
%59 = load double, double* %2
br label %62
60: ; preds = %55
%61 = load double, double* %3
br label %62
62: ; preds = %60, %58
%63 = phi double [ %59, %58 ], [ %61, %60 ]
%64 = call double @factorial(double %63)
store double %64, double* %4
br label %80
65: ; preds = %16
%66 = load double, double* %2
%67 = fptoui double %66 to i64
%68 = load double, double* %3
%69 = fptoui double %68 to i64
%70 = call double @gcd(i64 %67, i64 %69)
store double %70, double* %4
br label %80
71: ; preds = %16
%72 = load double, double* %2
%73 = fptoui double %72 to i64
%74 = load double, double* %3
%75 = fptoui double %74 to i64
%76 = call double @lcm(i64 %73, i64 %75)
store double %76, double* %4
br label %80
77: ; preds = %16
%78 = load i32, i32* @stderr
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %7
80: ; preds = %71, %65, %62, %48, %44, %40, %39, %25, %21
%81 = load i32, i32* @stdout
%82 = load double, double* %4
%83 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), double %82)
br label %7
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [3 x i8] c"> \00"
@.str.1 = [11 x i8] c"%lf %lf %c\00"
@.str.2 = [3 x i8] c"%c\00"
@EXIT_SUCCESS = global i32 0
@stderr = global i32 0
@.str.3 = [27 x i8] c"We can not divide by zero\0A\00"
@.str.4 = [18 x i8] c"Unknow operation\0A\00"
@.str.5 = [5 x i8] c"%lf\0A\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*
br label %6
6: ; preds = %72, %0
%7 = phi double [ %73, %72 ], [ undef, %0 ]
br label %8
8: ; preds = %35, %6
%9 = load i32, i32* @stdout
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), double* %1, double* %2, i8* %3)
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%15 = load double, double* %1
store double %15, double* %2
store double %7, double* %1
br label %16
16: ; preds = %13, %8
%17 = load i8, i8* %3
%18 = sext i8 %17 to i32
switch i32 %18, label %35 [
i32 113, label %19
i32 43, label %21
i32 45, label %25
i32 47, label %29
i32 42, label %39
i32 94, label %43
i32 37, label %47
i32 33, label %54
i32 103, label %60
i32 108, label %66
]
19: ; preds = %16
%20 = load i32, i32* @EXIT_SUCCESS
ret i32 %20
21: ; preds = %16
%22 = load double, double* %1
%23 = load double, double* %2
%24 = fadd double %22, %23
br label %72
25: ; preds = %16
%26 = load double, double* %1
%27 = load double, double* %2
%28 = fsub double %26, %27
br label %72
29: ; preds = %16
%30 = load double, double* %2
%31 = fcmp une double %30, 0.000000e+00
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load double, double* %1
%34 = fdiv double %33, %30
br label %72
35: ; preds = %29, %16
%36 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), %16 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), %29 ]
%37 = load i32, i32* @stderr
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* %36)
br label %8
39: ; preds = %16
%40 = load double, double* %1
%41 = load double, double* %2
%42 = fmul double %40, %41
br label %72
43: ; preds = %16
%44 = load double, double* %1
%45 = load double, double* %2
%46 = call double @pow(double %44, double %45)
br label %72
47: ; preds = %16
%48 = load double, double* %1
%49 = fptoui double %48 to i64
%50 = load double, double* %2
%51 = fptoui double %50 to i64
%52 = urem i64 %49, %51
%53 = uitofp i64 %52 to double
br label %72
54: ; preds = %16
%55 = icmp eq i32 %11, 0
%56 = load double, double* %1
%57 = load double, double* %2
%58 = select i1 %55, double %56, double %57
%59 = call double @factorial(double %58)
br label %72
60: ; preds = %16
%61 = load double, double* %1
%62 = fptoui double %61 to i64
%63 = load double, double* %2
%64 = fptoui double %63 to i64
%65 = call double @gcd(i64 %62, i64 %64)
br label %72
66: ; preds = %16
%67 = load double, double* %1
%68 = fptoui double %67 to i64
%69 = load double, double* %2
%70 = fptoui double %69 to i64
%71 = call double @lcm(i64 %68, i64 %70)
br label %72
72: ; preds = %66, %60, %54, %47, %43, %39, %32, %25, %21
%73 = phi double [ %71, %66 ], [ %65, %60 ], [ %59, %54 ], [ %53, %47 ], [ %46, %43 ], [ %42, %39 ], [ %34, %32 ], [ %28, %25 ], [ %24, %21 ]
%74 = load i32, i32* @stdout
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), double %73)
br label %6
}