#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 atof(char *);
unsigned int lookUpEntry(char *, char *, char **, unsigned int *);
unsigned int lookUpDouble(char *fileName, char *entry, double *val, double df) {
  unsigned int retval = 0, ns, status;
  char aux[10][100];
  status = lookUpEntry(fileName, entry, aux, &ns);
  if (status) {
    *val = atof(aux[0]);
    retval = 1;
  } else {
    *val = df;
  }
  return retval;
}


x86 assembly (clang, -O0):
<lookUpDouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x420(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1040 <lookUpEntry@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     1188 <lookUpDouble+0x68>
lea    -0x420(%rbp),%rdi
call   1030 <atof@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x24(%rbp)
jmp    1195 <lookUpDouble+0x75>
movsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x24(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lookUpDouble>:
push   %rbx
sub    $0x400,%rsp
movsd  %xmm0,(%rsp)
mov    %rdx,%rbx
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1040 <lookUpEntry@plt>
test   %eax,%eax
je     1154 <lookUpDouble+0x34>
lea    0x10(%rsp),%rdi
call   1030 <atof@plt>
mov    $0x1,%eax
jmp    115b <lookUpDouble+0x3b>
xor    %eax,%eax
movsd  (%rsp),%xmm0
movsd  %xmm0,(%rbx)
add    $0x400,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @lookUpDouble(i8* %0, i8* %1, double* %2, double %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca double*
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [10 x [100 x i8]]
store i8* %0, i8** %5
store i8* %1, i8** %6
store double* %2, double** %7
store double %3, double* %8
store i32 0, i32* %9
%13 = load i8*, i8** %5
%14 = load i8*, i8** %6
%15 = getelementptr inbounds [10 x [100 x i8]], [10 x [100 x i8]]* %12, i64 0, i64 0
%16 = bitcast [100 x i8]* %15 to i8**
%17 = call i32 @lookUpEntry(i8* %13, i8* %14, i8** %16, i32* %10)
store i32 %17, i32* %11
%18 = load i32, i32* %11
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %4
%21 = getelementptr inbounds [10 x [100 x i8]], [10 x [100 x i8]]* %12, i64 0, i64 0
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %21, i64 0, i64 0
%23 = call double @atof(i8* %22)
%24 = load double*, double** %7
store double %23, double* %24
store i32 1, i32* %9
br label %28
25: ; preds = %4
%26 = load double, double* %8
%27 = load double*, double** %7
store double %26, double* %27
br label %28
28: ; preds = %25, %20
%29 = load i32, i32* %9
ret i32 %29
}

LLVM IR (-O2):
define i32 @lookUpDouble(i8* %0, i8* %1, double* nocapture writeonly %2, double %3) {
%5 = alloca i32
%6 = alloca [10 x [100 x i8]]
%7 = bitcast i32* %5 to i8*
%8 = getelementptr inbounds [10 x [100 x i8]], [10 x [100 x i8]]* %6, i64 0, i64 0, i64 0
%9 = bitcast [10 x [100 x i8]]* %6 to i8**
%10 = call i32 @lookUpEntry(i8* %0, i8* %1, i8** %9, i32* %5)
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %4
%13 = call double @atof(i8* %8)
br label %14
14: ; preds = %4, %12
%15 = phi double [ %13, %12 ], [ %3, %4 ]
%16 = phi i32 [ 1, %12 ], [ 0, %4 ]
store double %15, double* %2
ret i32 %16
}