#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 *, char *);
int /*<<< orphan*/ push(int /*<<< orphan*/);
int /*<<< orphan*/ sin(double);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ tan(double);
void MathFunctions(char s[]) {
  double op2 = 0;
  if (strcmp(s, "sin") == 0)
    push(sin(pop()));
  else if (strcmp(s, "cos") == 0)
    push(cos(pop()));
  else if (strcmp(s, "tan") == 0)
    push(tan(pop()));
  else if (strcmp(s, "exp") == 0)
    push(exp(pop()));
  else if (strcmp(s, "pow") == 0) {
    op2 = pop();
    push(pow(pop(), op2));
  } else {
    printf("%s is not a supported function.\n", s);
  }
}


x86 assembly (clang, -O0):
<MathFunctions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11d6 <MathFunctions+0x46>
mov    $0x0,%al
call   1040 <pop@plt>
call   1060 <sin@plt>
mov    %eax,%edi
call   10a0 <push@plt>
jmp    12d3 <MathFunctions+0x143>
mov    -0x8(%rbp),%rdi
lea    0xe23(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1208 <MathFunctions+0x78>
mov    $0x0,%al
call   1040 <pop@plt>
call   1090 <cos@plt>
mov    %eax,%edi
call   10a0 <push@plt>
jmp    12ce <MathFunctions+0x13e>
mov    -0x8(%rbp),%rdi
lea    0xdf5(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    123a <MathFunctions+0xaa>
mov    $0x0,%al
call   1040 <pop@plt>
call   1080 <tan@plt>
mov    %eax,%edi
call   10a0 <push@plt>
jmp    12c9 <MathFunctions+0x139>
mov    -0x8(%rbp),%rdi
lea    0xdc7(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    126c <MathFunctions+0xdc>
mov    $0x0,%al
call   1040 <pop@plt>
call   1070 <exp@plt>
mov    %eax,%edi
call   10a0 <push@plt>
jmp    12c4 <MathFunctions+0x134>
mov    -0x8(%rbp),%rdi
lea    0xd99(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12af <MathFunctions+0x11f>
mov    $0x0,%al
call   1040 <pop@plt>
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <pop@plt>
movsd  -0x10(%rbp),%xmm1
call   10b0 <pow@plt>
mov    %eax,%edi
call   10a0 <push@plt>
jmp    12bf <MathFunctions+0x12f>
mov    -0x8(%rbp),%rsi
lea    0xd5a(%rip),%rdi
call   1030 <printf@plt>
jmp    12c4 <MathFunctions+0x134>
jmp    12c9 <MathFunctions+0x139>
jmp    12ce <MathFunctions+0x13e>
jmp    12d3 <MathFunctions+0x143>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MathFunctions>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xe61(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     120d <MathFunctions+0x7d>
lea    0xe54(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     121b <MathFunctions+0x8b>
lea    0xe44(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1229 <MathFunctions+0x99>
lea    0xe34(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1237 <MathFunctions+0xa7>
lea    0xe24(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1245 <MathFunctions+0xb5>
lea    0xe14(%rip),%rdi
mov    %rbx,%rsi
add    $0x10,%rsp
pop    %rbx
jmp    1030 <printf@plt>
xor    %eax,%eax
call   1040 <pop@plt>
call   1060 <sin@plt>
jmp    1264 <MathFunctions+0xd4>
xor    %eax,%eax
call   1040 <pop@plt>
call   1090 <cos@plt>
jmp    1264 <MathFunctions+0xd4>
xor    %eax,%eax
call   1040 <pop@plt>
call   1080 <tan@plt>
jmp    1264 <MathFunctions+0xd4>
xor    %eax,%eax
call   1040 <pop@plt>
call   1070 <exp@plt>
jmp    1264 <MathFunctions+0xd4>
xor    %eax,%eax
call   1040 <pop@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1040 <pop@plt>
movsd  0x8(%rsp),%xmm1
call   10b0 <pow@plt>
mov    %eax,%edi
add    $0x10,%rsp
pop    %rbx
jmp    10a0 <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 = [33 x i8] c"%s is not a supported function.\0A\00"
define void @MathFunctions(i8* %0) {
%2 = alloca i8*
%3 = alloca double
store i8* %0, i8** %2
store double 0.000000e+00, double* %3
%4 = load i8*, i8** %2
%5 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = call double (...) @pop()
%9 = call i32 @sin(double %8)
%10 = call i32 @push(i32 %9)
br label %52
11: ; preds = %1
%12 = load i8*, i8** %2
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = call double (...) @pop()
%17 = call i32 @cos(double %16)
%18 = call i32 @push(i32 %17)
br label %51
19: ; preds = %11
%20 = load i8*, i8** %2
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = call double (...) @pop()
%25 = call i32 @tan(double %24)
%26 = call i32 @push(i32 %25)
br label %50
27: ; preds = %19
%28 = load i8*, i8** %2
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = call double (...) @pop()
%33 = call i32 @exp(double %32)
%34 = call i32 @push(i32 %33)
br label %49
35: ; preds = %27
%36 = load i8*, i8** %2
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %45
39: ; preds = %35
%40 = call double (...) @pop()
store double %40, double* %3
%41 = call double (...) @pop()
%42 = load double, double* %3
%43 = call i32 @pow(double %41, double %42)
%44 = call i32 @push(i32 %43)
br label %48
45: ; preds = %35
%46 = load i8*, i8** %2
%47 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %46)
br label %48
48: ; preds = %45, %39
br label %49
49: ; preds = %48, %31
br label %50
50: ; preds = %49, %23
br label %51
51: ; preds = %50, %15
br label %52
52: ; preds = %51, %7
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 = [33 x i8] c"%s is not a supported function.\0A\00"
define void @MathFunctions(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 %39
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 %39
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 %39
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 %39
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 %37
32: ; preds = %29
%33 = tail call double (...) @pop()
%34 = tail call double (...) @pop()
%35 = tail call i32 @pow(double %34, double %33)
%36 = tail call i32 @push(i32 %35)
br label %39
37: ; preds = %29
%38 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %0)
br label %39
39: ; preds = %11, %25, %37, %32, %18, %4
ret void
}