#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*/ errhandler(int, char *, char *);
char *find_string(char const *, char const *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char const *, char const *,
                           ...);
scalar_t__ sscanf(char *, char *, double *);
void read_double(const char *szFileName, const char *szVarName,
                 double *pVariable) {
  char *szValue = NULL;
  if (szVarName == 0)
    errhandler(
        203,
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/grantathon/computational_fluid_dynamics/"
        "refs/heads/master/project/ns_sim_parallel/helper.c",
        "null pointer given as varable name");
  if (szFileName == 0)
    errhandler(
        204,
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/grantathon/computational_fluid_dynamics/"
        "refs/heads/master/project/ns_sim_parallel/helper.c",
        "null pointer given as filename");
  if (pVariable == 0)
    errhandler(
        205,
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/grantathon/computational_fluid_dynamics/"
        "refs/heads/master/project/ns_sim_parallel/helper.c",
        "null pointer given as variable");
  if (szVarName[0] == '*')
    szValue = find_string(szFileName, szVarName + 1);
  else
    szValue = find_string(szFileName, szVarName);
  if (sscanf(szValue, "%lf", pVariable) == 0) {
    char szTmp[80];
    if (0)
      sprintf(szTmp, " %s  File: %s   Variable: %s  Line: %d", "wrong format",
              szFileName, szVarName, 0);
    else
      sprintf(szTmp, " %s  File: %s   Variable: %s ", "wrong format",
              szFileName, szVarName);
    errhandler(
        213,
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/grantathon/computational_fluid_dynamics/"
        "refs/heads/master/project/ns_sim_parallel/helper.c",
        szTmp);
  };
}


