#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
double atof(char *);
double cos(double);
int /*<<< orphan*/ exit(int);
double exp(double);
int /*<<< orphan*/ *fopen(char *, char *);
double log(double);
char *nextword(int /*<<< orphan*/ *);
double pow(double, double);
int /*<<< orphan*/ printf(char *, ...);
double sin(double);
double stack_pop();
int /*<<< orphan*/ stack_push(double);
int stack_top();
scalar_t__ strcmp(char *, char *);
double rpn_eval(char *fileName, double x) {
  double a, b, c;
  FILE *fd;
  fd = fopen(fileName, "r");
  if (fd == NULL) {
    printf("Could not open file %s\n", fileName);
    exit(1);
  }
  char *word;
  while (word = nextword(fd)) {
    if (c = atof(word)) {
      stack_push(c);
    } else if (strcmp(word, "x") == 0) {
      stack_push(x);
    } else if (strcmp(word, "+") == 0) {
      a = stack_pop();
      b = stack_pop();
      stack_push(a + b);
    } else if (strcmp(word, "-") == 0) {
      a = stack_pop();
      b = stack_pop();
      stack_push(b - a);
    } else if (strcmp(word, "*") == 0) {
      a = stack_pop();
      b = stack_pop();
      stack_push(a * b);
    } else if (strcmp(word, "/") == 0) {
      a = stack_pop();
      b = stack_pop();
      stack_push(b / a);
    } else if (strcmp(word, "sin") == 0) {
      a = stack_pop();
      stack_push(sin(a));
    } else if (strcmp(word, "cos") == 0) {
      a = stack_pop();
      stack_push(cos(a));
    } else if (strcmp(word, "pow") == 0) {
      a = stack_pop();
      b = stack_pop();
      stack_push(pow(b, a));
    } else if (strcmp(word, "log") == 0) {
      a = stack_pop();
      stack_push(log(a));
    } else if (strcmp(word, "exp") == 0) {
      a = stack_pop();
      stack_push(exp(a));
    }
  }
  if (stack_top() != 1) {
    printf("Elements remain in the stack\n");
    exit(1);
  }
  double result = stack_pop();
  return result;
}


