#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 */
struct DynArr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ absolute(struct DynArr *);
int /*<<< orphan*/ add(struct DynArr *);
int /*<<< orphan*/ base10log(struct DynArr *);
struct DynArr *createDynArr(int);
int /*<<< orphan*/ cube(struct DynArr *);
int /*<<< orphan*/ deleteDynArr(struct DynArr *);
int /*<<< orphan*/ divide(struct DynArr *);
int /*<<< orphan*/ etonum(struct DynArr *);
int /*<<< orphan*/ exponential(struct DynArr *);
int /*<<< orphan*/ free(double *);
int isNumber(char *, double *);
double *malloc(int);
int /*<<< orphan*/ multiply(struct DynArr *);
int /*<<< orphan*/ naturalln(struct DynArr *);
int /*<<< orphan*/ pitonum(struct DynArr *);
int /*<<< orphan*/ power(struct DynArr *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ pushDynArr(struct DynArr *, double);
int /*<<< orphan*/ square(struct DynArr *);
int /*<<< orphan*/ squareroot(struct DynArr *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ subtract(struct DynArr *);
double topDynArr(struct DynArr *);
double calculate(int numInputTokens, char **inputString) {
  int i, count = 0, db = 0;
  double result = 0.0;
  double *num = malloc(sizeof(double));
  char *s;
  struct DynArr *stack;
  stack = createDynArr(20);
  for (i = 1; i < numInputTokens; i++) {
    s = inputString[i];
    if (strcmp(s, "+") == 0) {
      add(stack);
      db++;
    } else if (strcmp(s, "-") == 0) {
      subtract(stack);
      db++;
    } else if (strcmp(s, "/") == 0) {
      divide(stack);
      db++;
    } else if (strcmp(s, "x") == 0) {
      multiply(stack);
      db++;
    } else if (strcmp(s, "^") == 0) {
      power(stack);
      db++;
    } else if (strcmp(s, "^2") == 0)
      square(stack);
    else if (strcmp(s, "^3") == 0)
      cube(stack);
    else if (strcmp(s, "abs") == 0)
      absolute(stack);
    else if (strcmp(s, "sqrt") == 0)
      squareroot(stack);
    else if (strcmp(s, "exp") == 0)
      exponential(stack);
    else if (strcmp(s, "ln") == 0)
      naturalln(stack);
    else if (strcmp(s, "log") == 0)
      base10log(stack);
    else {
      if (strcmp(s, "e") == 0) {
        etonum(stack);
        count++;
      } else if (strcmp(s, "pi") == 0) {
        pitonum(stack);
        count++;
      } else if (isNumber(s, num) == 1) {
        pushDynArr(stack, *num);
        count++;
      } else {
        printf("Input error. Please check.\n");
        printf("For multiplication, please type x insdead of *.\n");
        printf("If the input contains value '0', please type 0 straightly "
               "instead of 0.0, 0.000, 0e0, etc.\n");
        return 0;
      }
    }
  }
  if (!stack) {
    printf("Error: The stack is empty.\n");
    return 0;
  }
  if (db > 0)
    db = 1;
  if ((i - 1 - count + db) < count)
    printf("Input error: Too few operators.\n");
  else if ((i - 1 - count + db) > count)
    printf("Input error: Too few numbers.\n");
  else {
    result = topDynArr(stack);
    printf("Final value = %lf\n", result);
  }
  free(num);
  deleteDynArr(stack);
  return result;
}


x86 assembly (clang, -O0):
<calculate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    $0x8,%edi
call   1110 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    $0x14,%edi
call   1150 <createDynArr@plt>
mov    %rax,-0x48(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1608 <calculate+0x398>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
lea    0xd21(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1305 <calculate+0x95>
mov    -0x48(%rbp),%rdi
call   1050 <add@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    15f5 <calculate+0x385>
mov    -0x40(%rbp),%rdi
lea    0xcf2(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1336 <calculate+0xc6>
mov    -0x48(%rbp),%rdi
call   1130 <subtract@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    15f0 <calculate+0x380>
mov    -0x40(%rbp),%rdi
lea    0xcc3(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1367 <calculate+0xf7>
mov    -0x48(%rbp),%rdi
call   1080 <divide@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    15eb <calculate+0x37b>
mov    -0x40(%rbp),%rdi
lea    0xc94(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1398 <calculate+0x128>
mov    -0x48(%rbp),%rdi
call   1070 <multiply@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    15e6 <calculate+0x376>
mov    -0x40(%rbp),%rdi
lea    0xc65(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    13c9 <calculate+0x159>
mov    -0x48(%rbp),%rdi
call   1060 <power@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    15e1 <calculate+0x371>
mov    -0x40(%rbp),%rdi
lea    0xc36(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    13f1 <calculate+0x181>
mov    -0x48(%rbp),%rdi
call   1090 <square@plt>
jmp    15dc <calculate+0x36c>
mov    -0x40(%rbp),%rdi
lea    0xc11(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1419 <calculate+0x1a9>
mov    -0x48(%rbp),%rdi
call   1190 <cube@plt>
jmp    15d7 <calculate+0x367>
mov    -0x40(%rbp),%rdi
lea    0xbec(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1441 <calculate+0x1d1>
mov    -0x48(%rbp),%rdi
call   10b0 <absolute@plt>
jmp    15d2 <calculate+0x362>
mov    -0x40(%rbp),%rdi
lea    0xbc8(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1469 <calculate+0x1f9>
mov    -0x48(%rbp),%rdi
call   1140 <squareroot@plt>
jmp    15cd <calculate+0x35d>
mov    -0x40(%rbp),%rdi
lea    0xba5(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1491 <calculate+0x221>
mov    -0x48(%rbp),%rdi
call   10d0 <exponential@plt>
jmp    15c8 <calculate+0x358>
mov    -0x40(%rbp),%rdi
lea    0xb81(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    14b9 <calculate+0x249>
mov    -0x48(%rbp),%rdi
call   1180 <naturalln@plt>
jmp    15c3 <calculate+0x353>
mov    -0x40(%rbp),%rdi
lea    0xb5c(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    14e1 <calculate+0x271>
mov    -0x48(%rbp),%rdi
call   1160 <base10log@plt>
jmp    15be <calculate+0x34e>
mov    -0x40(%rbp),%rdi
lea    0xb38(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1512 <calculate+0x2a2>
mov    -0x48(%rbp),%rdi
call   10f0 <etonum@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    15b9 <calculate+0x349>
mov    -0x40(%rbp),%rdi
lea    0xb09(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1543 <calculate+0x2d3>
mov    -0x48(%rbp),%rdi
call   1120 <pitonum@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    15b4 <calculate+0x344>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   10e0 <isNumber@plt>
cmp    $0x1,%eax
jne    1578 <calculate+0x308>
mov    -0x48(%rbp),%rdi
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
call   1170 <pushDynArr@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    15af <calculate+0x33f>
lea    0xaaa(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    0xab8(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    0xadb(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    16d1 <calculate+0x461>
jmp    15b4 <calculate+0x344>
jmp    15b9 <calculate+0x349>
jmp    15be <calculate+0x34e>
jmp    15c3 <calculate+0x353>
jmp    15c8 <calculate+0x358>
jmp    15cd <calculate+0x35d>
jmp    15d2 <calculate+0x362>
jmp    15d7 <calculate+0x367>
jmp    15dc <calculate+0x36c>
jmp    15e1 <calculate+0x371>
jmp    15e6 <calculate+0x376>
jmp    15eb <calculate+0x37b>
jmp    15f0 <calculate+0x380>
jmp    15f5 <calculate+0x385>
jmp    15fa <calculate+0x38a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12b8 <calculate+0x48>
cmpq   $0x0,-0x48(%rbp)
jne    162e <calculate+0x3be>
lea    0xab8(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    16d1 <calculate+0x461>
cmpl   $0x0,-0x24(%rbp)
jle    163f <calculate+0x3cf>
movl   $0x1,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
sub    -0x20(%rbp),%eax
add    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1667 <calculate+0x3f7>
lea    0xa93(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
jmp    16b5 <calculate+0x445>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
sub    -0x20(%rbp),%eax
add    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    168f <calculate+0x41f>
lea    0xa8c(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
jmp    16b0 <calculate+0x440>
mov    -0x48(%rbp),%rdi
call   1030 <topDynArr@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
lea    0xa85(%rip),%rdi
mov    $0x1,%al
call   10a0 <printf@plt>
jmp    16b5 <calculate+0x445>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
mov    -0x48(%rbp),%rdi
call   1100 <deleteDynArr@plt>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
mov    $0x8,%edi
call   1120 <malloc@plt>
mov    %rax,%r14
mov    $0x14,%edi
call   1160 <createDynArr@plt>
cmp    $0x2,%ebx
jl     152a <calculate+0x2aa>
mov    %r14,0x10(%rsp)
mov    %ebx,0xc(%rsp)
mov    %ebx,%r13d
movl   $0x0,(%rsp)
mov    $0x1,%r12d
xor    %r15d,%r15d
mov    %rax,%rbx
jmp    12f9 <calculate+0x79>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1050 <add@plt>
add    $0x1,%r15d
add    $0x1,%r12
cmp    %r12,%r13
je     155d <calculate+0x2dd>
mov    0x0(%rbp,%r12,8),%r14
mov    %r14,%rdi
lea    0xcf8(%rip),%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     12e0 <calculate+0x60>
mov    %r14,%rdi
lea    0xce6(%rip),%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     1480 <calculate+0x200>
mov    %r14,%rdi
lea    0xcd0(%rip),%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     148d <calculate+0x20d>
mov    %r14,%rdi
lea    0xcba(%rip),%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     149a <calculate+0x21a>
mov    %r14,%rdi
lea    0xca4(%rip),%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     14a7 <calculate+0x227>
mov    %r14,%rdi
lea    0xc8e(%rip),%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     14b4 <calculate+0x234>
mov    %r14,%rdi
lea    0xc79(%rip),%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     14c1 <calculate+0x241>
mov    %r14,%rdi
lea    0xc64(%rip),%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     14ce <calculate+0x24e>
mov    %r14,%rdi
lea    0xc50(%rip),%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     14db <calculate+0x25b>
mov    %r14,%rdi
lea    0xc3d(%rip),%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     14e8 <calculate+0x268>
mov    %r14,%rdi
lea    0xc29(%rip),%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     14f5 <calculate+0x275>
mov    %r14,%rdi
lea    0xc14(%rip),%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     1502 <calculate+0x282>
mov    %r14,%rdi
lea    0xc00(%rip),%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     150f <calculate+0x28f>
mov    %r14,%rdi
lea    0xbea(%rip),%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     1519 <calculate+0x299>
mov    %r14,%rdi
mov    0x10(%rsp),%r14
mov    %r14,%rsi
call   10f0 <isNumber@plt>
cmp    $0x1,%eax
jne    15d6 <calculate+0x356>
movsd  (%r14),%xmm0
mov    %rbx,%rdi
call   1180 <pushDynArr@plt>
jmp    1521 <calculate+0x2a1>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1140 <subtract@plt>
jmp    12e8 <calculate+0x68>
mov    %rbx,%rdi
call   1090 <divide@plt>
jmp    12e8 <calculate+0x68>
mov    %rbx,%rdi
call   1070 <multiply@plt>
jmp    12e8 <calculate+0x68>
mov    %rbx,%rdi
call   1060 <power@plt>
jmp    12e8 <calculate+0x68>
mov    %rbx,%rdi
call   10a0 <square@plt>
jmp    12ec <calculate+0x6c>
mov    %rbx,%rdi
call   11a0 <cube@plt>
jmp    12ec <calculate+0x6c>
mov    %rbx,%rdi
call   10c0 <absolute@plt>
jmp    12ec <calculate+0x6c>
mov    %rbx,%rdi
call   1150 <squareroot@plt>
jmp    12ec <calculate+0x6c>
mov    %rbx,%rdi
call   10e0 <exponential@plt>
jmp    12ec <calculate+0x6c>
mov    %rbx,%rdi
call   1190 <naturalln@plt>
jmp    12ec <calculate+0x6c>
mov    %rbx,%rdi
call   1170 <base10log@plt>
jmp    12ec <calculate+0x6c>
mov    %rbx,%rdi
call   1100 <etonum@plt>
jmp    1521 <calculate+0x2a1>
mov    %rbx,%rdi
call   1130 <pitonum@plt>
addl   $0x1,(%rsp)
jmp    12ec <calculate+0x6c>
mov    $0x1,%edx
xor    %r15d,%r15d
xor    %esi,%esi
mov    %rax,%rbx
test   %rbx,%rbx
je     156e <calculate+0x2ee>
test   %r15d,%r15d
mov    $0x1,%eax
cmovle %r15d,%eax
mov    %esi,%ecx
not    %ecx
add    %ecx,%edx
add    %eax,%edx
cmp    %esi,%edx
jge    157f <calculate+0x2ff>
lea    0xb1a(%rip),%rdi
jmp    1588 <calculate+0x308>
mov    0x10(%rsp),%r14
mov    0xc(%rsp),%edx
mov    (%rsp),%esi
test   %rbx,%rbx
jne    153c <calculate+0x2bc>
lea    0xac7(%rip),%rdi
call   1080 <puts@plt>
xorps  %xmm0,%xmm0
jmp    15c7 <calculate+0x347>
jle    1597 <calculate+0x317>
lea    0xacf(%rip),%rdi
call   1080 <puts@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
jmp    15b2 <calculate+0x332>
mov    %rbx,%rdi
call   1030 <topDynArr@plt>
lea    0xa83(%rip),%rdi
movsd  %xmm0,(%rsp)
mov    $0x1,%al
call   10b0 <printf@plt>
mov    %r14,%rdi
call   1040 <free@plt>
mov    %rbx,%rdi
call   1110 <deleteDynArr@plt>
movsd  (%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xab8(%rip),%rdi
call   1080 <puts@plt>
lea    0xac7(%rip),%rdi
call   1080 <puts@plt>
lea    0xaeb(%rip),%rdi
jmp    1575 <calculate+0x2f5>

LLVM IR (-O0):
%struct.DynArr = type { i32 }
@.str = [2 x i8] c"+\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [2 x i8] c"/\00"
@.str.3 = [2 x i8] c"x\00"
@.str.4 = [2 x i8] c"^\00"
@.str.5 = [3 x i8] c"^2\00"
@.str.6 = [3 x i8] c"^3\00"
@.str.7 = [4 x i8] c"abs\00"
@.str.8 = [5 x i8] c"sqrt\00"
@.str.9 = [4 x i8] c"exp\00"
@.str.10 = [3 x i8] c"ln\00"
@.str.11 = [4 x i8] c"log\00"
@.str.12 = [2 x i8] c"e\00"
@.str.13 = [3 x i8] c"pi\00"
@.str.14 = [28 x i8] c"Input error. Please check.\0A\00"
@.str.15 = [49 x i8] c"For multiplication, please type x insdead of *.\0A\00"
@.str.16 = [92 x i8] c"If the input contains value '0', please type 0 straightly instead of 0.0, 0.000, 0e0, etc.\0A\00"
@.str.17 = [28 x i8] c"Error: The stack is empty.\0A\00"
@.str.18 = [33 x i8] c"Input error: Too few operators.\0A\00"
@.str.19 = [31 x i8] c"Input error: Too few numbers.\0A\00"
@.str.20 = [19 x i8] c"Final value = %lf\0A\00"
define double @calculate(i32 %0, i8** %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double*
%11 = alloca i8*
%12 = alloca %struct.DynArr*
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %8
store double 0.000000e+00, double* %9
%13 = call double* @malloc(i32 8)
store double* %13, double** %10
%14 = call %struct.DynArr* @createDynArr(i32 20)
store %struct.DynArr* %14, %struct.DynArr** %12
store i32 1, i32* %6
br label %15
15: ; preds = %167, %2
%16 = load i32, i32* %6
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %170
19: ; preds = %15
%20 = load i8**, i8*** %5
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
store i8* %24, i8** %11
%25 = load i8*, i8** %11
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %19
%29 = load %struct.DynArr*, %struct.DynArr** %12
%30 = call i32 @add(%struct.DynArr* %29)
%31 = load i32, i32* %8
%32 = add nsw i32 %31, 1
store i32 %32, i32* %8
br label %166
33: ; preds = %19
%34 = load i8*, i8** %11
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = load %struct.DynArr*, %struct.DynArr** %12
%39 = call i32 @subtract(%struct.DynArr* %38)
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
br label %165
42: ; preds = %33
%43 = load i8*, i8** %11
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %51
46: ; preds = %42
%47 = load %struct.DynArr*, %struct.DynArr** %12
%48 = call i32 @divide(%struct.DynArr* %47)
%49 = load i32, i32* %8
%50 = add nsw i32 %49, 1
store i32 %50, i32* %8
br label %164
51: ; preds = %42
%52 = load i8*, i8** %11
%53 = call i64 @strcmp(i8* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %60
55: ; preds = %51
%56 = load %struct.DynArr*, %struct.DynArr** %12
%57 = call i32 @multiply(%struct.DynArr* %56)
%58 = load i32, i32* %8
%59 = add nsw i32 %58, 1
store i32 %59, i32* %8
br label %163
60: ; preds = %51
%61 = load i8*, i8** %11
%62 = call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %69
64: ; preds = %60
%65 = load %struct.DynArr*, %struct.DynArr** %12
%66 = call i32 @power(%struct.DynArr* %65)
%67 = load i32, i32* %8
%68 = add nsw i32 %67, 1
store i32 %68, i32* %8
br label %162
69: ; preds = %60
%70 = load i8*, i8** %11
%71 = call i64 @strcmp(i8* %70, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %76
73: ; preds = %69
%74 = load %struct.DynArr*, %struct.DynArr** %12
%75 = call i32 @square(%struct.DynArr* %74)
br label %161
76: ; preds = %69
%77 = load i8*, i8** %11
%78 = call i64 @strcmp(i8* %77, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%79 = icmp eq i64 %78, 0
br i1 %79, label %80, label %83
80: ; preds = %76
%81 = load %struct.DynArr*, %struct.DynArr** %12
%82 = call i32 @cube(%struct.DynArr* %81)
br label %160
83: ; preds = %76
%84 = load i8*, i8** %11
%85 = call i64 @strcmp(i8* %84, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%86 = icmp eq i64 %85, 0
br i1 %86, label %87, label %90
87: ; preds = %83
%88 = load %struct.DynArr*, %struct.DynArr** %12
%89 = call i32 @absolute(%struct.DynArr* %88)
br label %159
90: ; preds = %83
%91 = load i8*, i8** %11
%92 = call i64 @strcmp(i8* %91, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%93 = icmp eq i64 %92, 0
br i1 %93, label %94, label %97
94: ; preds = %90
%95 = load %struct.DynArr*, %struct.DynArr** %12
%96 = call i32 @squareroot(%struct.DynArr* %95)
br label %158
97: ; preds = %90
%98 = load i8*, i8** %11
%99 = call i64 @strcmp(i8* %98, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%100 = icmp eq i64 %99, 0
br i1 %100, label %101, label %104
101: ; preds = %97
%102 = load %struct.DynArr*, %struct.DynArr** %12
%103 = call i32 @exponential(%struct.DynArr* %102)
br label %157
104: ; preds = %97
%105 = load i8*, i8** %11
%106 = call i64 @strcmp(i8* %105, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%107 = icmp eq i64 %106, 0
br i1 %107, label %108, label %111
108: ; preds = %104
%109 = load %struct.DynArr*, %struct.DynArr** %12
%110 = call i32 @naturalln(%struct.DynArr* %109)
br label %156
111: ; preds = %104
%112 = load i8*, i8** %11
%113 = call i64 @strcmp(i8* %112, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%114 = icmp eq i64 %113, 0
br i1 %114, label %115, label %118
115: ; preds = %111
%116 = load %struct.DynArr*, %struct.DynArr** %12
%117 = call i32 @base10log(%struct.DynArr* %116)
br label %155
118: ; preds = %111
%119 = load i8*, i8** %11
%120 = call i64 @strcmp(i8* %119, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%121 = icmp eq i64 %120, 0
br i1 %121, label %122, label %127
122: ; preds = %118
%123 = load %struct.DynArr*, %struct.DynArr** %12
%124 = call i32 @etonum(%struct.DynArr* %123)
%125 = load i32, i32* %7
%126 = add nsw i32 %125, 1
store i32 %126, i32* %7
br label %154
127: ; preds = %118
%128 = load i8*, i8** %11
%129 = call i64 @strcmp(i8* %128, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%130 = icmp eq i64 %129, 0
br i1 %130, label %131, label %136
131: ; preds = %127
%132 = load %struct.DynArr*, %struct.DynArr** %12
%133 = call i32 @pitonum(%struct.DynArr* %132)
%134 = load i32, i32* %7
%135 = add nsw i32 %134, 1
store i32 %135, i32* %7
br label %153
136: ; preds = %127
%137 = load i8*, i8** %11
%138 = load double*, double** %10
%139 = call i32 @isNumber(i8* %137, double* %138)
%140 = icmp eq i32 %139, 1
br i1 %140, label %141, label %148
141: ; preds = %136
%142 = load %struct.DynArr*, %struct.DynArr** %12
%143 = load double*, double** %10
%144 = load double, double* %143
%145 = call i32 @pushDynArr(%struct.DynArr* %142, double %144)
%146 = load i32, i32* %7
%147 = add nsw i32 %146, 1
store i32 %147, i32* %7
br label %152
148: ; preds = %136
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0))
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.15, i64 0, i64 0))
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.16, i64 0, i64 0))
store double 0.000000e+00, double* %3
br label %213
152: ; preds = %141
br label %153
153: ; preds = %152, %131
br label %154
154: ; preds = %153, %122
br label %155
155: ; preds = %154, %115
br label %156
156: ; preds = %155, %108
br label %157
157: ; preds = %156, %101
br label %158
158: ; preds = %157, %94
br label %159
159: ; preds = %158, %87
br label %160
160: ; preds = %159, %80
br label %161
161: ; preds = %160, %73
br label %162
162: ; preds = %161, %64
br label %163
163: ; preds = %162, %55
br label %164
164: ; preds = %163, %46
br label %165
165: ; preds = %164, %37
br label %166
166: ; preds = %165, %28
br label %167
167: ; preds = %166
%168 = load i32, i32* %6
%169 = add nsw i32 %168, 1
store i32 %169, i32* %6
br label %15
170: ; preds = %15
%171 = load %struct.DynArr*, %struct.DynArr** %12
%172 = icmp ne %struct.DynArr* %171, null
br i1 %172, label %175, label %173
173: ; preds = %170
%174 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.17, i64 0, i64 0))
store double 0.000000e+00, double* %3
br label %213
175: ; preds = %170
%176 = load i32, i32* %8
%177 = icmp sgt i32 %176, 0
br i1 %177, label %178, label %179
178: ; preds = %175
store i32 1, i32* %8
br label %179
179: ; preds = %178, %175
%180 = load i32, i32* %6
%181 = sub nsw i32 %180, 1
%182 = load i32, i32* %7
%183 = sub nsw i32 %181, %182
%184 = load i32, i32* %8
%185 = add nsw i32 %183, %184
%186 = load i32, i32* %7
%187 = icmp slt i32 %185, %186
br i1 %187, label %188, label %190
188: ; preds = %179
%189 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.18, i64 0, i64 0))
br label %207
190: ; preds = %179
%191 = load i32, i32* %6
%192 = sub nsw i32 %191, 1
%193 = load i32, i32* %7
%194 = sub nsw i32 %192, %193
%195 = load i32, i32* %8
%196 = add nsw i32 %194, %195
%197 = load i32, i32* %7
%198 = icmp sgt i32 %196, %197
br i1 %198, label %199, label %201
199: ; preds = %190
%200 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.19, i64 0, i64 0))
br label %206
201: ; preds = %190
%202 = load %struct.DynArr*, %struct.DynArr** %12
%203 = call double @topDynArr(%struct.DynArr* %202)
store double %203, double* %9
%204 = load double, double* %9
%205 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.20, i64 0, i64 0), double %204)
br label %206
206: ; preds = %201, %199
br label %207
207: ; preds = %206, %188
%208 = load double*, double** %10
%209 = call i32 @free(double* %208)
%210 = load %struct.DynArr*, %struct.DynArr** %12
%211 = call i32 @deleteDynArr(%struct.DynArr* %210)
%212 = load double, double* %9
store double %212, double* %3
br label %213
213: ; preds = %207, %173, %148
%214 = load double, double* %3
ret double %214
}

LLVM IR (-O2):
%struct.DynArr = type { i32 }
@.str = [2 x i8] c"+\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [2 x i8] c"/\00"
@.str.3 = [2 x i8] c"x\00"
@.str.4 = [2 x i8] c"^\00"
@.str.5 = [3 x i8] c"^2\00"
@.str.6 = [3 x i8] c"^3\00"
@.str.7 = [4 x i8] c"abs\00"
@.str.8 = [5 x i8] c"sqrt\00"
@.str.9 = [4 x i8] c"exp\00"
@.str.10 = [3 x i8] c"ln\00"
@.str.11 = [4 x i8] c"log\00"
@.str.12 = [2 x i8] c"e\00"
@.str.13 = [3 x i8] c"pi\00"
@.str.20 = [19 x i8] c"Final value = %lf\0A\00"
@str = [27 x i8] c"Error: The stack is empty.\00"
@str.21 = [30 x i8] c"Input error: Too few numbers.\00"
@str.22 = [32 x i8] c"Input error: Too few operators.\00"
@str.23 = [27 x i8] c"Input error. Please check.\00"
@str.24 = [48 x i8] c"For multiplication, please type x insdead of *.\00"
@str.25 = [91 x i8] c"If the input contains value '0', please type 0 straightly instead of 0.0, 0.000, 0e0, etc.\00"
define double @calculate(i32 %0, i8** nocapture %1) {
%3 = tail call double* @malloc(i32 8)
%4 = tail call %struct.DynArr* @createDynArr(i32 20)
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %106
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %101
%9 = phi i64 [ 1, %6 ], [ %104, %101 ]
%10 = phi i32 [ 0, %6 ], [ %103, %101 ]
%11 = phi i32 [ 0, %6 ], [ %102, %101 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 %9
%13 = load i8*, i8** %12
%14 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %8
%17 = tail call i32 @add(%struct.DynArr* %4)
%18 = add nsw i32 %11, 1
br label %101
19: ; preds = %8
%20 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = tail call i32 @subtract(%struct.DynArr* %4)
%24 = add nsw i32 %11, 1
br label %101
25: ; preds = %19
%26 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = tail call i32 @divide(%struct.DynArr* %4)
%30 = add nsw i32 %11, 1
br label %101
31: ; preds = %25
%32 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = tail call i32 @multiply(%struct.DynArr* %4)
%36 = add nsw i32 %11, 1
br label %101
37: ; preds = %31
%38 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %37
%41 = tail call i32 @power(%struct.DynArr* %4)
%42 = add nsw i32 %11, 1
br label %101
43: ; preds = %37
%44 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %43
%47 = tail call i32 @square(%struct.DynArr* %4)
br label %101
48: ; preds = %43
%49 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %48
%52 = tail call i32 @cube(%struct.DynArr* %4)
br label %101
53: ; preds = %48
%54 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = tail call i32 @absolute(%struct.DynArr* %4)
br label %101
58: ; preds = %53
%59 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %58
%62 = tail call i32 @squareroot(%struct.DynArr* %4)
br label %101
63: ; preds = %58
%64 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %63
%67 = tail call i32 @exponential(%struct.DynArr* %4)
br label %101
68: ; preds = %63
%69 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %73
71: ; preds = %68
%72 = tail call i32 @naturalln(%struct.DynArr* %4)
br label %101
73: ; preds = %68
%74 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %73
%77 = tail call i32 @base10log(%struct.DynArr* %4)
br label %101
78: ; preds = %73
%79 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %84
81: ; preds = %78
%82 = tail call i32 @etonum(%struct.DynArr* %4)
%83 = add nsw i32 %10, 1
br label %101
84: ; preds = %78
%85 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%86 = icmp eq i64 %85, 0
br i1 %86, label %87, label %90
87: ; preds = %84
%88 = tail call i32 @pitonum(%struct.DynArr* %4)
%89 = add nsw i32 %10, 1
br label %101
90: ; preds = %84
%91 = tail call i32 @isNumber(i8* %13, double* %3)
%92 = icmp eq i32 %91, 1
br i1 %92, label %93, label %97
93: ; preds = %90
%94 = load double, double* %3
%95 = tail call i32 @pushDynArr(%struct.DynArr* %4, double %94)
%96 = add nsw i32 %10, 1
br label %101
97: ; preds = %90
%98 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.23, i64 0, i64 0))
%99 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.24, i64 0, i64 0))
%100 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([91 x i8], [91 x i8]* @str.25, i64 0, i64 0))
br label %133
101: ; preds = %16, %28, %40, %51, %61, %71, %81, %93, %87, %76, %66, %56, %46, %34, %22
%102 = phi i32 [ %18, %16 ], [ %24, %22 ], [ %30, %28 ], [ %36, %34 ], [ %42, %40 ], [ %11, %46 ], [ %11, %51 ], [ %11, %56 ], [ %11, %61 ], [ %11, %66 ], [ %11, %71 ], [ %11, %76 ], [ %11, %81 ], [ %11, %87 ], [ %11, %93 ]
%103 = phi i32 [ %10, %16 ], [ %10, %22 ], [ %10, %28 ], [ %10, %34 ], [ %10, %40 ], [ %10, %46 ], [ %10, %51 ], [ %10, %56 ], [ %10, %61 ], [ %10, %66 ], [ %10, %71 ], [ %10, %76 ], [ %83, %81 ], [ %89, %87 ], [ %96, %93 ]
%104 = add nuw nsw i64 %9, 1
%105 = icmp eq i64 %104, %7
br i1 %105, label %106, label %8
106: ; preds = %101, %2
%107 = phi i32 [ 0, %2 ], [ %102, %101 ]
%108 = phi i32 [ 0, %2 ], [ %103, %101 ]
%109 = phi i32 [ 1, %2 ], [ %0, %101 ]
%110 = icmp eq %struct.DynArr* %4, null
br i1 %110, label %111, label %113
111: ; preds = %106
%112 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %133
113: ; preds = %106
%114 = icmp slt i32 %107, 1
%115 = select i1 %114, i32 %107, i32 1
%116 = xor i32 %108, -1
%117 = add i32 %109, %116
%118 = add nsw i32 %117, %115
%119 = icmp slt i32 %118, %108
br i1 %119, label %120, label %122
120: ; preds = %113
%121 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.22, i64 0, i64 0))
br label %129
122: ; preds = %113
%123 = icmp sgt i32 %118, %108
br i1 %123, label %124, label %126
124: ; preds = %122
%125 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.21, i64 0, i64 0))
br label %129
126: ; preds = %122
%127 = tail call double @topDynArr(%struct.DynArr* %4)
%128 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.20, i64 0, i64 0), double %127)
br label %129
129: ; preds = %124, %126, %120
%130 = phi double [ 0.000000e+00, %120 ], [ 0.000000e+00, %124 ], [ %127, %126 ]
%131 = tail call i32 @free(double* %3)
%132 = tail call i32 @deleteDynArr(%struct.DynArr* %4)
br label %133
133: ; preds = %129, %111, %97
%134 = phi double [ 0.000000e+00, %97 ], [ %130, %129 ], [ 0.000000e+00, %111 ]
ret double %134
}