// File: /workspace/github_cpp_makefile_star2_O1/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 0x220b3(%rip), %al      # 0x465c0
testb %al, %al
je 0x2462d
movslq %ebp, %r14
leaq 0x22081(%rip), %rsi     # 0x465a0
leaq 0x8(%rsp), %rdi
xorl %edx, %edx
movq %r14, %rcx
callq 0x40a0
cmpq $0x0, 0x8(%rbx)
je 0x24694
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 0x245a6
leaq 0x8(%rsp), %r12
movsbl %al, %esi
movq %r12, %rdi
xorl %edx, %edx
callq 0x4580
cmpq $-0x1, %rax
je 0x245dd
movq %r15, %r13
imulq %r14, %r13
movq (%rbx), %rax
movsbl (%rax,%rbp), %esi
movq %r12, %rdi
xorl %edx, %edx
callq 0x4580
movq %rax, %r15
addq %r13, %r15
movl $0x80000000, %eax       # imm = 0x80000000
cmpq %rax, %r15
jge 0x245fb
movq (%rbx), %rax
movb 0x1(%rax,%rbp), %al
incq %rbp
testb %al, %al
jne 0x2455d
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x245c1
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4460
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 0x24d9(%rip), %rsi      # 0x26aca
movq %rax, %rdi
callq 0x4820
jmp 0x24617
movl $0x10, %edi
callq 0x41d0
movq %rax, %r14
leaq 0x24d0(%rip), %rsi      # 0x26adf
movq %rax, %rdi
callq 0x4820
movq 0xd9b2(%rip), %rsi      # 0x31fd0
movq 0xd99b(%rip), %rdx      # 0x31fc0
movq %r14, %rdi
callq 0x4750
leaq 0x21f8c(%rip), %rdi     # 0x465c0
callq 0x47d0
testl %eax, %eax
je 0x24515
leaq 0x21f68(%rip), %rax     # 0x465b0
movq %rax, 0x21f51(%rip)     # 0x465a0
leaq 0x21f4a(%rip), %rdi     # 0x465a0
leaq 0x243e(%rip), %rsi      # 0x26a9b
leaq 0x2447(%rip), %rdx      # 0x26aab
callq 0x578e
movq 0xd928(%rip), %rdi      # 0x31f98
leaq 0x21f29(%rip), %rsi     # 0x465a0
leaq 0xddc2(%rip), %rdx      # 0x32440
callq 0x43a0
leaq 0x21f36(%rip), %rdi     # 0x465c0
callq 0x4290
jmp 0x24515
movl $0x10, %edi
callq 0x41d0
movq %rax, %r14
leaq 0x2404(%rip), %rsi      # 0x26aac
movq %rax, %rdi
callq 0x4820
movq 0xd919(%rip), %rsi      # 0x31fd0
movq 0xd902(%rip), %rdx      # 0x31fc0
movq %r14, %rdi
callq 0x4750
movq %rax, %rbx
leaq 0x21ef0(%rip), %rdi     # 0x465c0
callq 0x4280
jmp 0x24708
jmp 0x246ea
jmp 0x246dd
jmp 0x246dd
movq %rax, %rbx
movq %r14, %rdi
callq 0x4300
jmp 0x246ed
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x24708
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4460
movq %rbx, %rdi
callq 0x4780