#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;
int /*<<< orphan*/ my_err(char *, char *, int, char const *);
int /*<<< orphan*/ perror(char *);
long strtol(char const *, int /*<<< orphan*/ *, int);
long util_parse_long(const char *str) {
  long val;
  errno = 0;
  val = strtol(str, NULL, 10);
  if (val == 0 && errno) {
    perror("strtol");
    my_err("%s:%d: failed to parse long 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",
           1110, str);
  }
  return val;
}


x86 assembly (clang, -O0):
<util_parse_long>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e9d(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11a4 <util_parse_long+0x74>
mov    0x2e6e(%rip),%rax
cmpq   $0x0,(%rax)
je     11a4 <util_parse_long+0x74>
lea    0xe7d(%rip),%rdi
call   1040 <perror@plt>
mov    -0x8(%rbp),%rcx
lea    0xe74(%rip),%rdi
lea    0xe95(%rip),%rsi
mov    $0x456,%edx
call   1050 <my_err@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<util_parse_long>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    0x2ea1(%rip),%r15
movq   $0x0,(%r15)
xor    %esi,%esi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1160 <util_parse_long+0x30>
cmpq   $0x0,(%r15)
jne    1169 <util_parse_long+0x39>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe90(%rip),%rdi
call   1040 <perror@plt>
lea    0xe8b(%rip),%rdi
lea    0xeac(%rip),%rsi
mov    $0x456,%edx
mov    %r14,%rcx
call   1050 <my_err@plt>
jmp    1160 <util_parse_long+0x30>

LLVM IR (-O0):
@errno = global i64 0
@.str = [7 x i8] c"strtol\00"
@.str.1 = [40 x i8] c"%s:%d: failed to parse long 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 i64 @util_parse_long(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
store i8* %0, i8** %2
store i64 0, i64* @errno
%4 = load i8*, i8** %2
%5 = call i64 @strtol(i8* %4, i32* null, i32 10)
store i64 %5, i64* %3
%6 = load i64, i64* %3
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %1
%9 = load i64, i64* @errno
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%13 = load i8*, i8** %2
%14 = call i32 @my_err(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.2, i64 0, i64 0), i32 1110, i8* %13)
br label %15
15: ; preds = %11, %8, %1
%16 = load i64, i64* %3
ret i64 %16
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [7 x i8] c"strtol\00"
@.str.1 = [40 x i8] c"%s:%d: failed to parse long 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 i64 @util_parse_long(i8* %0) {
store i64 0, i64* @errno
%2 = tail call i64 @strtol(i8* nocapture %0, i32* null, i32 10)
%3 = icmp eq i64 %2, 0
%4 = load i64, i64* @errno
%5 = icmp ne i64 %4, 0
%6 = select i1 %3, i1 %5, i1 false
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @my_err(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.2, i64 0, i64 0), i32 1110, i8* %0)
br label %10
10: ; preds = %7, %1
ret i64 %2
}