#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*/ fatal_(int, char *, int, char *, int);
int /*<<< orphan*/ fatal_e_(int, char *, int, char *, int);
int strtol(char *, int /*<<< orphan*/ *, int);
int _lexer_lex_int(char *str, char *end, int base) {
  errno = 0;
  char c = *end;
  *end = '\0';
  int n = strtol(str, NULL, base);
  if (errno != 0)
    do {
      fatal_e_(1,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/drkitty/bitty/refs/heads/"
               "master/assembler/lexer.re.c",
               104, "Invalid base-%d integer", base);
    } while (0);
  else if (base != 10 && n < 0)
    do {
      fatal_(1,
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/drkitty/bitty/refs/heads/master/"
             "assembler/lexer.re.c",
             106, "Base-%d integer cannot be negative", base);
    } while (0);
  *end = c;
  return n;
}


x86 assembly (clang, -O0):
<_lexer_lex_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    0x2e96(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x15(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1050 <strtol@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e65(%rip),%rax
cmpq   $0x0,(%rax)
je     11b0 <_lexer_lex_int+0x80>
jmp    118a <_lexer_lex_int+0x5a>
mov    -0x14(%rbp),%r8d
mov    $0x1,%edi
lea    0xe66(%rip),%rsi
mov    $0x68,%edx
lea    0xee9(%rip),%rcx
call   1030 <fatal_e_@plt>
jmp    11f4 <_lexer_lex_int+0xc4>
cmpl   $0xa,-0x14(%rbp)
je     11ef <_lexer_lex_int+0xbf>
cmpl   $0x0,-0x1c(%rbp)
jge    11ef <_lexer_lex_int+0xbf>
jmp    11c9 <_lexer_lex_int+0x99>
mov    -0x14(%rbp),%r8d
mov    $0x1,%edi
lea    0xe27(%rip),%rsi
mov    $0x6a,%edx
lea    0xec2(%rip),%rcx
call   1040 <fatal_@plt>
jmp    11ef <_lexer_lex_int+0xbf>
jmp    11f4 <_lexer_lex_int+0xc4>
mov    -0x15(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_lexer_lex_int>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebp
mov    %rsi,%rbx
mov    0x2e9c(%rip),%r12
movq   $0x0,(%r12)
mov    (%rsi),%r15b
movb   $0x0,(%rsi)
xor    %esi,%esi
call   1050 <strtol@plt>
mov    %eax,%r14d
cmpq   $0x0,(%r12)
je     1185 <_lexer_lex_int+0x55>
lea    0xe96(%rip),%rsi
lea    0xf1e(%rip),%rcx
mov    $0x1,%edi
mov    $0x68,%edx
mov    %ebp,%r8d
call   1030 <fatal_e_@plt>
jmp    11af <_lexer_lex_int+0x7f>
cmp    $0xa,%ebp
je     11af <_lexer_lex_int+0x7f>
test   %r14d,%r14d
jns    11af <_lexer_lex_int+0x7f>
lea    0xe6a(%rip),%rsi
lea    0xf0a(%rip),%rcx
mov    $0x1,%edi
mov    $0x6a,%edx
mov    %ebp,%r8d
call   1040 <fatal_@plt>
mov    %r15b,(%rbx)
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i64 0
@.str = [143 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/drkitty/bitty/refs/heads/master/assembler/lexer.re.c\00"
@.str.1 = [24 x i8] c"Invalid base-%d integer\00"
@.str.2 = [35 x i8] c"Base-%d integer cannot be negative\00"
define i32 @_lexer_lex_int(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i64 0, i64* @errno
%9 = load i8*, i8** %5
%10 = load i8, i8* %9
store i8 %10, i8* %7
%11 = load i8*, i8** %5
store i8 0, i8* %11
%12 = load i8*, i8** %4
%13 = load i32, i32* %6
%14 = call i32 @strtol(i8* %12, i32* null, i32 %13)
store i32 %14, i32* %8
%15 = load i64, i64* @errno
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %3
br label %18
18: ; preds = %17
%19 = load i32, i32* %6
%20 = call i32 @fatal_e_(i32 1, i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str, i64 0, i64 0), i32 104, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %18
br label %34
22: ; preds = %3
%23 = load i32, i32* %6
%24 = icmp ne i32 %23, 10
br i1 %24, label %25, label %33
25: ; preds = %22
%26 = load i32, i32* %8
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %25
br label %29
29: ; preds = %28
%30 = load i32, i32* %6
%31 = call i32 @fatal_(i32 1, i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str, i64 0, i64 0), i32 106, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %29
br label %33
33: ; preds = %32, %25, %22
br label %34
34: ; preds = %33, %21
%35 = load i8, i8* %7
%36 = load i8*, i8** %5
store i8 %35, i8* %36
%37 = load i32, i32* %8
ret i32 %37
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [143 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/drkitty/bitty/refs/heads/master/assembler/lexer.re.c\00"
@.str.1 = [24 x i8] c"Invalid base-%d integer\00"
@.str.2 = [35 x i8] c"Base-%d integer cannot be negative\00"
define i32 @_lexer_lex_int(i8* nocapture %0, i8* nocapture %1, i32 %2) {
store i64 0, i64* @errno
%4 = load i8, i8* %1
store i8 0, i8* %1
%5 = tail call i32 @strtol(i8* nocapture %0, i32* null, i32 %2)
%6 = load i64, i64* @errno
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %3
%9 = tail call i32 @fatal_e_(i32 1, i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str, i64 0, i64 0), i32 104, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %2)
br label %16
10: ; preds = %3
%11 = icmp ne i32 %2, 10
%12 = icmp slt i32 %5, 0
%13 = select i1 %11, i1 %12, i1 false
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = tail call i32 @fatal_(i32 1, i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str, i64 0, i64 0), i32 106, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %2)
br label %16
16: ; preds = %10, %14, %8
store i8 %4, i8* %1
ret i32 %5
}