#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);
main() {
  int i, type, var = 0;
  double op2, v;
  char s[100];
  double variable[26];
  for (i = 0; i < 26; i++)
    variable[i] = 0.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 '=':
      pop();
      if (var >= 'A' && var <= 'Z')
        variable[var - 'A'] = pop();
      else
        printf("error: no variable name\n");
      break;
    case '\n':
      v = pop();
      printf("\t%.8g\n", v);
      break;
    default:
      if (type >= 'A' && type <= 'Z')
        push(variable[type - 'A']);
      else if (type == 'v')
        push(v);
      else
        printf("error: unknow command %s \n", s);
      break;
    }
    var = type;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x180,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x1a,-0x8(%rbp)
jge    1198 <main+0x48>
movslq -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x160(%rbp,%rax,8)
ff ff
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1170 <main+0x20>
jmp    119d <main+0x4d>
lea    -0x90(%rbp),%rdi
call   1060 <getop@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e35(%rip),%rcx
cmp    (%rcx),%eax
je     13b3 <main+0x263>
mov    -0xc(%rbp),%eax
add    $0xfffffff6,%eax
mov    %eax,%ecx
mov    %rcx,-0x168(%rbp)
sub    $0x33,%eax
ja     1341 <main+0x1f1>
mov    -0x168(%rbp),%rax
lea    0xe1f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x90(%rbp),%rdi
call   1030 <atof@plt>
call   1070 <push@plt>
jmp    13a8 <main+0x258>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x170(%rbp)
ff
mov    $0x0,%al
call   1050 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0x170(%rbp),%xmm0
ff
addsd  %xmm1,%xmm0
call   1070 <push@plt>
jmp    13a8 <main+0x258>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x178(%rbp)
ff
mov    $0x0,%al
call   1050 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0x178(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1070 <push@plt>
jmp    13a8 <main+0x258>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1050 <pop@plt>
subsd  -0x18(%rbp),%xmm0
call   1070 <push@plt>
jmp    13a8 <main+0x258>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12a9 <main+0x159>
jp     12a9 <main+0x159>
jmp    12bf <main+0x16f>
mov    $0x0,%al
call   1050 <pop@plt>
divsd  -0x18(%rbp),%xmm0
call   1070 <push@plt>
jmp    12cd <main+0x17d>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13a8 <main+0x258>
mov    $0x0,%al
call   1050 <pop@plt>
cmpl   $0x41,-0x10(%rbp)
jl     130a <main+0x1ba>
cmpl   $0x5a,-0x10(%rbp)
jg     130a <main+0x1ba>
mov    $0x0,%al
call   1050 <pop@plt>
mov    -0x10(%rbp),%eax
sub    $0x41,%eax
cltq
movsd  %xmm0,-0x160(%rbp,%rax,8)
ff ff
jmp    1318 <main+0x1c8>
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13a8 <main+0x258>
mov    $0x0,%al
call   1050 <pop@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    0xdc9(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    13a8 <main+0x258>
cmpl   $0x41,-0xc(%rbp)
jl     1370 <main+0x220>
cmpl   $0x5a,-0xc(%rbp)
jg     1370 <main+0x220>
mov    -0xc(%rbp),%eax
sub    $0x41,%eax
cltq
movsd  -0x160(%rbp,%rax,8),%xmm0
ff ff
call   1070 <push@plt>
jmp    13a3 <main+0x253>
cmpl   $0x76,-0xc(%rbp)
jne    1389 <main+0x239>
movsd  -0x20(%rbp),%xmm0
call   1070 <push@plt>
jmp    139e <main+0x24e>
lea    -0x90(%rbp),%rsi
lea    0xd6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13a3 <main+0x253>
jmp    13a8 <main+0x258>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    119d <main+0x4d>
xor    %eax,%eax
add    $0x180,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x148,%rsp
xorpd  %xmm0,%xmm0
movapd %xmm0,0xd0(%rsp)
movapd %xmm0,0xc0(%rsp)
movapd %xmm0,0xb0(%rsp)
movapd %xmm0,0xa0(%rsp)
movapd %xmm0,0x90(%rsp)
movapd %xmm0,0x80(%rsp)
movapd %xmm0,0x70(%rsp)
movapd %xmm0,0x60(%rsp)
movapd %xmm0,0x50(%rsp)
movapd %xmm0,0x40(%rsp)
movapd %xmm0,0x30(%rsp)
movapd %xmm0,0x20(%rsp)
movapd %xmm0,0x10(%rsp)
lea    0xe0(%rsp),%rdi
call   1070 <getop@plt>
mov    0x2dff(%rip),%rbp
cmp    0x0(%rbp),%eax
jne    1202 <main+0xa2>
xor    %eax,%eax
add    $0x148,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe0(%rsp),%rbx
lea    0xdf7(%rip),%r14
lea    0xec0(%rip),%r15
xor    %r12d,%r12d
jmp    1252 <main+0xf2>
xor    %eax,%eax
call   1060 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <pop@plt>
mulsd  (%rsp),%xmm0
cs nopw 0x0(%rax,%rax,1)
nop
call   1080 <push@plt>
mov    %rbx,%rdi
call   1070 <getop@plt>
cmp    0x0(%rbp),%eax
je     11ee <main+0x8e>
mov    %r12d,%r13d
mov    %eax,%r12d
lea    -0xa(%r12),%eax
cmp    $0x33,%eax
ja     1284 <main+0x124>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
xor    %eax,%eax
call   1060 <pop@plt>
mov    %r15,%rdi
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%al
call   1050 <printf@plt>
jmp    1245 <main+0xe5>
lea    -0x41(%r12),%eax
cmp    $0x19,%eax
ja     132c <main+0x1cc>
mov    %eax,%eax
movsd  0x10(%rsp,%rax,8),%xmm0
jmp    1240 <main+0xe0>
mov    %rbx,%rdi
call   1040 <atof@plt>
jmp    1240 <main+0xe0>
xor    %eax,%eax
call   1060 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <pop@plt>
addsd  (%rsp),%xmm0
jmp    1240 <main+0xe0>
xor    %eax,%eax
call   1060 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <pop@plt>
subsd  (%rsp),%xmm0
jmp    1240 <main+0xe0>
xor    %eax,%eax
call   1060 <pop@plt>
ucomisd 0xd14(%rip),%xmm0
jne    12f0 <main+0x190>
jnp    134e <main+0x1ee>
xor    %eax,%eax
movsd  %xmm0,(%rsp)
call   1060 <pop@plt>
divsd  (%rsp),%xmm0
jmp    1240 <main+0xe0>
xor    %eax,%eax
call   1060 <pop@plt>
add    $0xffffffbf,%r13d
cmp    $0x19,%r13d
ja     133d <main+0x1dd>
xor    %eax,%eax
call   1060 <pop@plt>
mov    %r13d,%eax
movsd  %xmm0,0x10(%rsp,%rax,8)
jmp    1245 <main+0xe5>
cmp    $0x76,%r12d
jne    135f <main+0x1ff>
movsd  0x8(%rsp),%xmm0
jmp    1240 <main+0xe0>
lea    0xdb6(%rip),%rdi
call   1030 <puts@plt>
jmp    1245 <main+0xe5>
lea    0xdbd(%rip),%rdi
call   1030 <puts@plt>
jmp    1245 <main+0xe5>
lea    0xd79(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1245 <main+0xe5>

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

LLVM IR (-O2):
@EOF = global i32 0
@.str.2 = [7 x i8] c"\09%.8g\0A\00"
@.str.3 = [27 x i8] c"error: unknow command %s \0A\00"
@str = [24 x i8] c"error: no variable name\00"
@str.4 = [20 x i8] c"error: zero divisor\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [26 x double]
%3 = bitcast [26 x double]* %2 to i8*
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = call i32 @getop(i8* %4)
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %71, label %8
8: ; preds = %0, %66
%9 = phi i32 [ %68, %66 ], [ %5, %0 ]
%10 = phi double [ %67, %66 ], [ undef, %0 ]
%11 = phi i32 [ %9, %66 ], [ 0, %0 ]
switch i32 %9, label %52 [
i32 48, label %12
i32 43, label %15
i32 42, label %20
i32 45, label %25
i32 47, label %30
i32 61, label %39
i32 10, label %49
]
12: ; preds = %8
%13 = call double @atof(i8* %4)
%14 = call i32 @push(double %13)
br label %66
15: ; preds = %8
%16 = call double (...) @pop()
%17 = call double (...) @pop()
%18 = fadd double %16, %17
%19 = call i32 @push(double %18)
br label %66
20: ; preds = %8
%21 = call double (...) @pop()
%22 = call double (...) @pop()
%23 = fmul double %21, %22
%24 = call i32 @push(double %23)
br label %66
25: ; preds = %8
%26 = call double (...) @pop()
%27 = call double (...) @pop()
%28 = fsub double %27, %26
%29 = call i32 @push(double %28)
br label %66
30: ; preds = %8
%31 = call double (...) @pop()
%32 = fcmp une double %31, 0.000000e+00
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = call double (...) @pop()
%35 = fdiv double %34, %31
%36 = call i32 @push(double %35)
br label %66
37: ; preds = %30
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.4, i64 0, i64 0))
br label %66
39: ; preds = %8
%40 = call double (...) @pop()
%41 = add i32 %11, -65
%42 = icmp ult i32 %41, 26
br i1 %42, label %43, label %47
43: ; preds = %39
%44 = call double (...) @pop()
%45 = zext i32 %41 to i64
%46 = getelementptr inbounds [26 x double], [26 x double]* %2, i64 0, i64 %45
store double %44, double* %46
br label %66
47: ; preds = %39
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
br label %66
49: ; preds = %8
%50 = call double (...) @pop()
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %50)
br label %66
52: ; preds = %8
%53 = add i32 %9, -65
%54 = icmp ult i32 %53, 26
br i1 %54, label %55, label %60
55: ; preds = %52
%56 = zext i32 %53 to i64
%57 = getelementptr inbounds [26 x double], [26 x double]* %2, i64 0, i64 %56
%58 = load double, double* %57
%59 = call i32 @push(double %58)
br label %66
60: ; preds = %52
%61 = icmp eq i32 %9, 118
br i1 %61, label %62, label %64
62: ; preds = %60
%63 = call i32 @push(double %10)
br label %66
64: ; preds = %60
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %4)
br label %66
66: ; preds = %55, %64, %62, %43, %47, %33, %37, %49, %25, %20, %15, %12
%67 = phi double [ %10, %55 ], [ %10, %62 ], [ %10, %64 ], [ %50, %49 ], [ %10, %43 ], [ %10, %47 ], [ %10, %33 ], [ %10, %37 ], [ %10, %25 ], [ %10, %20 ], [ %10, %15 ], [ %10, %12 ]
%68 = call i32 @getop(i8* %4)
%69 = load i32, i32* @EOF
%70 = icmp eq i32 %68, %69
br i1 %70, label %71, label %8
71: ; preds = %66, %0
ret i32 0
}