#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *createFile(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ printf(char *, double, double);
int /*<<< orphan*/ strtod(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ testCase(int /*<<< orphan*/, double *, double *, double *,
                            double *, int /*<<< orphan*/ *);
void selecttest() {
  double worstSpeed = 0, indexSpeed, worstError = 0, indexError, tmp;
  FILE *in;
  in = fopen("SelectionInput.txt", "r");
  FILE *fp;
  fp = createFile("Select_Test_");
  fprintf(fp, "Test Var,Our Output,Std Output,The Deviation Was,");
  fprintf(fp, "Our Output (in ms),Std Output (in ms),We Took X Ms Longer\n");
  char entry[1000];
  while (fgets(entry, 1000, in) != NULL) {
    testCase(strtod(entry, NULL), &worstSpeed, &indexSpeed, &worstError,
             &indexError, fp);
  }
  fclose(fp);
  printf("The worst diviation from the c sinh function is %e with input %e\n",
         worstError, indexError);
}


x86 assembly (clang, -O0):
<selecttest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    0xe5e(%rip),%rdi
lea    0xe6a(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
lea    0xe5c(%rip),%rdi
call   1060 <createFile@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x38(%rbp),%rdi
lea    0xe77(%rip),%rsi
call   1080 <fprintf@plt>
lea    -0x420(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    $0x3e8,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     1231 <selecttest+0xb1>
lea    -0x420(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <strtod@plt>
mov    %eax,%edi
mov    -0x38(%rbp),%r9
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rcx
lea    -0x20(%rbp),%r8
call   1090 <testCase@plt>
jmp    11e2 <selecttest+0x62>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xe44(%rip),%rdi
call   1050 <printf@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<selecttest>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
movq   $0x0,0x10(%rsp)
movq   $0x0,(%rsp)
lea    0xe57(%rip),%rdi
lea    0xe63(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r14
lea    0xe56(%rip),%rdi
call   1060 <createFile@plt>
mov    %rax,%r15
lea    0xe54(%rip),%rdi
mov    $0x31,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10a0 <fwrite@plt>
lea    0xe6d(%rip),%rdi
mov    $0x3a,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10a0 <fwrite@plt>
lea    0x20(%rsp),%rdi
mov    $0x3e8,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1267 <selecttest+0xe7>
lea    0x20(%rsp),%rbx
lea    0x18(%rsp),%r13
mov    %rsp,%rbp
lea    0x8(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <strtod@plt>
mov    %eax,%edi
lea    0x10(%rsp),%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
mov    %r12,%r8
mov    %r15,%r9
call   1080 <testCase@plt>
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
jne    1230 <selecttest+0xb0>
mov    %r15,%rdi
call   1040 <fclose@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
lea    0xe0e(%rip),%rdi
call   1050 <printf@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"SelectionInput.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [13 x i8] c"Select_Test_\00"
@.str.3 = [50 x i8] c"Test Var,Our Output,Std Output,The Deviation Was,\00"
@.str.4 = [59 x i8] c"Our Output (in ms),Std Output (in ms),We Took X Ms Longer\0A\00"
@.str.5 = [66 x i8] c"The worst diviation from the c sinh function is %e with input %e\0A\00"
define void @selecttest() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [1000 x i8]
store double 0.000000e+00, double* %1
store double 0.000000e+00, double* %3
%9 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %6
%10 = call i32* @createFile(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
store i32* %10, i32** %7
%11 = load i32*, i32** %7
%12 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%13 = load i32*, i32** %7
%14 = call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0))
br label %15
15: ; preds = %20, %0
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%17 = load i32*, i32** %6
%18 = call i32* @fgets(i8* %16, i32 1000, i32* %17)
%19 = icmp ne i32* %18, null
br i1 %19, label %20, label %25
20: ; preds = %15
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%22 = call i32 @strtod(i8* %21, i32* null)
%23 = load i32*, i32** %7
%24 = call i32 @testCase(i32 %22, double* %1, double* %2, double* %3, double* %4, i32* %23)
br label %15
25: ; preds = %15
%26 = load i32*, i32** %7
%27 = call i32 @fclose(i32* %26)
%28 = load double, double* %3
%29 = load double, double* %4
%30 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.5, i64 0, i64 0), double %28, double %29)
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"SelectionInput.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [13 x i8] c"Select_Test_\00"
@.str.3 = [50 x i8] c"Test Var,Our Output,Std Output,The Deviation Was,\00"
@.str.4 = [59 x i8] c"Our Output (in ms),Std Output (in ms),We Took X Ms Longer\0A\00"
@.str.5 = [66 x i8] c"The worst diviation from the c sinh function is %e with input %e\0A\00"
define void @selecttest() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca [1000 x i8]
%6 = bitcast double* %1 to i8*
store double 0.000000e+00, double* %1
%7 = bitcast double* %2 to i8*
%8 = bitcast double* %3 to i8*
store double 0.000000e+00, double* %3
%9 = bitcast double* %4 to i8*
%10 = tail call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32* @createFile(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0), i64 49, i64 1, i32* %11)
%13 = tail call i64 @fwrite(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0), i64 58, i64 1, i32* %11)
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%15 = call i32* @fgets(i8* %14, i32 1000, i32* %10)
%16 = icmp eq i32* %15, null
br i1 %16, label %22, label %17
17: ; preds = %0, %17
%18 = call i32 @strtod(i8* nocapture %14, i32* null)
%19 = call i32 @testCase(i32 %18, double* %1, double* %2, double* %3, double* %4, i32* %11)
%20 = call i32* @fgets(i8* %14, i32 1000, i32* %10)
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %17
22: ; preds = %17, %0
%23 = call i32 @fclose(i32* %11)
%24 = load double, double* %3
%25 = load double, double* %4
%26 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.5, i64 0, i64 0), double %24, double %25)
ret void
}