#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 */
double INFINITY;
scalar_t__ RAND_MAX;
unsigned int rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ strcmp(char *, char *);
scalar_t__ time(int /*<<< orphan*/ *);
double getSymbol(char *s) {
  if (strcmp(s, "e") == 0)
    return 2.7182818284590452354;
  if (strcmp(s, "pi") == 0)
    return 3.14159265358979323846;
  if (strcmp(s, "inf") == 0)
    return INFINITY;
  if (strcmp(s, "rand") == 0) {
    srand((unsigned)time(NULL) + rand());
    return (double)rand() / (double)RAND_MAX;
  }
  if (strcmp(s, "g") == 0)
    return 1.6180339887498948482;
}


x86 assembly (clang, -O0):
<getSymbol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec1(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1178 <getSymbol+0x38>
movsd  0xea2(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1264 <getSymbol+0x124>
mov    -0x10(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11a4 <getSymbol+0x64>
movsd  0xe6e(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1264 <getSymbol+0x124>
mov    -0x10(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11d3 <getSymbol+0x93>
mov    0x2e23(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1264 <getSymbol+0x124>
mov    -0x10(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    123d <getSymbol+0xfd>
xor    %eax,%eax
mov    %eax,-0x1c(%rbp)
mov    %eax,%edi
call   1050 <time@plt>
mov    %rax,%rcx
mov    -0x1c(%rbp),%eax
mov    %ecx,-0x18(%rbp)
mov    %al,-0x11(%rbp)
call   1060 <rand@plt>
mov    -0x18(%rbp),%edi
add    %eax,%edi
call   1030 <srand@plt>
mov    -0x11(%rbp),%al
call   1060 <rand@plt>
mov    %eax,%eax
cvtsi2sd %rax,%xmm0
mov    0x2db6(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1264 <getSymbol+0x124>
mov    -0x10(%rbp),%rdi
lea    0xdde(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1264 <getSymbol+0x124>
movsd  0xda1(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getSymbol>:
push   %rbx
mov    %rdi,%rbx
lea    0xecd(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11aa <getSymbol+0x6a>
lea    0xebe(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11b4 <getSymbol+0x74>
lea    0xead(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11be <getSymbol+0x7e>
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11cb <getSymbol+0x8b>
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
movsd  0xe68(%rip),%xmm0
pop    %rbx
ret
movsd  0xe4e(%rip),%xmm0
pop    %rbx
ret
movsd  0xe4c(%rip),%xmm0
pop    %rbx
ret
mov    0x2e23(%rip),%rax
movsd  (%rax),%xmm0
pop    %rbx
ret
xor    %edi,%edi
call   1050 <time@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1060 <rand@plt>
add    %eax,%ebx
mov    %ebx,%edi
call   1030 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%eax
cvtsi2sd %rax,%xmm0
mov    0x2de6(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"e\00"
@.str.1 = [3 x i8] c"pi\00"
@.str.2 = [4 x i8] c"inf\00"
@INFINITY = global double 0.000000e+00
@.str.3 = [5 x i8] c"rand\00"
@RAND_MAX = global i64 0
@.str.4 = [2 x i8] c"g\00"
define double @getSymbol(i8* %0) {
%2 = alloca double
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store double 0x4005BF0A8B145769, double* %2
br label %39
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store double 0x400921FB54442D18, double* %2
br label %39
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = load double, double* @INFINITY
store double %18, double* %2
br label %39
19: ; preds = %13
%20 = load i8*, i8** %3
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %34
23: ; preds = %19
%24 = call i64 @time(i32* null)
%25 = trunc i64 %24 to i32
%26 = call i32 (...) @rand()
%27 = add i32 %25, %26
%28 = call i32 @srand(i32 %27)
%29 = call i32 (...) @rand()
%30 = uitofp i32 %29 to double
%31 = load i64, i64* @RAND_MAX
%32 = sitofp i64 %31 to double
%33 = fdiv double %30, %32
store double %33, double* %2
br label %39
34: ; preds = %19
%35 = load i8*, i8** %3
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %34
store double 0x3FF9E3779B97F4A8, double* %2
br label %39
39: ; preds = %7, %12, %17, %23, %38, %34
%40 = load double, double* %2
ret double %40
}

LLVM IR (-O2):
@.str = [2 x i8] c"e\00"
@.str.1 = [3 x i8] c"pi\00"
@.str.2 = [4 x i8] c"inf\00"
@INFINITY = global double 0.000000e+00
@.str.3 = [5 x i8] c"rand\00"
@RAND_MAX = global i64 0
@.str.4 = [2 x i8] c"g\00"
define double @getSymbol(i8* %0) {
%2 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %28, label %4
4: ; preds = %1
%5 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %28, label %7
7: ; preds = %4
%8 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = load double, double* @INFINITY
br label %28
12: ; preds = %7
%13 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %12
%16 = tail call i64 @time(i32* null)
%17 = trunc i64 %16 to i32
%18 = tail call i32 (...) @rand()
%19 = add i32 %18, %17
%20 = tail call i32 @srand(i32 %19)
%21 = tail call i32 (...) @rand()
%22 = uitofp i32 %21 to double
%23 = load i64, i64* @RAND_MAX
%24 = sitofp i64 %23 to double
%25 = fdiv double %22, %24
br label %28
26: ; preds = %12
%27 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %28
28: ; preds = %26, %4, %1, %10, %15
%29 = phi double [ %11, %10 ], [ %25, %15 ], [ 0x4005BF0A8B145769, %1 ], [ 0x400921FB54442D18, %4 ], [ 0x3FF9E3779B97F4A8, %26 ]
ret double %29
}