#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 */
scalar_t__ errno;
scalar_t__ is_nan_str(char const *);
int /*<<< orphan*/ my_err(char *, char *, int, char const *);
int /*<<< orphan*/ perror(char *);
double strtod(char const *, int /*<<< orphan*/ *);
double util_parse_double(const char *str) {
  double val;
  if (is_nan_str(str)) {
    return (0.0 / 0.0);
  }
  errno = 0;
  val = strtod(str, NULL);
  if (errno) {
    perror("strtod");
    my_err("%s:%d: failed to parse double string '%s'",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/bmvdgeijn/WASP/refs/heads/master/snp2h5/"
           "util.c",
           1156, str);
  }
  return val;
}


x86 assembly (clang, -O0):
<util_parse_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <is_nan_str@plt>
cmp    $0x0,%rax
je     1171 <util_parse_double+0x31>
movsd  0xe99(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11d4 <util_parse_double+0x94>
mov    0x2e68(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <strtod@plt>
movsd  %xmm0,-0x18(%rbp)
mov    0x2e48(%rip),%rax
cmpq   $0x0,(%rax)
je     11ca <util_parse_double+0x8a>
lea    0xe5f(%rip),%rdi
call   1040 <perror@plt>
mov    -0x10(%rbp),%rcx
lea    0xe56(%rip),%rdi
lea    0xe79(%rip),%rsi
mov    $0x484,%edx
call   1060 <my_err@plt>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<util_parse_double>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <is_nan_str@plt>
test   %rax,%rax
je     115b <util_parse_double+0x1b>
movsd  0xea7(%rip),%xmm0
jmp    1179 <util_parse_double+0x39>
mov    0x2e7e(%rip),%r14
movq   $0x0,(%r14)
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <strtod@plt>
cmpq   $0x0,(%r14)
jne    1181 <util_parse_double+0x41>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe80(%rip),%rdi
movsd  %xmm0,(%rsp)
call   1040 <perror@plt>
lea    0xe76(%rip),%rdi
lea    0xe99(%rip),%rsi
mov    $0x484,%edx
mov    %rbx,%rcx
call   1060 <my_err@plt>
movsd  (%rsp),%xmm0
jmp    1179 <util_parse_double+0x39>

LLVM IR (-O0):
@errno = global i64 0
@.str = [7 x i8] c"strtod\00"
@.str.1 = [42 x i8] c"%s:%d: failed to parse double string '%s'\00"
@.str.2 = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bmvdgeijn/WASP/refs/heads/master/snp2h5/util.c\00"
define double @util_parse_double(i8* %0) {
%2 = alloca double
%3 = alloca i8*
%4 = alloca double
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i64 @is_nan_str(i8* %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store double 0x7FF8000000000000, double* %2
br label %20
9: ; preds = %1
store i64 0, i64* @errno
%10 = load i8*, i8** %3
%11 = call double @strtod(i8* %10, i32* null)
store double %11, double* %4
%12 = load i64, i64* @errno
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %9
%15 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%16 = load i8*, i8** %3
%17 = call i32 @my_err(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.2, i64 0, i64 0), i32 1156, i8* %16)
br label %18
18: ; preds = %14, %9
%19 = load double, double* %4
store double %19, double* %2
br label %20
20: ; preds = %18, %8
%21 = load double, double* %2
ret double %21
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [7 x i8] c"strtod\00"
@.str.1 = [42 x i8] c"%s:%d: failed to parse double string '%s'\00"
@.str.2 = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bmvdgeijn/WASP/refs/heads/master/snp2h5/util.c\00"
define double @util_parse_double(i8* %0) {
%2 = tail call i64 @is_nan_str(i8* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %11
4: ; preds = %1
store i64 0, i64* @errno
%5 = tail call double @strtod(i8* nocapture %0, i32* null)
%6 = load i64, i64* @errno
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %4
%9 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @my_err(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.2, i64 0, i64 0), i32 1156, i8* %0)
br label %11
11: ; preds = %4, %8, %1
%12 = phi double [ 0x7FF8000000000000, %1 ], [ %5, %8 ], [ %5, %4 ]
ret double %12
}