// File: /workspace/github_cpp_makefile_star2_O3/solaldunckel[P]webserv/srcs/Utils/StringUtils.cpp
// Function: ft::stoi(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned long*, int)
int stoi(const std::string &str, std::size_t *pos, int base) {
    static std::string b("0123456789abcdef");
    (void)pos;
    std::string our_base(b, 0, base);

    int i = 0;

    if (str.empty())
      throw std::invalid_argument("null or empty string argument");

    bool negate = (str[0] != '-');

    if (str[i] == '+' || str[i] == '-')
      ++i;

    long result = 0;

    while (str[i]) {
      if (our_base.find(str[i]) == std::string::npos)
        throw std::invalid_argument("invalid input string");
      result = result * base + our_base.find(str[i]);
      if (result > std::numeric_limits<int>::max())
        throw std::invalid_argument("overflow");
      i++;
    }
    return negate ? result : -result;
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %ebp
movq %rdi, %rbx
movb 0x22146(%rip), %al      # 0x465d0
testb %al, %al
je 0x245aa
movslq %ebp, %r14
leaq 0x22114(%rip), %rsi     # 0x465b0
leaq 0x8(%rsp), %rdi
xorl %edx, %edx
movq %r14, %rcx
callq 0x40a0
cmpq $0x0, 0x8(%rbx)
je 0x24611
movq (%rbx), %rax
movb (%rax), %cl
movq %rcx, (%rsp)
addl $-0x2b, %ecx
xorl %ebp, %ebp
testb $-0x3, %cl
sete %bpl
movb (%rax,%rbp), %al
xorl %r15d, %r15d
testb %al, %al
je 0x24523
leaq 0x8(%rsp), %r12
movsbl %al, %esi
movq %r12, %rdi
xorl %edx, %edx
callq 0x4590
cmpq $-0x1, %rax
je 0x2455a
movq %r15, %r13
imulq %r14, %r13
movq (%rbx), %rax
movsbl (%rax,%rbp), %esi
movq %r12, %rdi
xorl %edx, %edx
callq 0x4590
movq %rax, %r15
addq %r13, %r15
movl $0x80000000, %eax       # imm = 0x80000000
cmpq %rax, %r15
jge 0x24578
movq (%rbx), %rax
movb 0x1(%rax,%rbp), %al
incq %rbp
testb %al, %al
jne 0x244da
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2453e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
movl %r15d, %eax
negl %eax
cmpb $0x2d, (%rsp)
cmovnel %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x41d0
movq %rax, %r14
leaq 0x255c(%rip), %rsi      # 0x26aca
movq %rax, %rdi
callq 0x4830
jmp 0x24594
movl $0x10, %edi
callq 0x41d0
movq %rax, %r14
leaq 0x2553(%rip), %rsi      # 0x26adf
movq %rax, %rdi
callq 0x4830
movq 0xda35(%rip), %rsi      # 0x31fd0
movq 0xda1e(%rip), %rdx      # 0x31fc0
movq %r14, %rdi
callq 0x4760
leaq 0x2201f(%rip), %rdi     # 0x465d0
callq 0x47e0
testl %eax, %eax
je 0x24492
leaq 0x21ffb(%rip), %rax     # 0x465c0
movq %rax, 0x21fe4(%rip)     # 0x465b0
leaq 0x21fdd(%rip), %rdi     # 0x465b0
leaq 0x24c1(%rip), %rsi      # 0x26a9b
leaq 0x24ca(%rip), %rdx      # 0x26aab
callq 0x579e
movq 0xd9ab(%rip), %rdi      # 0x31f98
leaq 0x21fbc(%rip), %rsi     # 0x465b0
leaq 0xde4d(%rip), %rdx      # 0x32448
callq 0x43b0
leaq 0x21fc9(%rip), %rdi     # 0x465d0
callq 0x4290
jmp 0x24492
movl $0x10, %edi
callq 0x41d0
movq %rax, %r14
leaq 0x2487(%rip), %rsi      # 0x26aac
movq %rax, %rdi
callq 0x4830
movq 0xd99c(%rip), %rsi      # 0x31fd0
movq 0xd985(%rip), %rdx      # 0x31fc0
movq %r14, %rdi
callq 0x4760
movq %rax, %rbx
leaq 0x21f83(%rip), %rdi     # 0x465d0
callq 0x4280
jmp 0x24685
jmp 0x24667
jmp 0x2465a
jmp 0x2465a
movq %rax, %rbx
movq %r14, %rdi
callq 0x4310
jmp 0x2466a
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x24685
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4790
nopl (%rax)