// File: 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
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
cmpb $0x0, 0x2ee33(%rip)     # 0x706e0
jne 0x41915
leaq 0x2ee2a(%rip), %rdi     # 0x706e0
callq 0x59d0
cmpl $0x0, %eax
je 0x41915
leaq -0x15(%rbp), %rdi
movq %rdi, -0x60(%rbp)
callq 0x5960
movq -0x60(%rbp), %rdx
leaq 0x2ede8(%rip), %rdi     # 0x706c0
leaq 0x319c(%rip), %rsi      # 0x44a7b
callq 0x6be0
jmp 0x418e6
leaq -0x15(%rbp), %rdi
callq 0x55e0
movq 0x1a692(%rip), %rdi     # 0x5bf88
leaq 0x2edc3(%rip), %rsi     # 0x706c0
leaq 0x1ac54(%rip), %rdx     # 0x5c558
callq 0x5480
leaq 0x2edd0(%rip), %rdi     # 0x706e0
callq 0x5340
movslq -0x14(%rbp), %rcx
leaq -0x48(%rbp), %rdi
leaq 0x2ed9c(%rip), %rsi     # 0x706c0
xorl %eax, %eax
movl %eax, %edx
callq 0x57a0
movl $0x0, -0x4c(%rbp)
movq -0x8(%rbp), %rdi
callq 0x5900
testb $0x1, %al
jne 0x41946
jmp 0x419d5
movl $0x10, %edi
callq 0x5250
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x68(%rbp)
leaq 0x312b(%rip), %rsi      # 0x44a8c
callq 0x5a10
jmp 0x41968
movq -0x68(%rbp), %rdi
movq 0x1a655(%rip), %rsi     # 0x5bfc8
movq 0x1a63e(%rip), %rdx     # 0x5bfb8
callq 0x5920
jmp 0x41bd2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x15(%rbp), %rdi
callq 0x55e0
leaq 0x2ed40(%rip), %rdi     # 0x706e0
callq 0x5330
jmp 0x41bc9
movq -0x68(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
callq 0x53b0
jmp 0x41bc0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x41bc0
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5610
movsbl (%rax), %eax
cmpl $0x2d, %eax
setne %al
andb $0x1, %al
movb %al, -0x4d(%rbp)
movq -0x8(%rbp), %rdi
movslq -0x4c(%rbp), %rsi
callq 0x5610
movsbl (%rax), %eax
cmpl $0x2b, %eax
je 0x41a1a
movq -0x8(%rbp), %rdi
movslq -0x4c(%rbp), %rsi
callq 0x5610
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x41a23
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movslq -0x4c(%rbp), %rsi
callq 0x5610
cmpb $0x0, (%rax)
je 0x41b7b
movq -0x8(%rbp), %rdi
movslq -0x4c(%rbp), %rsi
callq 0x5610
leaq -0x48(%rbp), %rdi
xorl %ecx, %ecx
movl %ecx, %edx
movsbl (%rax), %esi
callq 0x5730
cmpq $-0x1, %rax
jne 0x41abc
movl $0x10, %edi
callq 0x5250
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x70(%rbp)
leaq 0x302b(%rip), %rsi      # 0x44aaa
callq 0x5a10
jmp 0x41a86
movq -0x70(%rbp), %rdi
movq 0x1a537(%rip), %rsi     # 0x5bfc8
movq 0x1a520(%rip), %rdx     # 0x5bfb8
callq 0x5920
jmp 0x41bd2
movq -0x70(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
callq 0x53b0
jmp 0x41bc0
movq -0x58(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x8(%rbp), %rdi
movslq -0x4c(%rbp), %rsi
callq 0x5610
leaq -0x48(%rbp), %rdi
xorl %ecx, %ecx
movl %ecx, %edx
movsbl (%rax), %esi
callq 0x5730
movq %rax, %rcx
movq -0x80(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x78(%rbp)
callq 0x41d10
movl %eax, %ecx
movq -0x78(%rbp), %rax
movslq %ecx, %rcx
cmpq %rcx, %rax
jle 0x41b6d
movl $0x10, %edi
callq 0x5250
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x88(%rbp)
leaq 0x2f8f(%rip), %rsi      # 0x44abf
callq 0x5a10
jmp 0x41b37
movq -0x88(%rbp), %rdi
movq 0x1a483(%rip), %rsi     # 0x5bfc8
movq 0x1a46c(%rip), %rdx     # 0x5bfb8
callq 0x5920
jmp 0x41bd2
movq -0x88(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
callq 0x53b0
jmp 0x41bc0
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x41a2b
testb $0x1, -0x4d(%rbp)
je 0x41b8e
movq -0x58(%rbp), %rax
movq %rax, -0x90(%rbp)
jmp 0x41b9b
xorl %eax, %eax
subq -0x58(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movl %eax, -0x94(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x5aa8
movl -0x94(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x5aa8
movq -0x20(%rbp), %rdi
callq 0x5950
nopw %cs:(%rax,%rax)
nopl (%rax)