#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 *);
int getop(char *);
double pop();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(double);
int main() {
  int type;
  double op2, last_printed;
  char s[100];
  double vars[(unsigned char)('z' - 'a' + 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 != 0.0)
        push(pop() / op2);
      else
        printf("error: zero divisor\n");
      break;
    case -2:
      vars[(unsigned char)(s[1] - 'a')] = op2 = pop();
      push(op2);
      break;
    case 'a':
      push(s[0] == '_' ? last_printed : vars[(unsigned char)(s[0] - 'a')]);
      break;
    case '\n':
      printf("\t%.8g\n", last_printed = pop());
      break;
    default:
      printf("error: unknown command %s\n", s);
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x80(%rbp),%rdi
call   1060 <getop@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e73(%rip),%rcx
cmp    (%rcx),%eax
je     13b5 <main+0x265>
mov    -0x8(%rbp),%eax
mov    %eax,-0x154(%rbp)
sub    $0xfffffffe,%eax
je     1305 <main+0x1b5>
jmp    1194 <main+0x44>
mov    -0x154(%rbp),%eax
sub    $0xa,%eax
je     137f <main+0x22f>
jmp    11a8 <main+0x58>
mov    -0x154(%rbp),%eax
sub    $0x2a,%eax
je     1262 <main+0x112>
jmp    11bc <main+0x6c>
mov    -0x154(%rbp),%eax
sub    $0x2b,%eax
je     1233 <main+0xe3>
jmp    11d0 <main+0x80>
mov    -0x154(%rbp),%eax
sub    $0x2d,%eax
je     1291 <main+0x141>
jmp    11e4 <main+0x94>
mov    -0x154(%rbp),%eax
sub    $0x2f,%eax
je     12b3 <main+0x163>
jmp    11f8 <main+0xa8>
mov    -0x154(%rbp),%eax
sub    $0x30,%eax
je     1220 <main+0xd0>
jmp    120c <main+0xbc>
mov    -0x154(%rbp),%eax
sub    $0x61,%eax
je     1333 <main+0x1e3>
jmp    139e <main+0x24e>
lea    -0x80(%rbp),%rdi
call   1030 <atof@plt>
call   1070 <push@plt>
jmp    13b0 <main+0x260>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x160(%rbp)
ff
mov    $0x0,%al
call   1050 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0x160(%rbp),%xmm0
ff
addsd  %xmm1,%xmm0
call   1070 <push@plt>
jmp    13b0 <main+0x260>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x168(%rbp)
ff
mov    $0x0,%al
call   1050 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0x168(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1070 <push@plt>
jmp    13b0 <main+0x260>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1050 <pop@plt>
subsd  -0x10(%rbp),%xmm0
call   1070 <push@plt>
jmp    13b0 <main+0x260>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12dc <main+0x18c>
jp     12dc <main+0x18c>
jmp    12f2 <main+0x1a2>
mov    $0x0,%al
call   1050 <pop@plt>
divsd  -0x10(%rbp),%xmm0
call   1070 <push@plt>
jmp    1300 <main+0x1b0>
lea    0xd07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13b0 <main+0x260>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x10(%rbp)
movsbl -0x7f(%rbp),%eax
sub    $0x61,%eax
movzbl %al,%eax
movsd  %xmm0,-0x150(%rbp,%rax,8)
ff ff
movsd  -0x10(%rbp),%xmm0
call   1070 <push@plt>
jmp    13b0 <main+0x260>
movsbl -0x80(%rbp),%eax
cmp    $0x5f,%eax
jne    1352 <main+0x202>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x170(%rbp)
ff
jmp    136d <main+0x21d>
movsbl -0x80(%rbp),%eax
sub    $0x61,%eax
movzbl %al,%eax
movsd  -0x150(%rbp,%rax,8),%xmm0
ff ff
movsd  %xmm0,-0x170(%rbp)
ff
movsd  -0x170(%rbp),%xmm0
ff
call   1070 <push@plt>
jmp    13b0 <main+0x260>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x18(%rbp)
lea    0xc83(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    13b0 <main+0x260>
lea    -0x80(%rbp),%rsi
lea    0xc73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1162 <main+0x12>
xor    %eax,%eax
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x158,%rsp
lea    0x10(%rsp),%rdi
call   1070 <getop@plt>
mov    0x2e66(%rip),%r13
cmp    0x0(%r13),%eax
jne    119c <main+0x3c>
xor    %eax,%eax
add    $0x158,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x10(%rsp),%rbx
lea    0xf33(%rip),%r14
lea    0xe59(%rip),%rbp
lea    0xf1e(%rip),%r15
lea    0xf39(%rip),%r12
jmp    11de <main+0x7e>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1070 <getop@plt>
cmp    0x0(%r13),%eax
je     1188 <main+0x28>
lea    0x2(%rax),%ecx
cmp    $0x32,%ecx
ja     1211 <main+0xb1>
movslq 0x0(%rbp,%rcx,4),%rax
add    %rbp,%rax
jmp    *%rax
xor    %eax,%eax
call   1060 <pop@plt>
movzbl 0x11(%rsp),%eax
add    $0x9f,%al
movzbl %al,%eax
movsd  %xmm0,0x80(%rsp,%rax,8)
call   1080 <push@plt>
jmp    11d0 <main+0x70>
cmp    $0x61,%eax
jne    11bf <main+0x5f>
movzbl 0x10(%rsp),%eax
movsd  0x8(%rsp),%xmm0
cmp    $0x5f,%al
je     1233 <main+0xd3>
add    $0x9f,%al
movzbl %al,%eax
movsd  0x80(%rsp,%rax,8),%xmm0
call   1080 <push@plt>
jmp    11d0 <main+0x70>
xor    %eax,%eax
call   1060 <pop@plt>
mov    %r15,%rdi
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%al
call   1050 <printf@plt>
jmp    11d0 <main+0x70>
xor    %eax,%eax
call   1060 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <pop@plt>
mulsd  (%rsp),%xmm0
call   1080 <push@plt>
jmp    11d0 <main+0x70>
xor    %eax,%eax
call   1060 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <pop@plt>
addsd  (%rsp),%xmm0
call   1080 <push@plt>
jmp    11d0 <main+0x70>
xor    %eax,%eax
call   1060 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <pop@plt>
subsd  (%rsp),%xmm0
call   1080 <push@plt>
jmp    11d0 <main+0x70>
xor    %eax,%eax
call   1060 <pop@plt>
ucomisd 0xd35(%rip),%xmm0
jne    12cf <main+0x16f>
jnp    12fc <main+0x19c>
xor    %eax,%eax
movsd  %xmm0,(%rsp)
call   1060 <pop@plt>
divsd  (%rsp),%xmm0
call   1080 <push@plt>
jmp    11d0 <main+0x70>
mov    %rbx,%rdi
call   1040 <atof@plt>
call   1080 <push@plt>
jmp    11d0 <main+0x70>
mov    %r12,%rdi
call   1030 <puts@plt>
jmp    11d0 <main+0x70>

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