#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 /*<<< orphan*/ cos(double);
int /*<<< orphan*/ exp(double);
double pop();
int /*<<< orphan*/ pow(double, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ process_variable(char *);
int /*<<< orphan*/ push(int /*<<< orphan*/);
int /*<<< orphan*/ sin(double);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ tan(double);
void process_function_or_variable(char *name) {
  if (strcmp(name, "sin") == 0)
    push(sin(pop()));
  else if (strcmp(name, "cos") == 0)
    push(cos(pop()));
  else if (strcmp(name, "tan") == 0)
    push(tan(pop()));
  else if (strcmp(name, "exp") == 0)
    push(exp(pop()));
  else if (strcmp(name, "pow") == 0) {
    double op2 = pop();
    double op1 = pop();
    if (op1 == 0 && op2 <= 0)
      printf("error: trying to get \'%f^%f\'\n", op1, op2);
    else
      push(pow(op1, op2));
  } else if (strlen(name) == 1)
    process_variable(name);
  else
    printf("error: unknown command \'%s\'\n", name);
}


x86 assembly (clang, -O0):
<process_function_or_variable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11ee <process_function_or_variable+0x3e>
mov    $0x0,%al
call   1060 <pop@plt>
call   1080 <sin@plt>
mov    %eax,%edi
call   10c0 <push@plt>
jmp    135f <process_function_or_variable+0x1af>
mov    -0x8(%rbp),%rdi
lea    0xe0b(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1220 <process_function_or_variable+0x70>
mov    $0x0,%al
call   1060 <pop@plt>
call   10b0 <cos@plt>
mov    %eax,%edi
call   10c0 <push@plt>
jmp    135a <process_function_or_variable+0x1aa>
mov    -0x8(%rbp),%rdi
lea    0xddd(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1252 <process_function_or_variable+0xa2>
mov    $0x0,%al
call   1060 <pop@plt>
call   10a0 <tan@plt>
mov    %eax,%edi
call   10c0 <push@plt>
jmp    1355 <process_function_or_variable+0x1a5>
mov    -0x8(%rbp),%rdi
lea    0xdaf(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1284 <process_function_or_variable+0xd4>
mov    $0x0,%al
call   1060 <pop@plt>
call   1090 <exp@plt>
mov    %eax,%edi
call   10c0 <push@plt>
jmp    1350 <process_function_or_variable+0x1a0>
mov    -0x8(%rbp),%rdi
lea    0xd81(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1314 <process_function_or_variable+0x164>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12f9 <process_function_or_variable+0x149>
jp     12f9 <process_function_or_variable+0x149>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     12f9 <process_function_or_variable+0x149>
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    0xd27(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
jmp    130f <process_function_or_variable+0x15f>
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   10d0 <pow@plt>
mov    %eax,%edi
call   10c0 <push@plt>
jmp    134b <process_function_or_variable+0x19b>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x1,%eax
jne    1334 <process_function_or_variable+0x184>
mov    -0x8(%rbp),%rdi
call   1030 <process_variable@plt>
jmp    1346 <process_function_or_variable+0x196>
mov    -0x8(%rbp),%rsi
lea    0xcf3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    134b <process_function_or_variable+0x19b>
jmp    1350 <process_function_or_variable+0x1a0>
jmp    1355 <process_function_or_variable+0x1a5>
jmp    135a <process_function_or_variable+0x1aa>
jmp    135f <process_function_or_variable+0x1af>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_function_or_variable>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xe41(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1237 <process_function_or_variable+0x87>
lea    0xe34(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1248 <process_function_or_variable+0x98>
lea    0xe24(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1256 <process_function_or_variable+0xa6>
lea    0xe14(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1264 <process_function_or_variable+0xb4>
lea    0xe04(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1272 <process_function_or_variable+0xc2>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x1,%eax
jne    12b1 <process_function_or_variable+0x101>
mov    %rbx,%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1030 <process_variable@plt>
xor    %eax,%eax
call   1060 <pop@plt>
call   1080 <sin@plt>
jmp    12cc <process_function_or_variable+0x11c>
xor    %eax,%eax
call   1060 <pop@plt>
call   10b0 <cos@plt>
jmp    12cc <process_function_or_variable+0x11c>
xor    %eax,%eax
call   1060 <pop@plt>
call   10a0 <tan@plt>
jmp    12cc <process_function_or_variable+0x11c>
xor    %eax,%eax
call   1060 <pop@plt>
call   1090 <exp@plt>
jmp    12cc <process_function_or_variable+0x11c>
xor    %eax,%eax
call   1060 <pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1060 <pop@plt>
movsd  0x8(%rsp),%xmm1
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jne    12c7 <process_function_or_variable+0x117>
jp     12c7 <process_function_or_variable+0x117>
ucomisd %xmm1,%xmm2
jb     12c7 <process_function_or_variable+0x117>
lea    0xd6f(%rip),%rdi
mov    $0x2,%al
add    $0x10,%rsp
pop    %rbx
jmp    1050 <printf@plt>
lea    0xd7a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
jmp    1050 <printf@plt>
call   10d0 <pow@plt>
mov    %eax,%edi
add    $0x10,%rsp
pop    %rbx
jmp    10c0 <push@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"sin\00"
@.str.1 = [4 x i8] c"cos\00"
@.str.2 = [4 x i8] c"tan\00"
@.str.3 = [4 x i8] c"exp\00"
@.str.4 = [4 x i8] c"pow\00"
@.str.5 = [30 x i8] c"error: trying to get '%f^%f'\0A\00"
@.str.6 = [29 x i8] c"error: unknown command '%s'\0A\00"
define void @process_function_or_variable(i8* %0) {
%2 = alloca i8*
%3 = alloca double
%4 = alloca double
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = call double (...) @pop()
%10 = call i32 @sin(double %9)
%11 = call i32 @push(i32 %10)
br label %73
12: ; preds = %1
%13 = load i8*, i8** %2
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = call double (...) @pop()
%18 = call i32 @cos(double %17)
%19 = call i32 @push(i32 %18)
br label %72
20: ; preds = %12
%21 = load i8*, i8** %2
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %20
%25 = call double (...) @pop()
%26 = call i32 @tan(double %25)
%27 = call i32 @push(i32 %26)
br label %71
28: ; preds = %20
%29 = load i8*, i8** %2
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = call double (...) @pop()
%34 = call i32 @exp(double %33)
%35 = call i32 @push(i32 %34)
br label %70
36: ; preds = %28
%37 = load i8*, i8** %2
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %58
40: ; preds = %36
%41 = call double (...) @pop()
store double %41, double* %3
%42 = call double (...) @pop()
store double %42, double* %4
%43 = load double, double* %4
%44 = fcmp oeq double %43, 0.000000e+00
br i1 %44, label %45, label %52
45: ; preds = %40
%46 = load double, double* %3
%47 = fcmp ole double %46, 0.000000e+00
br i1 %47, label %48, label %52
48: ; preds = %45
%49 = load double, double* %4
%50 = load double, double* %3
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), double %49, double %50)
br label %57
52: ; preds = %45, %40
%53 = load double, double* %4
%54 = load double, double* %3
%55 = call i32 @pow(double %53, double %54)
%56 = call i32 @push(i32 %55)
br label %57
57: ; preds = %52, %48
br label %69
58: ; preds = %36
%59 = load i8*, i8** %2
%60 = call i32 @strlen(i8* %59)
%61 = icmp eq i32 %60, 1
br i1 %61, label %62, label %65
62: ; preds = %58
%63 = load i8*, i8** %2
%64 = call i32 @process_variable(i8* %63)
br label %68
65: ; preds = %58
%66 = load i8*, i8** %2
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* %66)
br label %68
68: ; preds = %65, %62
br label %69
69: ; preds = %68, %57
br label %70
70: ; preds = %69, %32
br label %71
71: ; preds = %70, %24
br label %72
72: ; preds = %71, %16
br label %73
73: ; preds = %72, %8
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"sin\00"
@.str.1 = [4 x i8] c"cos\00"
@.str.2 = [4 x i8] c"tan\00"
@.str.3 = [4 x i8] c"exp\00"
@.str.4 = [4 x i8] c"pow\00"
@.str.5 = [30 x i8] c"error: trying to get '%f^%f'\0A\00"
@.str.6 = [29 x i8] c"error: unknown command '%s'\0A\00"
define void @process_function_or_variable(i8* %0) {
%2 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = tail call double (...) @pop()
%6 = tail call i32 @sin(double %5)
%7 = tail call i32 @push(i32 %6)
br label %50
8: ; preds = %1
%9 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = tail call double (...) @pop()
%13 = tail call i32 @cos(double %12)
%14 = tail call i32 @push(i32 %13)
br label %50
15: ; preds = %8
%16 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = tail call double (...) @pop()
%20 = tail call i32 @tan(double %19)
%21 = tail call i32 @push(i32 %20)
br label %50
22: ; preds = %15
%23 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = tail call double (...) @pop()
%27 = tail call i32 @exp(double %26)
%28 = tail call i32 @push(i32 %27)
br label %50
29: ; preds = %22
%30 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %43
32: ; preds = %29
%33 = tail call double (...) @pop()
%34 = tail call double (...) @pop()
%35 = fcmp oeq double %34, 0.000000e+00
%36 = fcmp ole double %33, 0.000000e+00
%37 = select i1 %35, i1 %36, i1 false
br i1 %37, label %38, label %40
38: ; preds = %32
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), double %34, double %33)
br label %50
40: ; preds = %32
%41 = tail call i32 @pow(double %34, double %33)
%42 = tail call i32 @push(i32 %41)
br label %50
43: ; preds = %29
%44 = tail call i32 @strlen(i8* %0)
%45 = icmp eq i32 %44, 1
br i1 %45, label %46, label %48
46: ; preds = %43
%47 = tail call i32 @process_variable(i8* %0)
br label %50
48: ; preds = %43
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* %0)
br label %50
50: ; preds = %38, %40, %11, %25, %46, %48, %18, %4
ret void
}