#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;
double atof(char *);
double cos(double);
double expf(double);
double fmod(double, double);
int getop(char *);
double pop();
double powf(double, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(double);
double sin(double);
int main(void) {
  int type;
  double op2;
  char s[100];
  int adv = 0;
  while ((type = getop(s)) != EOF) {
    switch (type) {
    case '0':
      push(atof(s));
      break;
    case '+':
      push(pop() + pop());
      break;
    case '*':
      push(pop() * pop());
      break;
    case '-':
      op2 = pop();
      push(pop() - op2);
      break;
    case '/':
      op2 = pop();
      if (op2 != 0.0)
        push(pop() / op2);
      else
        printf("error: zero divisor\n");
      break;
    case '%':
      op2 = pop();
      if (op2 != 0.0)
        push(fmod(pop(), op2));
      else
        printf("error: zero divisor\n");
      break;
    case '^':
      op2 = pop();
      push(powf(pop(), op2));
      break;
    case 's':
      push(sin(pop()));
      break;
    case 'c':
      push(cos(pop()));
      break;
    case 'e':
      push(expf(pop()));
      break;
    case '\n':
      if (!adv)
        printf("\t%.8g\n", pop());
      adv = 0;
      break;
    case ' ':
      adv = 1;
      break;
    default:
      printf("error: unknown command %s\n", s);
      printf("use 'h' to get help\n");
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x84(%rbp)
lea    -0x80(%rbp),%rdi
call   10a0 <getop@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e19(%rip),%rcx
cmp    (%rcx),%eax
je     1410 <main+0x270>
mov    -0x8(%rbp),%eax
add    $0xfffffff6,%eax
mov    %eax,%ecx
mov    %rcx,-0x90(%rbp)
sub    $0x69,%eax
ja     13eb <main+0x24b>
mov    -0x90(%rbp),%rax
lea    0xe03(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x80(%rbp),%rdi
call   1030 <atof@plt>
call   10c0 <push@plt>
jmp    140b <main+0x26b>
mov    $0x0,%al
call   1080 <pop@plt>
movsd  %xmm0,-0x98(%rbp)
ff
mov    $0x0,%al
call   1080 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
addsd  %xmm1,%xmm0
call   10c0 <push@plt>
jmp    140b <main+0x26b>
mov    $0x0,%al
call   1080 <pop@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
mov    $0x0,%al
call   1080 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   10c0 <push@plt>
jmp    140b <main+0x26b>
mov    $0x0,%al
call   1080 <pop@plt>
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1080 <pop@plt>
subsd  -0x10(%rbp),%xmm0
call   10c0 <push@plt>
jmp    140b <main+0x26b>
mov    $0x0,%al
call   1080 <pop@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12c2 <main+0x122>
jp     12c2 <main+0x122>
jmp    12d8 <main+0x138>
mov    $0x0,%al
call   1080 <pop@plt>
divsd  -0x10(%rbp),%xmm0
call   10c0 <push@plt>
jmp    12e6 <main+0x146>
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    140b <main+0x26b>
mov    $0x0,%al
call   1080 <pop@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1314 <main+0x174>
jp     1314 <main+0x174>
jmp    132f <main+0x18f>
mov    $0x0,%al
call   1080 <pop@plt>
movsd  -0x10(%rbp),%xmm1
call   1060 <fmod@plt>
call   10c0 <push@plt>
jmp    133d <main+0x19d>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    140b <main+0x26b>
mov    $0x0,%al
call   1080 <pop@plt>
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1080 <pop@plt>
movsd  -0x10(%rbp),%xmm1
call   1040 <powf@plt>
call   10c0 <push@plt>
jmp    140b <main+0x26b>
mov    $0x0,%al
call   1080 <pop@plt>
call   1090 <sin@plt>
call   10c0 <push@plt>
jmp    140b <main+0x26b>
mov    $0x0,%al
call   1080 <pop@plt>
call   10b0 <cos@plt>
call   10c0 <push@plt>
jmp    140b <main+0x26b>
mov    $0x0,%al
call   1080 <pop@plt>
call   1070 <expf@plt>
call   10c0 <push@plt>
jmp    140b <main+0x26b>
cmpl   $0x0,-0x84(%rbp)
jne    13cd <main+0x22d>
mov    $0x0,%al
call   1080 <pop@plt>
lea    0xdf7(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movl   $0x0,-0x84(%rbp)
jmp    140b <main+0x26b>
movl   $0x1,-0x84(%rbp)
jmp    140b <main+0x26b>
lea    -0x80(%rbp),%rsi
lea    0xdce(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11bc <main+0x1c>
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   10b0 <getop@plt>
mov    0x2e19(%rip),%rbp
cmp    0x0(%rbp),%eax
jne    11e5 <main+0x35>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x10(%rsp),%rbx
lea    0xff5(%rip),%r15
lea    0xe10(%rip),%r12
xor    %r14d,%r14d
jmp    1228 <main+0x78>
xor    %eax,%eax
call   1090 <pop@plt>
call   1080 <expf@plt>
nopl   0x0(%rax)
call   10d0 <push@plt>
mov    %r14d,%r13d
mov    %rbx,%rdi
call   10b0 <getop@plt>
mov    %r13d,%r14d
cmp    0x0(%rbp),%eax
je     11d4 <main+0x24>
add    $0xfffffff6,%eax
cmp    $0x69,%eax
ja     1261 <main+0xb1>
mov    $0x1,%r13d
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
xor    %r13d,%r13d
test   %r14d,%r14d
jne    1218 <main+0x68>
xor    %r13d,%r13d
xor    %eax,%eax
call   1090 <pop@plt>
lea    0xf58(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
jmp    1218 <main+0x68>
lea    0xf4f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
jmp    1390 <main+0x1e0>
xor    %eax,%eax
call   1090 <pop@plt>
ucomisd 0xd77(%rip),%xmm0
jne    1291 <main+0xe1>
jnp    1389 <main+0x1d9>
xor    %eax,%eax
movsd  %xmm0,0x8(%rsp)
call   1090 <pop@plt>
movsd  0x8(%rsp),%xmm1
call   1070 <fmod@plt>
jmp    1210 <main+0x60>
xor    %eax,%eax
call   1090 <pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1090 <pop@plt>
mulsd  0x8(%rsp),%xmm0
jmp    1210 <main+0x60>
xor    %eax,%eax
call   1090 <pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1090 <pop@plt>
addsd  0x8(%rsp),%xmm0
jmp    1210 <main+0x60>
xor    %eax,%eax
call   1090 <pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1090 <pop@plt>
subsd  0x8(%rsp),%xmm0
jmp    1210 <main+0x60>
xor    %eax,%eax
call   1090 <pop@plt>
ucomisd 0xce6(%rip),%xmm0
jne    131e <main+0x16e>
jnp    1389 <main+0x1d9>
xor    %eax,%eax
movsd  %xmm0,0x8(%rsp)
call   1090 <pop@plt>
divsd  0x8(%rsp),%xmm0
jmp    1210 <main+0x60>
mov    %rbx,%rdi
call   1040 <atof@plt>
jmp    1210 <main+0x60>
xor    %eax,%eax
call   1090 <pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1090 <pop@plt>
movsd  0x8(%rsp),%xmm1
call   1050 <powf@plt>
jmp    1210 <main+0x60>
xor    %eax,%eax
call   1090 <pop@plt>
call   10c0 <cos@plt>
jmp    1210 <main+0x60>
xor    %eax,%eax
call   1090 <pop@plt>
call   10a0 <sin@plt>
jmp    1210 <main+0x60>
lea    0xe42(%rip),%rdi
call   1030 <puts@plt>
jmp    1215 <main+0x65>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [21 x i8] c"error: zero divisor\0A\00"
@.str.1 = [7 x i8] c"\09%.8g\0A\00"
@.str.2 = [27 x i8] c"error: unknown command %s\0A\00"
@.str.3 = [21 x i8] c"use 'h' to get help\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca [100 x i8]
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
br label %6
6: ; preds = %87, %0
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %4, 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 %88
11: ; preds = %6
%12 = load i32, i32* %2
switch i32 %12, label %83 [
i32 48, label %13
i32 43, label %17
i32 42, label %22
i32 45, label %27
i32 47, label %33
i32 37, label %45
i32 94, label %57
i32 115, label %63
i32 99, label %67
i32 101, label %71
i32 10, label %75
i32 32, label %82
]
13: ; preds = %11
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%15 = call double @atof(i8* %14)
%16 = call i32 @push(double %15)
br label %87
17: ; preds = %11
%18 = call double (...) @pop()
%19 = call double (...) @pop()
%20 = fadd double %18, %19
%21 = call i32 @push(double %20)
br label %87
22: ; preds = %11
%23 = call double (...) @pop()
%24 = call double (...) @pop()
%25 = fmul double %23, %24
%26 = call i32 @push(double %25)
br label %87
27: ; preds = %11
%28 = call double (...) @pop()
store double %28, double* %3
%29 = call double (...) @pop()
%30 = load double, double* %3
%31 = fsub double %29, %30
%32 = call i32 @push(double %31)
br label %87
33: ; preds = %11
%34 = call double (...) @pop()
store double %34, double* %3
%35 = load double, double* %3
%36 = fcmp une double %35, 0.000000e+00
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = call double (...) @pop()
%39 = load double, double* %3
%40 = fdiv double %38, %39
%41 = call i32 @push(double %40)
br label %44
42: ; preds = %33
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %44
44: ; preds = %42, %37
br label %87
45: ; preds = %11
%46 = call double (...) @pop()
store double %46, double* %3
%47 = load double, double* %3
%48 = fcmp une double %47, 0.000000e+00
br i1 %48, label %49, label %54
49: ; preds = %45
%50 = call double (...) @pop()
%51 = load double, double* %3
%52 = call double @fmod(double %50, double %51)
%53 = call i32 @push(double %52)
br label %56
54: ; preds = %45
%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, %49
br label %87
57: ; preds = %11
%58 = call double (...) @pop()
store double %58, double* %3
%59 = call double (...) @pop()
%60 = load double, double* %3
%61 = call double @powf(double %59, double %60)
%62 = call i32 @push(double %61)
br label %87
63: ; preds = %11
%64 = call double (...) @pop()
%65 = call double @sin(double %64)
%66 = call i32 @push(double %65)
br label %87
67: ; preds = %11
%68 = call double (...) @pop()
%69 = call double @cos(double %68)
%70 = call i32 @push(double %69)
br label %87
71: ; preds = %11
%72 = call double (...) @pop()
%73 = call double @expf(double %72)
%74 = call i32 @push(double %73)
br label %87
75: ; preds = %11
%76 = load i32, i32* %5
%77 = icmp ne i32 %76, 0
br i1 %77, label %81, label %78
78: ; preds = %75
%79 = call double (...) @pop()
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %79)
br label %81
81: ; preds = %78, %75
store i32 0, i32* %5
br label %87
82: ; preds = %11
store i32 1, i32* %5
br label %87
83: ; preds = %11
%84 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %84)
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %87
87: ; preds = %83, %82, %81, %71, %67, %63, %57, %56, %44, %27, %22, %17, %13
br label %6
88: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str.1 = [7 x i8] c"\09%.8g\0A\00"
@.str.2 = [27 x i8] c"error: unknown command %s\0A\00"
@str.4 = [20 x i8] c"error: zero divisor\00"
@str.5 = [20 x i8] c"use 'h' to get help\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 %75, label %6
6: ; preds = %0, %70
%7 = phi i32 [ %72, %70 ], [ %3, %0 ]
%8 = phi i32 [ %71, %70 ], [ 0, %0 ]
switch i32 %7, label %67 [
i32 48, label %9
i32 43, label %12
i32 42, label %17
i32 45, label %22
i32 47, label %27
i32 37, label %36
i32 94, label %45
i32 115, label %50
i32 99, label %54
i32 101, label %58
i32 10, label %62
i32 32, label %70
]
9: ; preds = %6
%10 = call double @atof(i8* %2)
%11 = call i32 @push(double %10)
br label %70
12: ; preds = %6
%13 = call double (...) @pop()
%14 = call double (...) @pop()
%15 = fadd double %13, %14
%16 = call i32 @push(double %15)
br label %70
17: ; preds = %6
%18 = call double (...) @pop()
%19 = call double (...) @pop()
%20 = fmul double %18, %19
%21 = call i32 @push(double %20)
br label %70
22: ; preds = %6
%23 = call double (...) @pop()
%24 = call double (...) @pop()
%25 = fsub double %24, %23
%26 = call i32 @push(double %25)
br label %70
27: ; preds = %6
%28 = call double (...) @pop()
%29 = fcmp une double %28, 0.000000e+00
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = call double (...) @pop()
%32 = fdiv double %31, %28
%33 = call i32 @push(double %32)
br label %70
34: ; preds = %27
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.4, i64 0, i64 0))
br label %70
36: ; preds = %6
%37 = call double (...) @pop()
%38 = fcmp une double %37, 0.000000e+00
br i1 %38, label %39, label %43
39: ; preds = %36
%40 = call double (...) @pop()
%41 = call double @fmod(double %40, double %37)
%42 = call i32 @push(double %41)
br label %70
43: ; preds = %36
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.4, i64 0, i64 0))
br label %70
45: ; preds = %6
%46 = call double (...) @pop()
%47 = call double (...) @pop()
%48 = call double @powf(double %47, double %46)
%49 = call i32 @push(double %48)
br label %70
50: ; preds = %6
%51 = call double (...) @pop()
%52 = call double @sin(double %51)
%53 = call i32 @push(double %52)
br label %70
54: ; preds = %6
%55 = call double (...) @pop()
%56 = call double @cos(double %55)
%57 = call i32 @push(double %56)
br label %70
58: ; preds = %6
%59 = call double (...) @pop()
%60 = call double @expf(double %59)
%61 = call i32 @push(double %60)
br label %70
62: ; preds = %6
%63 = icmp eq i32 %8, 0
br i1 %63, label %64, label %70
64: ; preds = %62
%65 = call double (...) @pop()
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %65)
br label %70
67: ; preds = %6
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%69 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.5, i64 0, i64 0))
br label %70
70: ; preds = %6, %62, %64, %39, %43, %30, %34, %67, %58, %54, %50, %45, %22, %17, %12, %9
%71 = phi i32 [ %8, %67 ], [ %8, %58 ], [ %8, %54 ], [ %8, %50 ], [ %8, %45 ], [ %8, %39 ], [ %8, %43 ], [ %8, %30 ], [ %8, %34 ], [ %8, %22 ], [ %8, %17 ], [ %8, %12 ], [ %8, %9 ], [ 0, %64 ], [ 0, %62 ], [ 1, %6 ]
%72 = call i32 @getop(i8* %2)
%73 = load i32, i32* @EOF
%74 = icmp eq i32 %72, %73
br i1 %74, label %75, label %6
75: ; preds = %70, %0
ret i32 0
}