#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ *strstr(char *, char *);
double strtod(char *, char **);
char *strtok(char *, char *);
double lookUpDoubleEntry(char *filename, char *entry, double df) {
  FILE *fp;
  fp = fopen(filename, "r");
  if (fp == NULL) {
    printf("\n [ERROR]   Unable to open file %s\n\n", filename);
    exit(0);
  }
  char re[100];
  while (fscanf(fp, "%s", re) == 1) {
    if (strcmp(entry, re) == 0) {
      if (fscanf(fp, "%s", re) == 1) {
        if (strstr(re, ";") != NULL) {
          char *token = strtok(re, ";");
          char *ptr;
          df = strtod(token, &ptr);
        }
      }
    }
  }
  fclose(fp);
  return df;
}


x86 assembly (clang, -O0):
<lookUpDoubleEntry>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe4d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11de <lookUpDoubleEntry+0x4e>
mov    -0x8(%rbp),%rsi
lea    0xe30(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
jmp    11e3 <lookUpDoubleEntry+0x53>
mov    -0x20(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    0xe32(%rip),%rsi
call   1060 <fscanf@plt>
cmp    $0x1,%eax
jne    129b <lookUpDoubleEntry+0x10b>
mov    -0x10(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1296 <lookUpDoubleEntry+0x106>
mov    -0x20(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    0xdf8(%rip),%rsi
call   1060 <fscanf@plt>
cmp    $0x1,%eax
jne    1291 <lookUpDoubleEntry+0x101>
lea    -0x90(%rbp),%rdi
lea    0xddf(%rip),%rsi
call   10b0 <strstr@plt>
cmp    $0x0,%rax
je     128c <lookUpDoubleEntry+0xfc>
lea    -0x90(%rbp),%rdi
lea    0xdc2(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    1291 <lookUpDoubleEntry+0x101>
jmp    1296 <lookUpDoubleEntry+0x106>
jmp    11e3 <lookUpDoubleEntry+0x53>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
movsd  -0x18(%rbp),%xmm0
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lookUpDoubleEntry>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
movsd  %xmm0,(%rsp)
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xe50(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1281 <lookUpDoubleEntry+0xf1>
mov    %rax,%r15
lea    0xe5f(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %rax,%rdi
call   1070 <fscanf@plt>
cmp    $0x1,%eax
jne    1265 <lookUpDoubleEntry+0xd5>
lea    0x10(%rsp),%rbx
lea    0xe3d(%rip),%r12
lea    0xe39(%rip),%r13
lea    0x8(%rsp),%rbp
jmp    1213 <lookUpDoubleEntry+0x83>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1070 <fscanf@plt>
cmp    $0x1,%eax
jne    1265 <lookUpDoubleEntry+0xd5>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1200 <lookUpDoubleEntry+0x70>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1070 <fscanf@plt>
cmp    $0x1,%eax
jne    1200 <lookUpDoubleEntry+0x70>
mov    %rbx,%rdi
mov    $0x3b,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1200 <lookUpDoubleEntry+0x70>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <strtok@plt>
mov    %rax,%rdi
mov    %rbp,%rsi
call   1030 <strtod@plt>
movsd  %xmm0,(%rsp)
jmp    1200 <lookUpDoubleEntry+0x70>
mov    %r15,%rdi
call   1040 <fclose@plt>
movsd  (%rsp),%xmm0
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd7a(%rip),%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [37 x i8] c"\0A [ERROR] Unable to open file %s\0A\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [2 x i8] c";\00"
define double @lookUpDoubleEntry(i8* %0, i8* %1, double %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca double
%7 = alloca i32*
%8 = alloca [100 x i8]
%9 = alloca i8*
%10 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store double %2, double* %6
%11 = load i8*, i8** %4
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %7
%13 = load i32*, i32** %7
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %19
15: ; preds = %3
%16 = load i8*, i8** %4
%17 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 0)
unreachable
19: ; preds = %3
br label %20
20: ; preds = %46, %19
%21 = load i32*, i32** %7
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%23 = call i32 @fscanf(i32* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %47
25: ; preds = %20
%26 = load i8*, i8** %5
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%28 = call i64 @strcmp(i8* %26, i8* %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %46
30: ; preds = %25
%31 = load i32*, i32** %7
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%33 = call i32 @fscanf(i32* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %32)
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %45
35: ; preds = %30
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%37 = call i32* @strstr(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%38 = icmp ne i32* %37, null
br i1 %38, label %39, label %44
39: ; preds = %35
%40 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%41 = call i8* @strtok(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %41, i8** %9
%42 = load i8*, i8** %9
%43 = call double @strtod(i8* %42, i8** %10)
store double %43, double* %6
br label %44
44: ; preds = %39, %35
br label %45
45: ; preds = %44, %30
br label %46
46: ; preds = %45, %25
br label %20
47: ; preds = %20
%48 = load i32*, i32** %7
%49 = call i32 @fclose(i32* %48)
%50 = load double, double* %6
ret double %50
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [37 x i8] c"\0A [ERROR] Unable to open file %s\0A\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [2 x i8] c";\00"
define double @lookUpDoubleEntry(i8* %0, i8* %1, double %2) {
%4 = alloca [100 x i8]
%5 = alloca i8*
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %3
%9 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%10 = tail call i32 @exit(i32 0)
unreachable
11: ; preds = %3
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%13 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %34
15: ; preds = %11
%16 = bitcast i8** %5 to i8*
br label %17
17: ; preds = %15, %30
%18 = phi double [ %2, %15 ], [ %31, %30 ]
%19 = call i64 @strcmp(i8* %1, i8* %12)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %30
24: ; preds = %21
%25 = call i8* @strchr(i8* %12, i32 59)
%26 = icmp eq i8* %25, null
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = call i8* @strtok(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%29 = call double @strtod(i8* %28, i8** %5)
br label %30
30: ; preds = %21, %27, %24, %17
%31 = phi double [ %29, %27 ], [ %18, %24 ], [ %18, %21 ], [ %18, %17 ]
%32 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%33 = icmp eq i32 %32, 1
br i1 %33, label %17, label %34
34: ; preds = %30, %11
%35 = phi double [ %2, %11 ], [ %31, %30 ]
%36 = call i32 @fclose(i32* %6)
ret double %35
}