#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 Getop(char *);
double atof(char *);
int /*<<< orphan*/ clearStack();
int /*<<< orphan*/ duplicate();
double fmod(double, double);
double pop();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(double);
int /*<<< orphan*/ showTop();
int /*<<< orphan*/ swapItems();
int main() {
  int type;
  double op2;
  char s[100];
  int flag = 1;
  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) {
        push(pop() / op2);
      } else {
        printf("\nError: division by zero!");
      }
      break;
    case '%':
      op2 = pop();
      if (op2) {
        push(fmod(pop(), op2));
      } else {
        printf("\nError: division by zero!");
      }
      break;
    case '?':
      showTop();
      break;
    case '#':
      duplicate();
      break;
    case '~':
      swapItems();
      break;
    case '!':
      clearStack();
      break;
    default:
      printf("\nError: unknown command %s.\n", s);
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x84(%rbp)
lea    -0x80(%rbp),%rdi
call   1050 <Getop@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e19(%rip),%rcx
cmp    (%rcx),%eax
je     1424 <main+0x284>
mov    -0x8(%rbp),%eax
mov    %eax,-0x88(%rbp)
test   %eax,%eax
je     12a1 <main+0x101>
jmp    11ed <main+0x4d>
mov    -0x88(%rbp),%eax
sub    $0x21,%eax
je     1401 <main+0x261>
jmp    1201 <main+0x61>
mov    -0x88(%rbp),%eax
sub    $0x23,%eax
je     13e9 <main+0x249>
jmp    1215 <main+0x75>
mov    -0x88(%rbp),%eax
sub    $0x25,%eax
je     1386 <main+0x1e6>
jmp    1229 <main+0x89>
mov    -0x88(%rbp),%eax
sub    $0x2a,%eax
je     12e3 <main+0x143>
jmp    123d <main+0x9d>
mov    -0x88(%rbp),%eax
sub    $0x2b,%eax
je     12b4 <main+0x114>
jmp    1251 <main+0xb1>
mov    -0x88(%rbp),%eax
sub    $0x2d,%eax
je     1312 <main+0x172>
jmp    1265 <main+0xc5>
mov    -0x88(%rbp),%eax
sub    $0x2f,%eax
je     1334 <main+0x194>
jmp    1279 <main+0xd9>
mov    -0x88(%rbp),%eax
sub    $0x3f,%eax
je     13dd <main+0x23d>
jmp    128d <main+0xed>
mov    -0x88(%rbp),%eax
sub    $0x7e,%eax
je     13f5 <main+0x255>
jmp    140d <main+0x26d>
lea    -0x80(%rbp),%rdi
call   1040 <atof@plt>
call   10a0 <push@plt>
jmp    141f <main+0x27f>
mov    $0x0,%al
call   1080 <pop@plt>
movsd  %xmm0,-0x90(%rbp)
ff
mov    $0x0,%al
call   1080 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0x90(%rbp),%xmm0
ff
addsd  %xmm1,%xmm0
call   10a0 <push@plt>
jmp    141f <main+0x27f>
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
mulsd  %xmm1,%xmm0
call   10a0 <push@plt>
jmp    141f <main+0x27f>
mov    $0x0,%al
call   1080 <pop@plt>
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1080 <pop@plt>
subsd  -0x10(%rbp),%xmm0
call   10a0 <push@plt>
jmp    141f <main+0x27f>
mov    $0x0,%al
call   1080 <pop@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    135d <main+0x1bd>
jp     135d <main+0x1bd>
jmp    1373 <main+0x1d3>
mov    $0x0,%al
call   1080 <pop@plt>
divsd  -0x10(%rbp),%xmm0
call   10a0 <push@plt>
jmp    1381 <main+0x1e1>
lea    0xc86(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    141f <main+0x27f>
mov    $0x0,%al
call   1080 <pop@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    13af <main+0x20f>
jp     13af <main+0x20f>
jmp    13ca <main+0x22a>
mov    $0x0,%al
call   1080 <pop@plt>
movsd  -0x10(%rbp),%xmm1
call   1070 <fmod@plt>
call   10a0 <push@plt>
jmp    13d8 <main+0x238>
lea    0xc2f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    141f <main+0x27f>
mov    $0x0,%al
call   1030 <showTop@plt>
jmp    141f <main+0x27f>
mov    $0x0,%al
call   10b0 <duplicate@plt>
jmp    141f <main+0x27f>
mov    $0x0,%al
call   1090 <swapItems@plt>
jmp    141f <main+0x27f>
mov    $0x0,%al
call   10c0 <clearStack@plt>
jmp    141f <main+0x27f>
lea    -0x80(%rbp),%rsi
lea    0xc02(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    11bc <main+0x1c>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x80,%rsp
lea    0x10(%rsp),%rdi
call   1050 <Getop@plt>
mov    0x2e27(%rip),%r12
cmp    (%r12),%eax
jne    11da <main+0x3a>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0x10(%rsp),%r13
lea    0xf3c(%rip),%r14
lea    0xe1b(%rip),%rbx
lea    0xf14(%rip),%r15
jmp    121e <main+0x7e>
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rdi
call   1050 <Getop@plt>
cmp    (%r12),%eax
je     11c7 <main+0x27>
cmp    $0x3f,%eax
ja     123d <main+0x9d>
mov    %eax,%eax
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
mov    %r13,%rdi
call   1040 <atof@plt>
call   10a0 <push@plt>
jmp    1210 <main+0x70>
cmp    $0x7e,%eax
jne    11f6 <main+0x56>
xor    %eax,%eax
call   1090 <swapItems@plt>
jmp    1210 <main+0x70>
xor    %eax,%eax
call   10c0 <clearStack@plt>
jmp    1210 <main+0x70>
xor    %eax,%eax
call   10b0 <duplicate@plt>
jmp    1210 <main+0x70>
xor    %eax,%eax
call   1080 <pop@plt>
ucomisd 0xd94(%rip),%xmm0
jne    1274 <main+0xd4>
jnp    133e <main+0x19e>
xor    %eax,%eax
movsd  %xmm0,0x8(%rsp)
call   1080 <pop@plt>
movsd  0x8(%rsp),%xmm1
call   1070 <fmod@plt>
call   10a0 <push@plt>
jmp    1210 <main+0x70>
xor    %eax,%eax
call   1080 <pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1080 <pop@plt>
mulsd  0x8(%rsp),%xmm0
call   10a0 <push@plt>
jmp    1210 <main+0x70>
xor    %eax,%eax
call   1080 <pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1080 <pop@plt>
addsd  0x8(%rsp),%xmm0
call   10a0 <push@plt>
jmp    1210 <main+0x70>
xor    %eax,%eax
call   1080 <pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1080 <pop@plt>
subsd  0x8(%rsp),%xmm0
call   10a0 <push@plt>
jmp    1210 <main+0x70>
xor    %eax,%eax
call   1080 <pop@plt>
ucomisd 0xcef(%rip),%xmm0
jne    1315 <main+0x175>
jnp    133e <main+0x19e>
xor    %eax,%eax
movsd  %xmm0,0x8(%rsp)
call   1080 <pop@plt>
divsd  0x8(%rsp),%xmm0
call   10a0 <push@plt>
jmp    1210 <main+0x70>
xor    %eax,%eax
call   1030 <showTop@plt>
jmp    1210 <main+0x70>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1210 <main+0x70>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [26 x i8] c"\0AError: division by zero!\00"
@.str.1 = [29 x i8] c"\0AError: unknown command %s.\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 1, i32* %5
br label %6
6: ; preds = %68, %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 %69
11: ; preds = %6
%12 = load i32, i32* %2
switch i32 %12, label %65 [
i32 0, label %13
i32 43, label %17
i32 42, label %22
i32 45, label %27
i32 47, label %33
i32 37, label %45
i32 63, label %57
i32 35, label %59
i32 126, label %61
i32 33, label %63
]
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 %68
17: ; preds = %11
%18 = call double (...) @pop()
%19 = call double (...) @pop()
%20 = fadd double %18, %19
%21 = call i32 @push(double %20)
br label %68
22: ; preds = %11
%23 = call double (...) @pop()
%24 = call double (...) @pop()
%25 = fmul double %23, %24
%26 = call i32 @push(double %25)
br label %68
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 %68
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 ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %44
44: ; preds = %42, %37
br label %68
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 ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %56
56: ; preds = %54, %49
br label %68
57: ; preds = %11
%58 = call i32 (...) @showTop()
br label %68
59: ; preds = %11
%60 = call i32 (...) @duplicate()
br label %68
61: ; preds = %11
%62 = call i32 (...) @swapItems()
br label %68
63: ; preds = %11
%64 = call i32 (...) @clearStack()
br label %68
65: ; preds = %11
%66 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %66)
br label %68
68: ; preds = %65, %63, %61, %59, %57, %56, %44, %27, %22, %17, %13
br label %6
69: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [26 x i8] c"\0AError: division by zero!\00"
@.str.1 = [29 x i8] c"\0AError: unknown command %s.\0A\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 %58, label %6
6: ; preds = %0, %54
%7 = phi i32 [ %55, %54 ], [ %3, %0 ]
switch i32 %7, label %52 [
i32 0, label %8
i32 43, label %11
i32 42, label %16
i32 45, label %21
i32 47, label %26
i32 37, label %35
i32 63, label %44
i32 35, label %46
i32 126, label %48
i32 33, label %50
]
8: ; preds = %6
%9 = call double @atof(i8* %2)
%10 = call i32 @push(double %9)
br label %54
11: ; preds = %6
%12 = call double (...) @pop()
%13 = call double (...) @pop()
%14 = fadd double %12, %13
%15 = call i32 @push(double %14)
br label %54
16: ; preds = %6
%17 = call double (...) @pop()
%18 = call double (...) @pop()
%19 = fmul double %17, %18
%20 = call i32 @push(double %19)
br label %54
21: ; preds = %6
%22 = call double (...) @pop()
%23 = call double (...) @pop()
%24 = fsub double %23, %22
%25 = call i32 @push(double %24)
br label %54
26: ; preds = %6
%27 = call double (...) @pop()
%28 = fcmp une double %27, 0.000000e+00
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = call double (...) @pop()
%31 = fdiv double %30, %27
%32 = call i32 @push(double %31)
br label %54
33: ; preds = %26
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %54
35: ; preds = %6
%36 = call double (...) @pop()
%37 = fcmp une double %36, 0.000000e+00
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = call double (...) @pop()
%40 = call double @fmod(double %39, double %36)
%41 = call i32 @push(double %40)
br label %54
42: ; preds = %35
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %54
44: ; preds = %6
%45 = call i32 (...) @showTop()
br label %54
46: ; preds = %6
%47 = call i32 (...) @duplicate()
br label %54
48: ; preds = %6
%49 = call i32 (...) @swapItems()
br label %54
50: ; preds = %6
%51 = call i32 (...) @clearStack()
br label %54
52: ; preds = %6
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %54
54: ; preds = %38, %42, %29, %33, %52, %50, %48, %46, %44, %21, %16, %11, %8
%55 = call i32 @Getop(i8* %2)
%56 = load i32, i32* @EOF
%57 = icmp eq i32 %55, %56
br i1 %57, label %58, label %6
58: ; preds = %54, %0
ret i32 0
}