x86 assembly (clang, -O0):
<read_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117f <read_double+0x3f>
mov    $0xcb,%edi
lea    0xe8d(%rip),%rsi
lea    0xf3b(%rip),%rdx
call   1030 <errhandler@plt>
cmpq   $0x0,-0x8(%rbp)
jne    11a2 <read_double+0x62>
mov    $0xcc,%edi
lea    0xe6a(%rip),%rsi
lea    0xf3b(%rip),%rdx
call   1030 <errhandler@plt>
cmpq   $0x0,-0x18(%rbp)
jne    11c5 <read_double+0x85>
mov    $0xcd,%edi
lea    0xe47(%rip),%rsi
lea    0xf37(%rip),%rdx
call   1030 <errhandler@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
jne    11ef <read_double+0xaf>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
call   1060 <find_string@plt>
mov    %rax,-0x20(%rbp)
jmp    1200 <read_double+0xc0>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <find_string@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xf07(%rip),%rsi
call   1040 <sscanf@plt>
cmp    $0x0,%rax
jne    1254 <read_double+0x114>
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0xee9(%rip),%rsi
lea    0xf00(%rip),%rdx
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x70(%rbp),%rdx
mov    $0xd5,%edi
lea    0xdb1(%rip),%rsi
call   1030 <errhandler@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_double>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
test   %rsi,%rsi
je     11d3 <read_double+0x93>
test   %r14,%r14
je     11f4 <read_double+0xb4>
test   %r15,%r15
je     1215 <read_double+0xd5>
xor    %esi,%esi
cmpb   $0x2a,(%rbx)
sete   %sil
add    %rbx,%rsi
mov    %r14,%rdi
call   1060 <find_string@plt>
lea    0xf92(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
call   1040 <sscanf@plt>
test   %rax,%rax
jne    11c9 <read_double+0x89>
lea    0xf7f(%rip),%rsi
lea    0xf96(%rip),%rdx
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r14,%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   1050 <sprintf@plt>
lea    0xe44(%rip),%rsi
mov    $0xd5,%edi
mov    %r15,%rdx
call   1030 <errhandler@plt>
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe26(%rip),%rsi
lea    0xed4(%rip),%rdx
mov    $0xcb,%edi
call   1030 <errhandler@plt>
test   %r14,%r14
jne    1160 <read_double+0x20>
lea    0xe05(%rip),%rsi
lea    0xed6(%rip),%rdx
mov    $0xcc,%edi
call   1030 <errhandler@plt>
test   %r15,%r15
jne    1169 <read_double+0x29>
lea    0xde4(%rip),%rsi
lea    0xed4(%rip),%rdx
mov    $0xcd,%edi
call   1030 <errhandler@plt>
jmp    1169 <read_double+0x29>

LLVM IR (-O0):
@.str = [181 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/grantathon/computational_fluid_dynamics/refs/heads/master/project/ns_sim_parallel/helper.c\00"
@.str.1 = [35 x i8] c"null pointer given as varable name\00"
@.str.2 = [31 x i8] c"null pointer given as filename\00"
@.str.3 = [31 x i8] c"null pointer given as variable\00"
@.str.4 = [4 x i8] c"%lf\00"
@.str.5 = [30 x i8] c" %s File: %s Variable: %s \00"
@.str.6 = [13 x i8] c"wrong format\00"
define void @read_double(i8* %0, i8* %1, double* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca double*
%7 = alloca i8*
%8 = alloca [80 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store double* %2, double** %6
store i8* null, i8** %7
%9 = load i8*, i8** %5
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i32 @errhandler(i32 203, i8* getelementptr inbounds ([181 x i8], [181 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %3
%14 = load i8*, i8** %4
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 @errhandler(i32 204, i8* getelementptr inbounds ([181 x i8], [181 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
%19 = load double*, double** %6
%20 = icmp eq double* %19, null
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 @errhandler(i32 205, i8* getelementptr inbounds ([181 x i8], [181 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %21, %18
%24 = load i8*, i8** %5
%25 = getelementptr inbounds i8, i8* %24, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 42
br i1 %28, label %29, label %34
29: ; preds = %23
%30 = load i8*, i8** %4
%31 = load i8*, i8** %5
%32 = getelementptr inbounds i8, i8* %31, i64 1
%33 = call i8* @find_string(i8* %30, i8* %32)
store i8* %33, i8** %7
br label %38
34: ; preds = %23
%35 = load i8*, i8** %4
%36 = load i8*, i8** %5
%37 = call i8* @find_string(i8* %35, i8* %36)
store i8* %37, i8** %7
br label %38
38: ; preds = %34, %29
%39 = load i8*, i8** %7
%40 = load double*, double** %6
%41 = call i64 @sscanf(i8* %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %50
43: ; preds = %38
%44 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%45 = load i8*, i8** %4
%46 = load i8*, i8** %5
%47 = call i32 (i8*, i8*, i8*, i8*, i8*, ...) @sprintf(i8* %44, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %45, i8* %46)
%48 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%49 = call i32 @errhandler(i32 213, i8* getelementptr inbounds ([181 x i8], [181 x i8]* @.str, i64 0, i64 0), i8* %48)
br label %50
50: ; preds = %43, %38
ret void
}

LLVM IR (-O2):
@.str = [181 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/grantathon/computational_fluid_dynamics/refs/heads/master/project/ns_sim_parallel/helper.c\00"
@.str.1 = [35 x i8] c"null pointer given as varable name\00"
@.str.2 = [31 x i8] c"null pointer given as filename\00"
@.str.3 = [31 x i8] c"null pointer given as variable\00"
@.str.4 = [4 x i8] c"%lf\00"
@.str.5 = [30 x i8] c" %s File: %s Variable: %s \00"
@.str.6 = [13 x i8] c"wrong format\00"
define void @read_double(i8* %0, i8* %1, double* %2) {
%4 = alloca [80 x i8]
%5 = icmp eq i8* %1, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @errhandler(i32 203, i8* getelementptr inbounds ([181 x i8], [181 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %6, %3
%9 = icmp eq i8* %0, null
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = tail call i32 @errhandler(i32 204, i8* getelementptr inbounds ([181 x i8], [181 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
%13 = icmp eq double* %2, null
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = tail call i32 @errhandler(i32 205, i8* getelementptr inbounds ([181 x i8], [181 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %16
16: ; preds = %14, %12
%17 = load i8, i8* %1
%18 = icmp eq i8 %17, 42
%19 = zext i1 %18 to i64
%20 = getelementptr i8, i8* %1, i64 %19
%21 = tail call i8* @find_string(i8* %0, i8* %20)
%22 = tail call i64 @sscanf(i8* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %2)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %16
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%26 = call i32 (i8*, i8*, i8*, i8*, i8*, ...) @sprintf(i8* %25, i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %0, i8* %1)
%27 = call i32 @errhandler(i32 213, i8* getelementptr inbounds ([181 x i8], [181 x i8]* @.str, i64 0, i64 0), i8* %25)
br label %28
28: ; preds = %24, %16
ret void
}