// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/strtod.c
// Function: scan_uint64
static int scan_uint64(
    const uint8_t *str,
    int32_t len,
    uint64_t *out,
    int *neg) {
    const uint8_t *end = str + len;
    int seenadigit = 0;
    int base = 10;
    *neg = 0;
    *out = 0;
    uint64_t accum = 0;
    /* len max is INT64_MAX in base 2 with _ between each bits */
    /* '2r' + 64 bits + 63 _  + sign = 130 => 150 for some leading  */
    /* zeros */
    if (len > 150) return 0;
    /* Get sign */
    if (str >= end) return 0;
    if (*str == '-') {
        *neg = 1;
        str++;
    } else if (*str == '+') {
        str++;
    }
    /* Check for leading 0x or digit digit r */
    if (str + 1 < end && str[0] == '0' && str[1] == 'x') {
        base = 16;
        str += 2;
    } else if (str + 1 < end  &&
               str[0] >= '0' && str[0] <= '9' &&
               str[1] == 'r') {
        base = str[0] - '0';
        str += 2;
    } else if (str + 2 < end  &&
               str[0] >= '0' && str[0] <= '9' &&
               str[1] >= '0' && str[1] <= '9' &&
               str[2] == 'r') {
        base = 10 * (str[0] - '0') + (str[1] - '0');
        if (base < 2 || base > 36) return 0;
        str += 3;
    }

    /* Skip leading zeros */
    while (str < end && *str == '0') {
        seenadigit = 1;
        str++;
    }
    /* Parse significant digits */
    while (str < end) {
        if (*str == '_') {
            if (!seenadigit) return 0;
        } else {
            int digit = digit_lookup[*str & 0x7F];
            if (*str > 127 || digit >= base) return 0;
            if (accum > (UINT64_MAX - digit) / base) return 0;
            accum = accum * base + digit;
            seenadigit = 1;
        }
        str++;
    }

    if (!seenadigit) return 0;
    *out = accum;
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0xa, -0x38(%rbp)
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movq $0x0, -0x40(%rbp)
cmpl $0x96, -0x14(%rbp)
jle 0x66d22
movl $0x0, -0x4(%rbp)
jmp 0x66fcd
movq -0x10(%rbp), %rax
cmpq -0x30(%rbp), %rax
jb 0x66d38
movl $0x0, -0x4(%rbp)
jmp 0x66fcd
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x66d5c
movq -0x28(%rbp), %rax
movl $0x1, (%rax)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x66d76
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x2b, %eax
jne 0x66d74
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x66d76
movq -0x10(%rbp), %rax
addq $0x1, %rax
cmpq -0x30(%rbp), %rax
jae 0x66db5
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x30, %eax
jne 0x66db5
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x78, %eax
jne 0x66db5
movl $0x10, -0x38(%rbp)
movq -0x10(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x10(%rbp)
jmp 0x66e9c
movq -0x10(%rbp), %rax
addq $0x1, %rax
cmpq -0x30(%rbp), %rax
jae 0x66e06
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x30, %eax
jl 0x66e06
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x39, %eax
jg 0x66e06
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x72, %eax
jne 0x66e06
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
subl $0x30, %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x10(%rbp)
jmp 0x66e9a
movq -0x10(%rbp), %rax
addq $0x2, %rax
cmpq -0x30(%rbp), %rax
jae 0x66e98
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x30, %eax
jl 0x66e98
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x39, %eax
jg 0x66e98
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x30, %eax
jl 0x66e98
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x39, %eax
jg 0x66e98
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %eax
cmpl $0x72, %eax
jne 0x66e98
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
subl $0x30, %eax
imull $0xa, %eax, %eax
movq -0x10(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
subl $0x30, %ecx
addl %ecx, %eax
movl %eax, -0x38(%rbp)
cmpl $0x2, -0x38(%rbp)
jl 0x66e80
cmpl $0x24, -0x38(%rbp)
jle 0x66e8c
movl $0x0, -0x4(%rbp)
jmp 0x66fcd
movq -0x10(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x10(%rbp)
jmp 0x66e9a
jmp 0x66e9c
jmp 0x66e9e
movq -0x10(%rbp), %rcx
xorl %eax, %eax
cmpq -0x30(%rbp), %rcx
movb %al, -0x45(%rbp)
jae 0x66ebd
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x30, %eax
sete %al
movb %al, -0x45(%rbp)
movb -0x45(%rbp), %al
testb $0x1, %al
jne 0x66ec6
jmp 0x66edb
movl $0x1, -0x34(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x66e9e
jmp 0x66edd
movq -0x10(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0x66fac
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x5f, %eax
jne 0x66f0e
cmpl $0x0, -0x34(%rbp)
jne 0x66f09
movl $0x0, -0x4(%rbp)
jmp 0x66fcd
jmp 0x66f9b
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
andl $0x7f, %eax
movslq %eax, %rcx
leaq 0x49d0e(%rip), %rax     # 0xb0c30
movzbl (%rax,%rcx), %eax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x7f, %eax
jg 0x66f3d
movl -0x44(%rbp), %eax
cmpl -0x38(%rbp), %eax
jl 0x66f49
movl $0x0, -0x4(%rbp)
jmp 0x66fcd
movq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movslq -0x44(%rbp), %rcx
movq $-0x1, %rax
subq %rcx, %rax
movslq -0x38(%rbp), %rcx
xorl %edx, %edx
divq %rcx
movq %rax, %rcx
movq -0x50(%rbp), %rax
cmpq %rcx, %rax
jbe 0x66f7d
movl $0x0, -0x4(%rbp)
jmp 0x66fcd
movq -0x40(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq %rcx, %rax
movslq -0x44(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movl $0x1, -0x34(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x66edd
cmpl $0x0, -0x34(%rbp)
jne 0x66fbb
movl $0x0, -0x4(%rbp)
jmp 0x66fcd
movq -0x40(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)