__attribute__((unused)) int str_to_int(const char *str) {
  char *ptr;
  int ret_code;
  if (str[0] == '\0')
    fatal2("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/raven-au/ovlfs/refs/heads/master/tools/"
           "file_test.c",
           __FUNCTION__, 172, "invalid number: value is empty");
  ret_code = strtol(str, &ptr, 0);
  if (ptr[0] != '\0')
    fatal2("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/raven-au/ovlfs/refs/heads/master/tools/"
           "file_test.c",
           __FUNCTION__, 177, "invalid number, '%s'", str);
  return ret_code;
}


x86 assembly (clang, -O0):
<str_to_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    115d <str_to_int+0x3d>
lea    0xebd(%rip),%rdi
lea    0xf43(%rip),%rsi
mov    $0xac,%edx
lea    0xf42(%rip),%rcx
mov    $0x0,%al
call   1030 <fatal2@plt>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11a4 <str_to_int+0x84>
mov    -0x8(%rbp),%r8
lea    0xe76(%rip),%rdi
lea    0xefc(%rip),%rsi
mov    $0xb1,%edx
lea    0xf1a(%rip),%rcx
mov    $0x0,%al
call   1030 <fatal2@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_to_int>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
jne    114d <str_to_int+0x2d>
lea    0xecd(%rip),%rdi
lea    0xf53(%rip),%rsi
lea    0xf57(%rip),%rcx
mov    $0xac,%edx
xor    %eax,%eax
call   1030 <fatal2@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %rax,%r14
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
je     118a <str_to_int+0x6a>
lea    0xe93(%rip),%rdi
lea    0xf19(%rip),%rsi
lea    0xf3c(%rip),%rcx
mov    $0xb1,%edx
mov    %rbx,%r8
xor    %eax,%eax
call   1030 <fatal2@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [141 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/raven-au/ovlfs/refs/heads/master/tools/file_test.c\00"
@__FUNCTION__.str_to_int = [11 x i8] c"str_to_int\00"
@.str.1 = [31 x i8] c"invalid number: value is empty\00"
@.str.2 = [21 x i8] c"invalid number, '%s'\00"
define i32 @str_to_int(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 (i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @fatal2 to i32 (i8*, i8*, i32, i8*, ...)*)(i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.str_to_int, i64 0, i64 0), i32 172, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %1
%13 = load i8*, i8** %2
%14 = call i64 @strtol(i8* %13, i8** %3, i32 0)
%15 = trunc i64 %14 to i32
store i32 %15, i32* %4
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %12
%22 = load i8*, i8** %2
%23 = call i32 (i8*, i8*, i32, i8*, i8*, ...) bitcast (i32 (...)* @fatal2 to i32 (i8*, i8*, i32, i8*, i8*, ...)*)(i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.str_to_int, i64 0, i64 0), i32 177, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %21, %12
%25 = load i32, i32* %4
ret i32 %25
}

LLVM IR (-O2):
@.str = [141 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/raven-au/ovlfs/refs/heads/master/tools/file_test.c\00"
@__FUNCTION__.str_to_int = [11 x i8] c"str_to_int\00"
@.str.1 = [31 x i8] c"invalid number: value is empty\00"
@.str.2 = [21 x i8] c"invalid number, '%s'\00"
define i32 @str_to_int(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 (i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @fatal2 to i32 (i8*, i8*, i32, i8*, ...)*)(i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.str_to_int, i64 0, i64 0), i32 172, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %6, %1
%9 = call i64 @strtol(i8* %0, i8** %2, i32 0)
%10 = load i8*, i8** %2
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %8
%14 = tail call i32 (i8*, i8*, i32, i8*, i8*, ...) bitcast (i32 (...)* @fatal2 to i32 (i8*, i8*, i32, i8*, i8*, ...)*)(i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.str_to_int, i64 0, i64 0), i32 177, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %15
15: ; preds = %13, %8
%16 = trunc i64 %9 to i32
ret i32 %16
}