#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 */
typedef int uint32_t;

/* Variables and functions */
int INT_MAX;
int INT_MIN;
int /*<<< orphan*/ printf(char *, char *, int);
int safe_atoi(int *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
uint32_t test_safe_atoi() {
  uint32_t errs = 0;
  int rv = 0;
  int intret = 0;
  int testval = 0;
  char testvalstr[50] = {0};
  rv = safe_atoi(NULL, NULL);
  if (rv == 0) {
    printf("Error: False Positive %s:%d\n",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/nolandda/misc/refs/heads/master/"
           "utility_funcs/test_utils.c",
           31);
    errs += 1;
  }
  rv = safe_atoi(&intret, NULL);
  if (rv == 0) {
    printf("Error: False Positive %s:%d\n",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/nolandda/misc/refs/heads/master/"
           "utility_funcs/test_utils.c",
           37);
    errs += 1;
  }
  rv = safe_atoi(NULL, "11");
  if (rv == 0) {
    printf("Error: False Positive %s:%d\n",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/nolandda/misc/refs/heads/master/"
           "utility_funcs/test_utils.c",
           43);
    errs += 1;
  }
  rv = safe_atoi(&intret, "cat");
  if (rv == 0) {
    printf("Error: False Positive %s:%d\n",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/nolandda/misc/refs/heads/master/"
           "utility_funcs/test_utils.c",
           49);
    errs += 1;
  }
  rv = safe_atoi(
      &intret,
      "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod "
      "tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim "
      "veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea "
      "commodo consequat. Duis aute irure dolor in reprehenderit in voluptate "
      "velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint "
      "occaecat cupidatat non proident, sunt in culpa qui officia deserunt "
      "mollit anim id est laborum.");
  if (rv == 0) {
    printf("Error: False Positive %s:%d\n",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/nolandda/misc/refs/heads/master/"
           "utility_funcs/test_utils.c",
           55);
    errs += 1;
  }
  testval = 0;
  sprintf(testvalstr, "%d", testval);
  rv = safe_atoi(&intret, testvalstr);
  if (rv != 0) {
    printf("Error: False Negative %s:%d\n",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/nolandda/misc/refs/heads/master/"
           "utility_funcs/test_utils.c",
           67);
    errs += 1;
  } else {
    if (intret != testval) {
      printf("Error: Mismatch %s:%d\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/nolandda/misc/refs/heads/master/"
             "utility_funcs/test_utils.c",
             72);
      errs += 1;
    }
  }
  testval = INT_MIN;
  sprintf(testvalstr, "%d", testval);
  rv = safe_atoi(&intret, testvalstr);
  if (rv != 0) {
    printf("Error: False Negative %s:%d\n",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/nolandda/misc/refs/heads/master/"
           "utility_funcs/test_utils.c",
           81);
    errs += 1;
  } else {
    if (intret != testval) {
      printf("Error: Mismatch %s:%d\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/nolandda/misc/refs/heads/master/"
             "utility_funcs/test_utils.c",
             86);
      errs += 1;
    }
  }
  testval = INT_MAX;
  sprintf(testvalstr, "%d", testval);
  rv = safe_atoi(&intret, testvalstr);
  if (rv != 0) {
    printf("Error: False Negative %s:%d\n",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/nolandda/misc/refs/heads/master/"
           "utility_funcs/test_utils.c",
           96);
    errs += 1;
  } else {
    if (intret != testval) {
      printf("Error: Mismatch %s:%d\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/nolandda/misc/refs/heads/master/"
             "utility_funcs/test_utils.c",
             101);
      errs += 1;
    }
  }
  testval = 1234567;
  sprintf(testvalstr, "  \t %d \t\n", testval);
  rv = safe_atoi(&intret, testvalstr);
  if (rv != 0) {
    printf("Error: False Negative %s:%d\n",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/nolandda/misc/refs/heads/master/"
           "utility_funcs/test_utils.c",
           111);
    errs += 1;
  } else {
    if (intret != testval) {
      printf("Error: Mismatch %s:%d\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/nolandda/misc/refs/heads/master/"
             "utility_funcs/test_utils.c",
             116);
      errs += 1;
    }
  }
  return errs;
}


x86 assembly (clang, -O0):
<test_safe_atoi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1040 <memset@plt>
xor    %eax,%eax
mov    %eax,%esi
mov    %rsi,%rdi
call   1050 <safe_atoi@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11ae <test_safe_atoi+0x6e>
lea    0xe6c(%rip),%rdi
lea    0xe82(%rip),%rsi
mov    $0x1f,%edx
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <safe_atoi@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11e9 <test_safe_atoi+0xa9>
lea    0xe31(%rip),%rdi
lea    0xe47(%rip),%rsi
mov    $0x25,%edx
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xebe(%rip),%rsi
call   1050 <safe_atoi@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1227 <test_safe_atoi+0xe7>
lea    0xdf3(%rip),%rdi
lea    0xe09(%rip),%rsi
mov    $0x2b,%edx
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1050 <safe_atoi@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1265 <test_safe_atoi+0x125>
lea    0xdb5(%rip),%rdi
lea    0xdcb(%rip),%rsi
mov    $0x31,%edx
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
lea    0xe49(%rip),%rsi
call   1050 <safe_atoi@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    12a3 <test_safe_atoi+0x163>
lea    0xd77(%rip),%rdi
lea    0xd8d(%rip),%rsi
mov    $0x37,%edx
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xfbf(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x50(%rbp),%rsi
lea    -0xc(%rbp),%rdi
call   1050 <safe_atoi@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     12fd <test_safe_atoi+0x1bd>
lea    0xf9c(%rip),%rdi
lea    0xd38(%rip),%rsi
mov    $0x43,%edx
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    132f <test_safe_atoi+0x1ef>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     132a <test_safe_atoi+0x1ea>
lea    0xf87(%rip),%rdi
lea    0xd06(%rip),%rsi
mov    $0x48,%edx
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    132f <test_safe_atoi+0x1ef>
mov    0x2caa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xf2e(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x50(%rbp),%rsi
lea    -0xc(%rbp),%rdi
call   1050 <safe_atoi@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     138e <test_safe_atoi+0x24e>
lea    0xf0b(%rip),%rdi
lea    0xca7(%rip),%rsi
mov    $0x51,%edx
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    13c0 <test_safe_atoi+0x280>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     13bb <test_safe_atoi+0x27b>
lea    0xef6(%rip),%rdi
lea    0xc75(%rip),%rsi
mov    $0x56,%edx
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    13c0 <test_safe_atoi+0x280>
mov    0x2c21(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xe9d(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x50(%rbp),%rsi
lea    -0xc(%rbp),%rdi
call   1050 <safe_atoi@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     141f <test_safe_atoi+0x2df>
lea    0xe7a(%rip),%rdi
lea    0xc16(%rip),%rsi
mov    $0x60,%edx
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1451 <test_safe_atoi+0x311>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     144c <test_safe_atoi+0x30c>
lea    0xe65(%rip),%rdi
lea    0xbe4(%rip),%rsi
mov    $0x65,%edx
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1451 <test_safe_atoi+0x311>
movl   $0x12d687,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xe48(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x50(%rbp),%rsi
lea    -0xc(%rbp),%rdi
call   1050 <safe_atoi@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     14ab <test_safe_atoi+0x36b>
lea    0xdee(%rip),%rdi
lea    0xb8a(%rip),%rsi
mov    $0x6f,%edx
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    14dd <test_safe_atoi+0x39d>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     14d8 <test_safe_atoi+0x398>
lea    0xdd9(%rip),%rdi
lea    0xb58(%rip),%rsi
mov    $0x74,%edx
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    14dd <test_safe_atoi+0x39d>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_safe_atoi>:
push   %rbp
push   %r14
push   %rbx
sub    $0x50,%rsp
movl   $0x0,0xc(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movw   $0x0,0x40(%rsp)
xor    %r14d,%r14d
xor    %edi,%edi
xor    %esi,%esi
call   1040 <safe_atoi@plt>
test   %eax,%eax
jne    1187 <test_safe_atoi+0x57>
lea    0xe90(%rip),%rdi
lea    0xea6(%rip),%rsi
mov    $0x1f,%edx
call   1030 <printf@plt>
mov    $0x1,%r14d
lea    0xc(%rsp),%rdi
xor    %esi,%esi
call   1040 <safe_atoi@plt>
test   %eax,%eax
jne    11b3 <test_safe_atoi+0x83>
lea    0xe62(%rip),%rdi
lea    0xe78(%rip),%rsi
mov    $0x25,%edx
call   1030 <printf@plt>
add    $0x1,%r14d
lea    0xef8(%rip),%rsi
xor    %edi,%edi
call   1040 <safe_atoi@plt>
test   %eax,%eax
jne    11e1 <test_safe_atoi+0xb1>
lea    0xe34(%rip),%rdi
lea    0xe4a(%rip),%rsi
mov    $0x2b,%edx
call   1030 <printf@plt>
add    $0x1,%r14d
lea    0xecd(%rip),%rsi
lea    0xc(%rsp),%rdi
call   1040 <safe_atoi@plt>
test   %eax,%eax
jne    1212 <test_safe_atoi+0xe2>
lea    0xe03(%rip),%rdi
lea    0xe19(%rip),%rsi
mov    $0x31,%edx
call   1030 <printf@plt>
add    $0x1,%r14d
lea    0xea0(%rip),%rsi
lea    0xc(%rsp),%rdi
call   1040 <safe_atoi@plt>
test   %eax,%eax
jne    1243 <test_safe_atoi+0x113>
lea    0xdd2(%rip),%rdi
lea    0xde8(%rip),%rsi
mov    $0x37,%edx
call   1030 <printf@plt>
add    $0x1,%r14d
lea    0x102d(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
xor    %edx,%edx
call   1050 <sprintf@plt>
lea    0xc(%rsp),%rdi
mov    %rbp,%rsi
call   1040 <safe_atoi@plt>
test   %eax,%eax
je     127f <test_safe_atoi+0x14f>
lea    0x1009(%rip),%rdi
lea    0xda5(%rip),%rsi
mov    $0x43,%edx
jmp    1299 <test_safe_atoi+0x169>
cmpl   $0x0,0xc(%rsp)
je     12a2 <test_safe_atoi+0x172>
lea    0x100a(%rip),%rdi
lea    0xd89(%rip),%rsi
mov    $0x48,%edx
call   1030 <printf@plt>
add    $0x1,%r14d
mov    0x2d37(%rip),%rax
mov    (%rax),%ebp
lea    0xfc5(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %ebp,%edx
call   1050 <sprintf@plt>
lea    0xc(%rsp),%rdi
mov    %rbx,%rsi
call   1040 <safe_atoi@plt>
test   %eax,%eax
je     12e7 <test_safe_atoi+0x1b7>
lea    0xfa1(%rip),%rdi
lea    0xd3d(%rip),%rsi
mov    $0x51,%edx
jmp    1300 <test_safe_atoi+0x1d0>
cmp    %ebp,0xc(%rsp)
je     1309 <test_safe_atoi+0x1d9>
lea    0xfa3(%rip),%rdi
lea    0xd22(%rip),%rsi
mov    $0x56,%edx
call   1030 <printf@plt>
add    $0x1,%r14d
mov    0x2cd8(%rip),%rax
mov    (%rax),%ebp
lea    0xf5e(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %ebp,%edx
call   1050 <sprintf@plt>
lea    0xc(%rsp),%rdi
mov    %rbx,%rsi
call   1040 <safe_atoi@plt>
test   %eax,%eax
je     134e <test_safe_atoi+0x21e>
lea    0xf3a(%rip),%rdi
lea    0xcd6(%rip),%rsi
mov    $0x60,%edx
jmp    1367 <test_safe_atoi+0x237>
cmp    %ebp,0xc(%rsp)
je     1370 <test_safe_atoi+0x240>
lea    0xf3c(%rip),%rdi
lea    0xcbb(%rip),%rsi
mov    $0x65,%edx
call   1030 <printf@plt>
add    $0x1,%r14d
lea    0xf37(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x12d687,%edx
call   1050 <sprintf@plt>
lea    0xc(%rsp),%rdi
mov    %rbx,%rsi
call   1040 <safe_atoi@plt>
test   %eax,%eax
je     13af <test_safe_atoi+0x27f>
lea    0xed9(%rip),%rdi
lea    0xc75(%rip),%rsi
mov    $0x6f,%edx
jmp    13cc <test_safe_atoi+0x29c>
cmpl   $0x12d687,0xc(%rsp)
je     13d5 <test_safe_atoi+0x2a5>
lea    0xed7(%rip),%rdi
lea    0xc56(%rip),%rsi
mov    $0x74,%edx
call   1030 <printf@plt>
add    $0x1,%r14d
mov    %r14d,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Error: False Positive %s:%d\0A\00"
@.str.1 = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/nolandda/misc/refs/heads/master/utility_funcs/test_utils.c\00"
@.str.2 = [3 x i8] c"11\00"
@.str.3 = [4 x i8] c"cat\00"
@.str.4 = [446 x i8] c"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [29 x i8] c"Error: False Negative %s:%d\0A\00"
@.str.7 = [23 x i8] c"Error: Mismatch %s:%d\0A\00"
@INT_MIN = global i32 0
@INT_MAX = global i32 0
@.str.8 = [10 x i8] c" \09 %d \09\0A\00"
define i32 @test_safe_atoi() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [50 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%6 = bitcast [50 x i8]* %5 to i8*
%7 = call i32 @safe_atoi(i32* null, i8* null)
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 31)
%12 = load i32, i32* %1
%13 = add nsw i32 %12, 1
store i32 %13, i32* %1
br label %14
14: ; preds = %10, %0
%15 = call i32 @safe_atoi(i32* %3, i8* null)
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 37)
%20 = load i32, i32* %1
%21 = add nsw i32 %20, 1
store i32 %21, i32* %1
br label %22
22: ; preds = %18, %14
%23 = call i32 @safe_atoi(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32 %23, i32* %2
%24 = load i32, i32* %2
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 43)
%28 = load i32, i32* %1
%29 = add nsw i32 %28, 1
store i32 %29, i32* %1
br label %30
30: ; preds = %26, %22
%31 = call i32 @safe_atoi(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i32 %31, i32* %2
%32 = load i32, i32* %2
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 49)
%36 = load i32, i32* %1
%37 = add nsw i32 %36, 1
store i32 %37, i32* %1
br label %38
38: ; preds = %34, %30
%39 = call i32 @safe_atoi(i32* %3, i8* getelementptr inbounds ([446 x i8], [446 x i8]* @.str.4, i64 0, i64 0))
store i32 %39, i32* %2
%40 = load i32, i32* %2
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %38
%43 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 55)
%44 = load i32, i32* %1
%45 = add nsw i32 %44, 1
store i32 %45, i32* %1
br label %46
46: ; preds = %42, %38
store i32 0, i32* %4
%47 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%48 = load i32, i32* %4
%49 = call i32 @sprintf(i8* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %48)
%50 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%51 = call i32 @safe_atoi(i32* %3, i8* %50)
store i32 %51, i32* %2
%52 = load i32, i32* %2
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %46
%55 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 67)
%56 = load i32, i32* %1
%57 = add nsw i32 %56, 1
store i32 %57, i32* %1
br label %67
58: ; preds = %46
%59 = load i32, i32* %3
%60 = load i32, i32* %4
%61 = icmp ne i32 %59, %60
br i1 %61, label %62, label %66
62: ; preds = %58
%63 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 72)
%64 = load i32, i32* %1
%65 = add nsw i32 %64, 1
store i32 %65, i32* %1
br label %66
66: ; preds = %62, %58
br label %67
67: ; preds = %66, %54
%68 = load i32, i32* @INT_MIN
store i32 %68, i32* %4
%69 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%70 = load i32, i32* %4
%71 = call i32 @sprintf(i8* %69, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %70)
%72 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%73 = call i32 @safe_atoi(i32* %3, i8* %72)
store i32 %73, i32* %2
%74 = load i32, i32* %2
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %80
76: ; preds = %67
%77 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 81)
%78 = load i32, i32* %1
%79 = add nsw i32 %78, 1
store i32 %79, i32* %1
br label %89
80: ; preds = %67
%81 = load i32, i32* %3
%82 = load i32, i32* %4
%83 = icmp ne i32 %81, %82
br i1 %83, label %84, label %88
84: ; preds = %80
%85 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 86)
%86 = load i32, i32* %1
%87 = add nsw i32 %86, 1
store i32 %87, i32* %1
br label %88
88: ; preds = %84, %80
br label %89
89: ; preds = %88, %76
%90 = load i32, i32* @INT_MAX
store i32 %90, i32* %4
%91 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%92 = load i32, i32* %4
%93 = call i32 @sprintf(i8* %91, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %92)
%94 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%95 = call i32 @safe_atoi(i32* %3, i8* %94)
store i32 %95, i32* %2
%96 = load i32, i32* %2
%97 = icmp ne i32 %96, 0
br i1 %97, label %98, label %102
98: ; preds = %89
%99 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 96)
%100 = load i32, i32* %1
%101 = add nsw i32 %100, 1
store i32 %101, i32* %1
br label %111
102: ; preds = %89
%103 = load i32, i32* %3
%104 = load i32, i32* %4
%105 = icmp ne i32 %103, %104
br i1 %105, label %106, label %110
106: ; preds = %102
%107 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 101)
%108 = load i32, i32* %1
%109 = add nsw i32 %108, 1
store i32 %109, i32* %1
br label %110
110: ; preds = %106, %102
br label %111
111: ; preds = %110, %98
store i32 1234567, i32* %4
%112 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%113 = load i32, i32* %4
%114 = call i32 @sprintf(i8* %112, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32 %113)
%115 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%116 = call i32 @safe_atoi(i32* %3, i8* %115)
store i32 %116, i32* %2
%117 = load i32, i32* %2
%118 = icmp ne i32 %117, 0
br i1 %118, label %119, label %123
119: ; preds = %111
%120 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 111)
%121 = load i32, i32* %1
%122 = add nsw i32 %121, 1
store i32 %122, i32* %1
br label %132
123: ; preds = %111
%124 = load i32, i32* %3
%125 = load i32, i32* %4
%126 = icmp ne i32 %124, %125
br i1 %126, label %127, label %131
127: ; preds = %123
%128 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 116)
%129 = load i32, i32* %1
%130 = add nsw i32 %129, 1
store i32 %130, i32* %1
br label %131
131: ; preds = %127, %123
br label %132
132: ; preds = %131, %119
%133 = load i32, i32* %1
ret i32 %133
}

