#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*/ exit(int);
int /*<<< orphan*/ printf(char *, char const *);
scalar_t__ strcmp(char const *, char *);
void printFunction(const char *funname) {
  char *func;
  if (strcmp(funname, "poly") == 0)
    func = "y = x^2 - 4 = 0";
  else if (strcmp(funname, "cos") == 0)
    func = "y = cos(x) - x^3 = 0";
  else if (strcmp(funname, "sin") == 0)
    func = "y = sin(x)-.5 = 0";
  else if (strcmp(funname, "xsin") == 0)
    func = "y = x*sin(x)-10 = 0";
  else if (strcmp(funname, "imaginary") == 0)
    func = "y = x^2+1 = 0";
  else {
    printf("Error: %s is not a valid function name\n", funname);
    exit(1);
  }
  printf("Function: %s\n", func);
}


x86 assembly (clang, -O0):
<printFunction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1166 <printFunction+0x36>
lea    0xea8(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    123c <printFunction+0x10c>
mov    -0x8(%rbp),%rdi
lea    0xea4(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1190 <printFunction+0x60>
lea    0xe92(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1237 <printFunction+0x107>
mov    -0x8(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ba <printFunction+0x8a>
lea    0xe7d(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1232 <printFunction+0x102>
mov    -0x8(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11e4 <printFunction+0xb4>
lea    0xe6a(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    122d <printFunction+0xfd>
mov    -0x8(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    120e <printFunction+0xde>
lea    0xe5e(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1228 <printFunction+0xf8>
mov    -0x8(%rbp),%rsi
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    122d <printFunction+0xfd>
jmp    1232 <printFunction+0x102>
jmp    1237 <printFunction+0x107>
jmp    123c <printFunction+0x10c>
mov    -0x10(%rbp),%rsi
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printFunction>:
push   %rbx
mov    %rdi,%rbx
lea    0xec5(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     119e <printFunction+0x6e>
lea    0xec9(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11a7 <printFunction+0x77>
lea    0xee1(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11b0 <printFunction+0x80>
lea    0xecc(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11b9 <printFunction+0x89>
lea    0xed1(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11cd <printFunction+0x9d>
lea    0xec7(%rip),%rsi
jmp    11c0 <printFunction+0x90>
lea    0xe60(%rip),%rsi
jmp    11c0 <printFunction+0x90>
lea    0xe6b(%rip),%rsi
jmp    11c0 <printFunction+0x90>
lea    0xe77(%rip),%rsi
jmp    11c0 <printFunction+0x90>
lea    0xe85(%rip),%rsi
lea    0xed2(%rip),%rdi
pop    %rbx
jmp    1030 <printf@plt>
lea    0xe9d(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"poly\00"
@.str.1 = [16 x i8] c"y = x^2 - 4 = 0\00"
@.str.2 = [4 x i8] c"cos\00"
@.str.3 = [21 x i8] c"y = cos(x) - x^3 = 0\00"
@.str.4 = [4 x i8] c"sin\00"
@.str.5 = [18 x i8] c"y = sin(x)-.5 = 0\00"
@.str.6 = [5 x i8] c"xsin\00"
@.str.7 = [20 x i8] c"y = x*sin(x)-10 = 0\00"
@.str.8 = [10 x i8] c"imaginary\00"
@.str.9 = [14 x i8] c"y = x^2+1 = 0\00"
@.str.10 = [40 x i8] c"Error: %s is not a valid function name\0A\00"
@.str.11 = [14 x i8] c"Function: %s\0A\00"
define void @printFunction(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %36
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %35
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %34
18: ; preds = %13
%19 = load i8*, i8** %2
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %33
23: ; preds = %18
%24 = load i8*, i8** %2
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8** %3
br label %32
28: ; preds = %23
%29 = load i8*, i8** %2
%30 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.10, i64 0, i64 0), i8* %29)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %27
br label %33
33: ; preds = %32, %22
br label %34
34: ; preds = %33, %17
br label %35
35: ; preds = %34, %12
br label %36
36: ; preds = %35, %7
%37 = load i8*, i8** %3
%38 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8* %37)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"poly\00"
@.str.1 = [16 x i8] c"y = x^2 - 4 = 0\00"
@.str.2 = [4 x i8] c"cos\00"
@.str.3 = [21 x i8] c"y = cos(x) - x^3 = 0\00"
@.str.4 = [4 x i8] c"sin\00"
@.str.5 = [18 x i8] c"y = sin(x)-.5 = 0\00"
@.str.6 = [5 x i8] c"xsin\00"
@.str.7 = [20 x i8] c"y = x*sin(x)-10 = 0\00"
@.str.8 = [10 x i8] c"imaginary\00"
@.str.9 = [14 x i8] c"y = x^2+1 = 0\00"
@.str.10 = [40 x i8] c"Error: %s is not a valid function name\0A\00"
@.str.11 = [14 x i8] c"Function: %s\0A\00"
define void @printFunction(i8* %0) {
%2 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %19, label %4
4: ; preds = %1
%5 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %19, label %7
7: ; preds = %4
%8 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %7
%11 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %10
%14 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = tail call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.10, i64 0, i64 0), i8* %0)
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %13, %10, %7, %4, %1
%20 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), %1 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), %7 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), %10 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), %13 ]
%21 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8* %20)
ret void
}