x86 assembly (clang, -O0):
<rpn_eval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe04(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    122c <rpn_eval+0x4c>
mov    -0x8(%rbp),%rsi
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    1231 <rpn_eval+0x51>
mov    -0x30(%rbp),%rdi
call   1050 <nextword@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
je     1523 <rpn_eval+0x343>
mov    -0x38(%rbp),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    126e <rpn_eval+0x8e>
jp     126e <rpn_eval+0x8e>
jmp    127d <rpn_eval+0x9d>
movsd  -0x28(%rbp),%xmm0
call   10e0 <stack_push@plt>
jmp    151e <rpn_eval+0x33e>
mov    -0x38(%rbp),%rdi
lea    0xd92(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12a6 <rpn_eval+0xc6>
movsd  -0x10(%rbp),%xmm0
call   10e0 <stack_push@plt>
jmp    1519 <rpn_eval+0x339>
mov    -0x38(%rbp),%rdi
lea    0xd6b(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12ec <rpn_eval+0x10c>
mov    $0x0,%al
call   1100 <stack_pop@plt>
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1100 <stack_pop@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
call   10e0 <stack_push@plt>
jmp    1514 <rpn_eval+0x334>
mov    -0x38(%rbp),%rdi
lea    0xd27(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1332 <rpn_eval+0x152>
mov    $0x0,%al
call   1100 <stack_pop@plt>
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1100 <stack_pop@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
call   10e0 <stack_push@plt>
jmp    150f <rpn_eval+0x32f>
mov    -0x38(%rbp),%rdi
lea    0xce3(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1378 <rpn_eval+0x198>
mov    $0x0,%al
call   1100 <stack_pop@plt>
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1100 <stack_pop@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   10e0 <stack_push@plt>
jmp    150a <rpn_eval+0x32a>
mov    -0x38(%rbp),%rdi
lea    0xc9f(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    13be <rpn_eval+0x1de>
mov    $0x0,%al
call   1100 <stack_pop@plt>
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1100 <stack_pop@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
call   10e0 <stack_push@plt>
jmp    1505 <rpn_eval+0x325>
mov    -0x38(%rbp),%rdi
lea    0xc5b(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    13f8 <rpn_eval+0x218>
mov    $0x0,%al
call   1100 <stack_pop@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1080 <sin@plt>
call   10e0 <stack_push@plt>
jmp    1500 <rpn_eval+0x320>
mov    -0x38(%rbp),%rdi
lea    0xc25(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1432 <rpn_eval+0x252>
mov    $0x0,%al
call   1100 <stack_pop@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   10a0 <cos@plt>
call   10e0 <stack_push@plt>
jmp    14fb <rpn_eval+0x31b>
mov    -0x38(%rbp),%rdi
lea    0xbef(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    147d <rpn_eval+0x29d>
mov    $0x0,%al
call   1100 <stack_pop@plt>
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1100 <stack_pop@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   10d0 <pow@plt>
call   10e0 <stack_push@plt>
jmp    14f6 <rpn_eval+0x316>
mov    -0x38(%rbp),%rdi
lea    0xba8(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    14b7 <rpn_eval+0x2d7>
mov    $0x0,%al
call   1100 <stack_pop@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   10b0 <log@plt>
call   10e0 <stack_push@plt>
jmp    14f1 <rpn_eval+0x311>
mov    -0x38(%rbp),%rdi
lea    0xb72(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    14ec <rpn_eval+0x30c>
mov    $0x0,%al
call   1100 <stack_pop@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1090 <exp@plt>
call   10e0 <stack_push@plt>
jmp    14f1 <rpn_eval+0x311>
jmp    14f6 <rpn_eval+0x316>
jmp    14fb <rpn_eval+0x31b>
jmp    1500 <rpn_eval+0x320>
jmp    1505 <rpn_eval+0x325>
jmp    150a <rpn_eval+0x32a>
jmp    150f <rpn_eval+0x32f>
jmp    1514 <rpn_eval+0x334>
jmp    1519 <rpn_eval+0x339>
jmp    151e <rpn_eval+0x33e>
jmp    1231 <rpn_eval+0x51>
mov    $0x0,%al
call   1030 <stack_top@plt>
cmp    $0x1,%eax
je     154b <rpn_eval+0x36b>
lea    0xafe(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    $0x0,%al
call   1100 <stack_pop@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rpn_eval>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,0x10(%rsp)
mov    %rdi,%rbp
lea    0xdfa(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1467 <rpn_eval+0x277>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <nextword@plt>
test   %rax,%rax
je     1446 <rpn_eval+0x256>
mov    %rax,%rbp
lea    0xde8(%rip),%r14
lea    0xde3(%rip),%r15
lea    0xdde(%rip),%r12
lea    0xdd9(%rip),%r13
nop
mov    %rbp,%rdi
call   1050 <atof@plt>
ucomisd 0xda0(%rip),%xmm0
jne    1264 <rpn_eval+0x74>
jnp    1280 <rpn_eval+0x90>
call   10f0 <stack_push@plt>
mov    %rbx,%rdi
call   1060 <nextword@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1250 <rpn_eval+0x60>
jmp    1446 <rpn_eval+0x256>
xchg   %ax,%ax
mov    %rbp,%rdi
mov    %r14,%rsi
call   1080 <strcmp@plt>
movsd  0x10(%rsp),%xmm0
test   %rax,%rax
je     1264 <rpn_eval+0x74>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1373 <rpn_eval+0x183>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1392 <rpn_eval+0x1a2>
mov    %rbp,%rdi
mov    %r13,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     13b1 <rpn_eval+0x1c1>
mov    %rbp,%rdi
lea    0xd4e(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     13d0 <rpn_eval+0x1e0>
mov    %rbp,%rdi
lea    0xd38(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     13ef <rpn_eval+0x1ff>
mov    %rbp,%rdi
lea    0xd24(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1400 <rpn_eval+0x210>
mov    %rbp,%rdi
lea    0xd10(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1411 <rpn_eval+0x221>
mov    %rbp,%rdi
lea    0xcfc(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1435 <rpn_eval+0x245>
mov    %rbp,%rdi
lea    0xce8(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1269 <rpn_eval+0x79>
xor    %eax,%eax
call   1110 <stack_pop@plt>
call   10a0 <exp@plt>
jmp    1264 <rpn_eval+0x74>
xor    %eax,%eax
call   1110 <stack_pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1110 <stack_pop@plt>
addsd  0x8(%rsp),%xmm0
jmp    1264 <rpn_eval+0x74>
xor    %eax,%eax
call   1110 <stack_pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1110 <stack_pop@plt>
subsd  0x8(%rsp),%xmm0
jmp    1264 <rpn_eval+0x74>
xor    %eax,%eax
call   1110 <stack_pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1110 <stack_pop@plt>
mulsd  0x8(%rsp),%xmm0
jmp    1264 <rpn_eval+0x74>
xor    %eax,%eax
call   1110 <stack_pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1110 <stack_pop@plt>
divsd  0x8(%rsp),%xmm0
jmp    1264 <rpn_eval+0x74>
xor    %eax,%eax
call   1110 <stack_pop@plt>
call   1090 <sin@plt>
jmp    1264 <rpn_eval+0x74>
xor    %eax,%eax
call   1110 <stack_pop@plt>
call   10b0 <cos@plt>
jmp    1264 <rpn_eval+0x74>
xor    %eax,%eax
call   1110 <stack_pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1110 <stack_pop@plt>
movsd  0x8(%rsp),%xmm1
call   10e0 <pow@plt>
jmp    1264 <rpn_eval+0x74>
xor    %eax,%eax
call   1110 <stack_pop@plt>
call   10c0 <log@plt>
jmp    1264 <rpn_eval+0x74>
xor    %eax,%eax
call   1030 <stack_top@plt>
cmp    $0x1,%eax
jne    1482 <rpn_eval+0x292>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1110 <stack_pop@plt>
lea    0xb9c(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    0xbb7(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [24 x i8] c"Could not open file %s\0A\00"
@.str.2 = [2 x i8] c"x\00"
@.str.3 = [2 x i8] c"+\00"
@.str.4 = [2 x i8] c"-\00"
@.str.5 = [2 x i8] c"*\00"
@.str.6 = [2 x i8] c"/\00"
@.str.7 = [4 x i8] c"sin\00"
@.str.8 = [4 x i8] c"cos\00"
@.str.9 = [4 x i8] c"pow\00"
@.str.10 = [4 x i8] c"log\00"
@.str.11 = [4 x i8] c"exp\00"
@.str.12 = [30 x i8] c"Elements remain in the stack\0A\00"
define double @rpn_eval(i8* %0, double %1) {
%3 = alloca i8*
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca double
store i8* %0, i8** %3
store double %1, double* %4
%11 = load i8*, i8** %3
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %8
%13 = load i32*, i32** %8
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = load i8*, i8** %3
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
br label %20
20: ; preds = %139, %19
%21 = load i32*, i32** %8
%22 = call i8* @nextword(i32* %21)
store i8* %22, i8** %9
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %140
24: ; preds = %20
%25 = load i8*, i8** %9
%26 = call double @atof(i8* %25)
store double %26, double* %7
%27 = fcmp une double %26, 0.000000e+00
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load double, double* %7
%30 = call i32 @stack_push(double %29)
br label %139
31: ; preds = %24
%32 = load i8*, i8** %9
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %31
%36 = load double, double* %4
%37 = call i32 @stack_push(double %36)
br label %138
38: ; preds = %31
%39 = load i8*, i8** %9
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %49
42: ; preds = %38
%43 = call double (...) @stack_pop()
store double %43, double* %5
%44 = call double (...) @stack_pop()
store double %44, double* %6
%45 = load double, double* %5
%46 = load double, double* %6
%47 = fadd double %45, %46
%48 = call i32 @stack_push(double %47)
br label %137
49: ; preds = %38
%50 = load i8*, i8** %9
%51 = call i64 @strcmp(i8* %50, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %60
53: ; preds = %49
%54 = call double (...) @stack_pop()
store double %54, double* %5
%55 = call double (...) @stack_pop()
store double %55, double* %6
%56 = load double, double* %6
%57 = load double, double* %5
%58 = fsub double %56, %57
%59 = call i32 @stack_push(double %58)
br label %136
60: ; preds = %49
%61 = load i8*, i8** %9
%62 = call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %71
64: ; preds = %60
%65 = call double (...) @stack_pop()
store double %65, double* %5
%66 = call double (...) @stack_pop()
store double %66, double* %6
%67 = load double, double* %5
%68 = load double, double* %6
%69 = fmul double %67, %68
%70 = call i32 @stack_push(double %69)
br label %135
71: ; preds = %60
%72 = load i8*, i8** %9
%73 = call i64 @strcmp(i8* %72, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%74 = icmp eq i64 %73, 0
br i1 %74, label %75, label %82
75: ; preds = %71
%76 = call double (...) @stack_pop()
store double %76, double* %5
%77 = call double (...) @stack_pop()
store double %77, double* %6
%78 = load double, double* %6
%79 = load double, double* %5
%80 = fdiv double %78, %79
%81 = call i32 @stack_push(double %80)
br label %134
82: ; preds = %71
%83 = load i8*, i8** %9
%84 = call i64 @strcmp(i8* %83, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%85 = icmp eq i64 %84, 0
br i1 %85, label %86, label %91
86: ; preds = %82
%87 = call double (...) @stack_pop()
store double %87, double* %5
%88 = load double, double* %5
%89 = call double @sin(double %88)
%90 = call i32 @stack_push(double %89)
br label %133
91: ; preds = %82
%92 = load i8*, i8** %9
%93 = call i64 @strcmp(i8* %92, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%94 = icmp eq i64 %93, 0
br i1 %94, label %95, label %100
95: ; preds = %91
%96 = call double (...) @stack_pop()
store double %96, double* %5
%97 = load double, double* %5
%98 = call double @cos(double %97)
%99 = call i32 @stack_push(double %98)
br label %132
100: ; preds = %91
%101 = load i8*, i8** %9
%102 = call i64 @strcmp(i8* %101, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%103 = icmp eq i64 %102, 0
br i1 %103, label %104, label %111
104: ; preds = %100
%105 = call double (...) @stack_pop()
store double %105, double* %5
%106 = call double (...) @stack_pop()
store double %106, double* %6
%107 = load double, double* %6
%108 = load double, double* %5
%109 = call double @pow(double %107, double %108)
%110 = call i32 @stack_push(double %109)
br label %131
111: ; preds = %100
%112 = load i8*, i8** %9
%113 = call i64 @strcmp(i8* %112, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%114 = icmp eq i64 %113, 0
br i1 %114, label %115, label %120
115: ; preds = %111
%116 = call double (...) @stack_pop()
store double %116, double* %5
%117 = load double, double* %5
%118 = call double @log(double %117)
%119 = call i32 @stack_push(double %118)
br label %130
120: ; preds = %111
%121 = load i8*, i8** %9
%122 = call i64 @strcmp(i8* %121, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%123 = icmp eq i64 %122, 0
br i1 %123, label %124, label %129
124: ; preds = %120
%125 = call double (...) @stack_pop()
store double %125, double* %5
%126 = load double, double* %5
%127 = call double @exp(double %126)
%128 = call i32 @stack_push(double %127)
br label %129
129: ; preds = %124, %120
br label %130
130: ; preds = %129, %115
br label %131
131: ; preds = %130, %104
br label %132
132: ; preds = %131, %95
br label %133
133: ; preds = %132, %86
br label %134
134: ; preds = %133, %75
br label %135
135: ; preds = %134, %64
br label %136
136: ; preds = %135, %53
br label %137
137: ; preds = %136, %42
br label %138
138: ; preds = %137, %35
br label %139
139: ; preds = %138, %28
br label %20
140: ; preds = %20
%141 = call i32 (...) @stack_top()
%142 = icmp ne i32 %141, 1
br i1 %142, label %143, label %146
143: ; preds = %140
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0))
%145 = call i32 @exit(i32 1)
unreachable
146: ; preds = %140
%147 = call double (...) @stack_pop()
store double %147, double* %10
%148 = load double, double* %10
ret double %148
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [24 x i8] c"Could not open file %s\0A\00"
@.str.2 = [2 x i8] c"x\00"
@.str.3 = [2 x i8] c"+\00"
@.str.4 = [2 x i8] c"-\00"
@.str.5 = [2 x i8] c"*\00"
@.str.6 = [2 x i8] c"/\00"
@.str.7 = [4 x i8] c"sin\00"
@.str.8 = [4 x i8] c"cos\00"
@.str.9 = [4 x i8] c"pow\00"
@.str.10 = [4 x i8] c"log\00"
@.str.11 = [4 x i8] c"exp\00"
@str = [29 x i8] c"Elements remain in the stack\00"
define double @rpn_eval(i8* %0, double %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i8* @nextword(i32* %3)
%7 = icmp eq i8* %6, null
br i1 %7, label %83, label %11
8: ; preds = %2
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %5, %80
%12 = phi i8* [ %81, %80 ], [ %6, %5 ]
%13 = tail call double @atof(i8* %12)
%14 = fcmp une double %13, 0.000000e+00
br i1 %14, label %77, label %15
15: ; preds = %11
%16 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %77, label %18
18: ; preds = %15
%19 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = tail call double (...) @stack_pop()
%23 = tail call double (...) @stack_pop()
%24 = fadd double %22, %23
br label %77
25: ; preds = %18
%26 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = tail call double (...) @stack_pop()
%30 = tail call double (...) @stack_pop()
%31 = fsub double %30, %29
br label %77
32: ; preds = %25
%33 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %32
%36 = tail call double (...) @stack_pop()
%37 = tail call double (...) @stack_pop()
%38 = fmul double %36, %37
br label %77
39: ; preds = %32
%40 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %39
%43 = tail call double (...) @stack_pop()
%44 = tail call double (...) @stack_pop()
%45 = fdiv double %44, %43
br label %77
46: ; preds = %39
%47 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %46
%50 = tail call double (...) @stack_pop()
%51 = tail call double @sin(double %50)
br label %77
52: ; preds = %46
%53 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %52
%56 = tail call double (...) @stack_pop()
%57 = tail call double @cos(double %56)
br label %77
58: ; preds = %52
%59 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %65
61: ; preds = %58
%62 = tail call double (...) @stack_pop()
%63 = tail call double (...) @stack_pop()
%64 = tail call double @pow(double %63, double %62)
br label %77
65: ; preds = %58
%66 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %65
%69 = tail call double (...) @stack_pop()
%70 = tail call double @log(double %69)
br label %77
71: ; preds = %65
%72 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%73 = icmp eq i64 %72, 0
br i1 %73, label %74, label %80
74: ; preds = %71
%75 = tail call double (...) @stack_pop()
%76 = tail call double @exp(double %75)
br label %77
77: ; preds = %15, %11, %21, %35, %49, %61, %74, %68, %55, %42, %28
%78 = phi double [ %31, %28 ], [ %45, %42 ], [ %57, %55 ], [ %70, %68 ], [ %76, %74 ], [ %64, %61 ], [ %51, %49 ], [ %38, %35 ], [ %24, %21 ], [ %13, %11 ], [ %1, %15 ]
%79 = tail call i32 @stack_push(double %78)
br label %80
80: ; preds = %77, %71
%81 = tail call i8* @nextword(i32* %3)
%82 = icmp eq i8* %81, null
br i1 %82, label %83, label %11
83: ; preds = %80, %5
%84 = tail call i32 (...) @stack_top()
%85 = icmp eq i32 %84, 1
br i1 %85, label %89, label %86
86: ; preds = %83
%87 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%88 = tail call i32 @exit(i32 1)
unreachable
89: ; preds = %83
%90 = tail call double (...) @stack_pop()
ret double %90
}