LLVM IR (-O2):
@.str = [29 x i8] c"Error: False Positive %s:%d\0A\00"
@.str.1 = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/nolandda/misc/refs/heads/master/utility_funcs/test_utils.c\00"
@.str.2 = [3 x i8] c"11\00"
@.str.3 = [4 x i8] c"cat\00"
@.str.4 = [446 x i8] c"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [29 x i8] c"Error: False Negative %s:%d\0A\00"
@.str.7 = [23 x i8] c"Error: Mismatch %s:%d\0A\00"
@INT_MIN = global i32 0
@INT_MAX = global i32 0
@.str.8 = [10 x i8] c" \09 %d \09\0A\00"
define i32 @test_safe_atoi() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @safe_atoi(i32* null, i8* null)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 31)
br label %9
9: ; preds = %7, %0
%10 = phi i32 [ 1, %7 ], [ 0, %0 ]
%11 = call i32 @safe_atoi(i32* %1, i8* null)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 37)
%15 = add nuw nsw i32 %10, 1
br label %16
16: ; preds = %13, %9
%17 = phi i32 [ %15, %13 ], [ %10, %9 ]
%18 = call i32 @safe_atoi(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 43)
%22 = add nuw nsw i32 %17, 1
br label %23
23: ; preds = %20, %16
%24 = phi i32 [ %22, %20 ], [ %17, %16 ]
%25 = call i32 @safe_atoi(i32* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 49)
%29 = add nuw nsw i32 %24, 1
br label %30
30: ; preds = %27, %23
%31 = phi i32 [ %29, %27 ], [ %24, %23 ]
%32 = call i32 @safe_atoi(i32* %1, i8* getelementptr inbounds ([446 x i8], [446 x i8]* @.str.4, i64 0, i64 0))
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 55)
%36 = add nuw nsw i32 %31, 1
br label %37
37: ; preds = %34, %30
%38 = phi i32 [ %36, %34 ], [ %31, %30 ]
%39 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 0)
%40 = call i32 @safe_atoi(i32* %1, i8* %4)
%41 = icmp eq i32 %40, 0
br i1 %41, label %45, label %42
42: ; preds = %37
%43 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 67)
%44 = add nuw nsw i32 %38, 1
br label %51
45: ; preds = %37
%46 = load i32, i32* %1
%47 = icmp eq i32 %46, 0
br i1 %47, label %51, label %48
48: ; preds = %45
%49 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 72)
%50 = add nuw nsw i32 %38, 1
br label %51
51: ; preds = %45, %48, %42
%52 = phi i32 [ %44, %42 ], [ %50, %48 ], [ %38, %45 ]
%53 = load i32, i32* @INT_MIN
%54 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %53)
%55 = call i32 @safe_atoi(i32* %1, i8* %4)
%56 = icmp eq i32 %55, 0
br i1 %56, label %60, label %57
57: ; preds = %51
%58 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 81)
%59 = add nuw nsw i32 %52, 1
br label %66
60: ; preds = %51
%61 = load i32, i32* %1
%62 = icmp eq i32 %61, %53
br i1 %62, label %66, label %63
63: ; preds = %60
%64 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 86)
%65 = add nuw nsw i32 %52, 1
br label %66
66: ; preds = %60, %63, %57
%67 = phi i32 [ %59, %57 ], [ %65, %63 ], [ %52, %60 ]
%68 = load i32, i32* @INT_MAX
%69 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %68)
%70 = call i32 @safe_atoi(i32* %1, i8* %4)
%71 = icmp eq i32 %70, 0
br i1 %71, label %75, label %72
72: ; preds = %66
%73 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 96)
%74 = add nuw nsw i32 %67, 1
br label %81
75: ; preds = %66
%76 = load i32, i32* %1
%77 = icmp eq i32 %76, %68
br i1 %77, label %81, label %78
78: ; preds = %75
%79 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 101)
%80 = add nuw nsw i32 %67, 1
br label %81
81: ; preds = %75, %78, %72
%82 = phi i32 [ %74, %72 ], [ %80, %78 ], [ %67, %75 ]
%83 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32 1234567)
%84 = call i32 @safe_atoi(i32* %1, i8* %4)
%85 = icmp eq i32 %84, 0
br i1 %85, label %89, label %86
86: ; preds = %81
%87 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 111)
%88 = add nuw nsw i32 %82, 1
br label %95
89: ; preds = %81
%90 = load i32, i32* %1
%91 = icmp eq i32 %90, 1234567
br i1 %91, label %95, label %92
92: ; preds = %89
%93 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 116)
%94 = add nuw nsw i32 %82, 1
br label %95
95: ; preds = %89, %92, %86
%96 = phi i32 [ %88, %86 ], [ %94, %92 ], [ %82, %89 ]
ret i32 %96
}