#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 EOF;
int atof(char *);
int cos(double);
int getop(char *);
int getvar(char);
double pop();
int pow(double, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(int);
int /*<<< orphan*/ setvar(double);
int sin(double);
int main(void) {
  int type, lasttype;
  double op1;
  char str[100];
  lasttype = '6';
  while ((type = getop(str)) != EOF) {
    switch (type) {
    case '0':
      push(atof(str));
      break;
    case '5':
      push(getvar(str[0] - 'a'));
      break;
    case '+':
      push(pop() + pop());
      break;
    case '*':
      push(pop() * pop());
      break;
    case '-':
      op1 = pop();
      push(pop() - op1);
      break;
    case '/':
      op1 = pop();
      if (op1 != 0) {
        push(pop() / op1);
      } else {
        printf("error: zero divisor\n");
      }
      break;
    case '%':
      op1 = pop();
      if (op1 != 0) {
        push(((int)pop()) % ((int)op1));
      } else {
        printf("error: zero divisor\n");
      }
      break;
    case '\n':
      op1 = pop();
      if (lasttype != '5') {
        setvar(op1);
      }
      printf("%lf\n", op1);
      break;
    case '3':
      op1 = pop();
      push(pow(pop(), op1));
      break;
    case '1':
      push(sin(pop()));
      break;
    case '2':
      push(cos(pop()));
      break;
    default:
      printf("action parse error\n");
      break;
    }
    lasttype = type;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x36,-0xc(%rbp)
lea    -0x80(%rbp),%rdi
call   1080 <getop@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e1c(%rip),%rcx
cmp    (%rcx),%eax
je     141a <main+0x27a>
mov    -0x8(%rbp),%eax
add    $0xfffffff6,%eax
mov    %eax,%ecx
mov    %rcx,-0x88(%rbp)
sub    $0x2b,%eax
ja     1401 <main+0x261>
mov    -0x88(%rbp),%rax
lea    0xe06(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x80(%rbp),%rdi
call   1040 <atof@plt>
mov    %eax,%edi
call   10b0 <push@plt>
jmp    140f <main+0x26f>
movsbl -0x80(%rbp),%eax
sub    $0x61,%eax
movsbl %al,%edi
call   1030 <getvar@plt>
mov    %eax,%edi
call   10b0 <push@plt>
jmp    140f <main+0x26f>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x90(%rbp)
ff
mov    $0x0,%al
call   1060 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0x90(%rbp),%xmm0
ff
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   10b0 <push@plt>
jmp    140f <main+0x26f>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x98(%rbp)
ff
mov    $0x0,%al
call   1060 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   10b0 <push@plt>
jmp    140f <main+0x26f>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1060 <pop@plt>
subsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   10b0 <push@plt>
jmp    140f <main+0x26f>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12e8 <main+0x148>
jp     12e8 <main+0x148>
jmp    1302 <main+0x162>
mov    $0x0,%al
call   1060 <pop@plt>
divsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   10b0 <push@plt>
jmp    1310 <main+0x170>
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    140f <main+0x26f>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    133e <main+0x19e>
jp     133e <main+0x19e>
jmp    135d <main+0x1bd>
mov    $0x0,%al
call   1060 <pop@plt>
cvttsd2si %xmm0,%eax
cvttsd2si -0x18(%rbp),%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   10b0 <push@plt>
jmp    136b <main+0x1cb>
lea    0xd4c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    140f <main+0x26f>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x35,-0xc(%rbp)
je     1390 <main+0x1f0>
movsd  -0x18(%rbp),%xmm0
call   1090 <setvar@plt>
movsd  -0x18(%rbp),%xmm0
lea    0xd29(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    140f <main+0x26f>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1060 <pop@plt>
movsd  -0x18(%rbp),%xmm1
call   10c0 <pow@plt>
mov    %eax,%edi
call   10b0 <push@plt>
jmp    140f <main+0x26f>
mov    $0x0,%al
call   1060 <pop@plt>
call   1070 <sin@plt>
mov    %eax,%edi
call   10b0 <push@plt>
jmp    140f <main+0x26f>
mov    $0x0,%al
call   1060 <pop@plt>
call   10a0 <cos@plt>
mov    %eax,%edi
call   10b0 <push@plt>
jmp    140f <main+0x26f>
lea    0xcc2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11b9 <main+0x19>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0x10(%rsp),%rdi
call   1090 <getop@plt>
mov    0x2e19(%rip),%r13
cmp    0x0(%r13),%eax
jne    11e6 <main+0x36>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x36,%ebp
lea    0x10(%rsp),%rbx
lea    0xe11(%rip),%r12
lea    0xeba(%rip),%r15
jmp    1225 <main+0x75>
mov    %rbx,%rdi
call   1050 <atof@plt>
nopl   0x0(%rax,%rax,1)
mov    %eax,%edi
call   10c0 <push@plt>
mov    %rbx,%rdi
call   1090 <getop@plt>
cmp    0x0(%r13),%eax
je     11d5 <main+0x25>
mov    %ebp,%r14d
mov    %eax,%ebp
lea    -0xa(%rbp),%eax
cmp    $0x2b,%eax
ja     126b <main+0xbb>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
xor    %eax,%eax
call   1070 <pop@plt>
cmp    $0x35,%r14d
je     125f <main+0xaf>
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
call   10a0 <setvar@plt>
movsd  0x8(%rsp),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
jmp    1217 <main+0x67>
lea    0xe5f(%rip),%rdi
jmp    139a <main+0x1ea>
xor    %eax,%eax
call   1070 <pop@plt>
ucomisd 0xd7a(%rip),%xmm0
jne    128e <main+0xde>
jnp    1393 <main+0x1e3>
xor    %eax,%eax
movsd  %xmm0,0x8(%rsp)
call   1070 <pop@plt>
cvttsd2si %xmm0,%eax
cvttsd2si 0x8(%rsp),%ecx
cltd
idiv   %ecx
mov    %edx,%edi
jmp    1212 <main+0x62>
xor    %eax,%eax
call   1070 <pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1070 <pop@plt>
mulsd  0x8(%rsp),%xmm0
jmp    1330 <main+0x180>
xor    %eax,%eax
call   1070 <pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1070 <pop@plt>
addsd  0x8(%rsp),%xmm0
jmp    1330 <main+0x180>
xor    %eax,%eax
call   1070 <pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1070 <pop@plt>
subsd  0x8(%rsp),%xmm0
jmp    1330 <main+0x180>
xor    %eax,%eax
call   1070 <pop@plt>
ucomisd 0xcee(%rip),%xmm0
jne    1316 <main+0x166>
jnp    1393 <main+0x1e3>
xor    %eax,%eax
movsd  %xmm0,0x8(%rsp)
call   1070 <pop@plt>
divsd  0x8(%rsp),%xmm0
nopl   0x0(%rax)
cvttsd2si %xmm0,%edi
jmp    1212 <main+0x62>
xor    %eax,%eax
call   1070 <pop@plt>
call   1080 <sin@plt>
jmp    1210 <main+0x60>
xor    %eax,%eax
call   1070 <pop@plt>
call   10b0 <cos@plt>
jmp    1210 <main+0x60>
xor    %eax,%eax
call   1070 <pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1070 <pop@plt>
movsd  0x8(%rsp),%xmm1
call   10d0 <pow@plt>
jmp    1210 <main+0x60>
movzbl 0x10(%rsp),%eax
add    $0x9f,%al
movsbl %al,%edi
call   1030 <getvar@plt>
jmp    1210 <main+0x60>
lea    0xd23(%rip),%rdi
call   1040 <puts@plt>
jmp    1217 <main+0x67>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [21 x i8] c"error: zero divisor\0A\00"
@.str.1 = [5 x i8] c"%lf\0A\00"
@.str.2 = [20 x i8] c"action parse error\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca [100 x i8]
store i32 0, i32* %1
store i32 54, i32* %3
br label %6
6: ; preds = %97, %0
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%8 = call i32 @getop(i8* %7)
store i32 %8, i32* %2
%9 = load i32, i32* @EOF
%10 = icmp ne i32 %8, %9
br i1 %10, label %11, label %99
11: ; preds = %6
%12 = load i32, i32* %2
switch i32 %12, label %95 [
i32 48, label %13
i32 53, label %17
i32 43, label %25
i32 42, label %31
i32 45, label %37
i32 47, label %44
i32 37, label %57
i32 10, label %71
i32 51, label %81
i32 49, label %87
i32 50, label %91
]
13: ; preds = %11
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%15 = call i32 @atof(i8* %14)
%16 = call i32 @push(i32 %15)
br label %97
17: ; preds = %11
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = sub nsw i32 %20, 97
%22 = trunc i32 %21 to i8
%23 = call i32 @getvar(i8 signext %22)
%24 = call i32 @push(i32 %23)
br label %97
25: ; preds = %11
%26 = call double (...) @pop()
%27 = call double (...) @pop()
%28 = fadd double %26, %27
%29 = fptosi double %28 to i32
%30 = call i32 @push(i32 %29)
br label %97
31: ; preds = %11
%32 = call double (...) @pop()
%33 = call double (...) @pop()
%34 = fmul double %32, %33
%35 = fptosi double %34 to i32
%36 = call i32 @push(i32 %35)
br label %97
37: ; preds = %11
%38 = call double (...) @pop()
store double %38, double* %4
%39 = call double (...) @pop()
%40 = load double, double* %4
%41 = fsub double %39, %40
%42 = fptosi double %41 to i32
%43 = call i32 @push(i32 %42)
br label %97
44: ; preds = %11
%45 = call double (...) @pop()
store double %45, double* %4
%46 = load double, double* %4
%47 = fcmp une double %46, 0.000000e+00
br i1 %47, label %48, label %54
48: ; preds = %44
%49 = call double (...) @pop()
%50 = load double, double* %4
%51 = fdiv double %49, %50
%52 = fptosi double %51 to i32
%53 = call i32 @push(i32 %52)
br label %56
54: ; preds = %44
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %56
56: ; preds = %54, %48
br label %97
57: ; preds = %11
%58 = call double (...) @pop()
store double %58, double* %4
%59 = load double, double* %4
%60 = fcmp une double %59, 0.000000e+00
br i1 %60, label %61, label %68
61: ; preds = %57
%62 = call double (...) @pop()
%63 = fptosi double %62 to i32
%64 = load double, double* %4
%65 = fptosi double %64 to i32
%66 = srem i32 %63, %65
%67 = call i32 @push(i32 %66)
br label %70
68: ; preds = %57
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %70
70: ; preds = %68, %61
br label %97
71: ; preds = %11
%72 = call double (...) @pop()
store double %72, double* %4
%73 = load i32, i32* %3
%74 = icmp ne i32 %73, 53
br i1 %74, label %75, label %78
75: ; preds = %71
%76 = load double, double* %4
%77 = call i32 @setvar(double %76)
br label %78
78: ; preds = %75, %71
%79 = load double, double* %4
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %79)
br label %97
81: ; preds = %11
%82 = call double (...) @pop()
store double %82, double* %4
%83 = call double (...) @pop()
%84 = load double, double* %4
%85 = call i32 @pow(double %83, double %84)
%86 = call i32 @push(i32 %85)
br label %97
87: ; preds = %11
%88 = call double (...) @pop()
%89 = call i32 @sin(double %88)
%90 = call i32 @push(i32 %89)
br label %97
91: ; preds = %11
%92 = call double (...) @pop()
%93 = call i32 @cos(double %92)
%94 = call i32 @push(i32 %93)
br label %97
95: ; preds = %11
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %97
97: ; preds = %95, %91, %87, %81, %78, %70, %56, %37, %31, %25, %17, %13
%98 = load i32, i32* %2
store i32 %98, i32* %3
br label %6
99: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str.1 = [5 x i8] c"%lf\0A\00"
@str.3 = [20 x i8] c"error: zero divisor\00"
@str.4 = [19 x i8] c"action parse error\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 @getop(i8* %2)
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %82, label %6
6: ; preds = %0, %78
%7 = phi i32 [ %79, %78 ], [ %3, %0 ]
%8 = phi i32 [ %7, %78 ], [ 54, %0 ]
switch i32 %7, label %76 [
i32 48, label %9
i32 53, label %12
i32 43, label %17
i32 42, label %23
i32 45, label %29
i32 47, label %35
i32 37, label %45
i32 10, label %56
i32 51, label %63
i32 49, label %68
i32 50, label %72
]
9: ; preds = %6
%10 = call i32 @atof(i8* %2)
%11 = call i32 @push(i32 %10)
br label %78
12: ; preds = %6
%13 = load i8, i8* %2
%14 = add i8 %13, -97
%15 = call i32 @getvar(i8 signext %14)
%16 = call i32 @push(i32 %15)
br label %78
17: ; preds = %6
%18 = call double (...) @pop()
%19 = call double (...) @pop()
%20 = fadd double %18, %19
%21 = fptosi double %20 to i32
%22 = call i32 @push(i32 %21)
br label %78
23: ; preds = %6
%24 = call double (...) @pop()
%25 = call double (...) @pop()
%26 = fmul double %24, %25
%27 = fptosi double %26 to i32
%28 = call i32 @push(i32 %27)
br label %78
29: ; preds = %6
%30 = call double (...) @pop()
%31 = call double (...) @pop()
%32 = fsub double %31, %30
%33 = fptosi double %32 to i32
%34 = call i32 @push(i32 %33)
br label %78
35: ; preds = %6
%36 = call double (...) @pop()
%37 = fcmp une double %36, 0.000000e+00
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = call double (...) @pop()
%40 = fdiv double %39, %36
%41 = fptosi double %40 to i32
%42 = call i32 @push(i32 %41)
br label %78
43: ; preds = %35
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.3, i64 0, i64 0))
br label %78
45: ; preds = %6
%46 = call double (...) @pop()
%47 = fcmp une double %46, 0.000000e+00
br i1 %47, label %48, label %54
48: ; preds = %45
%49 = call double (...) @pop()
%50 = fptosi double %49 to i32
%51 = fptosi double %46 to i32
%52 = srem i32 %50, %51
%53 = call i32 @push(i32 %52)
br label %78
54: ; preds = %45
%55 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.3, i64 0, i64 0))
br label %78
56: ; preds = %6
%57 = call double (...) @pop()
%58 = icmp eq i32 %8, 53
br i1 %58, label %61, label %59
59: ; preds = %56
%60 = call i32 @setvar(double %57)
br label %61
61: ; preds = %59, %56
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %57)
br label %78
63: ; preds = %6
%64 = call double (...) @pop()
%65 = call double (...) @pop()
%66 = call i32 @pow(double %65, double %64)
%67 = call i32 @push(i32 %66)
br label %78
68: ; preds = %6
%69 = call double (...) @pop()
%70 = call i32 @sin(double %69)
%71 = call i32 @push(i32 %70)
br label %78
72: ; preds = %6
%73 = call double (...) @pop()
%74 = call i32 @cos(double %73)
%75 = call i32 @push(i32 %74)
br label %78
76: ; preds = %6
%77 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.4, i64 0, i64 0))
br label %78
78: ; preds = %48, %54, %38, %43, %76, %72, %68, %63, %61, %29, %23, %17, %12, %9
%79 = call i32 @getop(i8* %2)
%80 = load i32, i32* @EOF
%81 = icmp eq i32 %79, %80
br i1 %81, label %82, label %6
82: ; preds = %78, %0
ret i32 0
}