// File: /workspace/github_cpp_makefile_star2_O2/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 0x24081(%rip), %al      # 0x3f5d0
testb %al, %al
je 0x1b64e
movslq %ebp, %r14
leaq 0x2404f(%rip), %rsi     # 0x3f5b0
leaq 0x8(%rsp), %rdi
xorl %edx, %edx
movq %r14, %rcx
callq 0x4090
cmpq $0x0, 0x8(%rbx)
je 0x1b6a5
movq (%rbx), %rax
movb (%rax), %al
movq %rax, (%rsp)
addl $-0x2b, %eax
xorl %ebp, %ebp
testb $-0x3, %al
sete %bpl
xorl %r13d, %r13d
leaq 0x8(%rsp), %r15
movl $0x80000000, %r12d      # imm = 0x80000000
movq (%rbx), %rax
movb (%rax,%rbp), %al
testb %al, %al
je 0x1b5f6
movsbl %al, %esi
movq %r15, %rdi
xorl %edx, %edx
callq 0x45a0
cmpq $-0x1, %rax
je 0x1b61e
imulq %r14, %r13
movq (%rbx), %rax
movsbl (%rax,%rbp), %esi
movq %r15, %rdi
xorl %edx, %edx
callq 0x45a0
addq %rax, %r13
incq %rbp
cmpq %r12, %r13
jl 0x1b59d
pushq $0x10
popq %rdi
callq 0x41e0
movq %rax, %r14
leaq 0x24a3(%rip), %rsi      # 0x1da8f
movq %rax, %rdi
callq 0x4810
jmp 0x1b638
movl %r13d, %ebx
negl %ebx
cmpb $0x2d, (%rsp)
cmovnel %r13d, %ebx
leaq 0x8(%rsp), %rdi
callq 0x4898
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x41e0
movq %rax, %r14
leaq 0x244a(%rip), %rsi      # 0x1da7a
movq %rax, %rdi
callq 0x4810
movq 0xf991(%rip), %rsi      # 0x2afd0
movq 0xf97a(%rip), %rdx      # 0x2afc0
movq %r14, %rdi
callq 0x4730
leaq 0x23f7b(%rip), %rdi     # 0x3f5d0
callq 0x47c0
testl %eax, %eax
je 0x1b557
leaq 0x23f47(%rip), %rdi     # 0x3f5b0
leaq 0x23db(%rip), %rsi      # 0x1da4b
leaq 0x8(%rsp), %rdx
callq 0x5328
movq 0xf91f(%rip), %rdi      # 0x2afa0
leaq 0x23f28(%rip), %rsi     # 0x3f5b0
leaq 0xfdc1(%rip), %rdx      # 0x2b450
callq 0x43b0
leaq 0x23f35(%rip), %rdi     # 0x3f5d0
callq 0x42a0
jmp 0x1b557
pushq $0x10
popq %rdi
callq 0x41e0
movq %rax, %r14
leaq 0x23a5(%rip), %rsi      # 0x1da5c
movq %rax, %rdi
callq 0x4810
movq 0xf90a(%rip), %rsi      # 0x2afd0
movq 0xf8f3(%rip), %rdx      # 0x2afc0
movq %r14, %rdi
callq 0x4730
movq %rax, %rbx
leaq 0x23ef1(%rip), %rdi     # 0x3f5d0
callq 0x4290
jmp 0x1b706
jmp 0x1b6f9
jmp 0x1b6ec
jmp 0x1b6ec
movq %rax, %rbx
movq %r14, %rdi
callq 0x4310
jmp 0x1b6fc
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4898
movq %rbx, %rdi
callq 0x4750
nop