// File: /workspace/github_c_makefile_star2_O2/JesseBuesking[P]omnomnum/branchlut/branchlut.c
// Function: u64toa_branchlut
int u64toa_branchlut(uint64_t value, char* buffer) {
    char* start = buffer;
    if (value < 100000000) {
        uint32_t v = (uint32_t) (value);
        if (v < 10000) {
            const uint32_t d1 = (v / 100) << 1;
            const uint32_t d2 = (v % 100) << 1;

            if (v >= 1000)
                *buffer++ = gDigitsLut[d1];
            if (v >= 100)
                *buffer++ = gDigitsLut[d1 + 1];
            if (v >= 10)
                *buffer++ = gDigitsLut[d2];
            *buffer++ = gDigitsLut[d2 + 1];
        }
        else {
            // value = bbbbcccc
            const uint32_t b = v / 10000;
            const uint32_t c = v % 10000;

            const uint32_t d1 = (b / 100) << 1;
            const uint32_t d2 = (b % 100) << 1;

            const uint32_t d3 = (c / 100) << 1;
            const uint32_t d4 = (c % 100) << 1;

            if (value >= 10000000)
                *buffer++ = gDigitsLut[d1];
            if (value >= 1000000)
                *buffer++ = gDigitsLut[d1 + 1];
            if (value >= 100000)
                *buffer++ = gDigitsLut[d2];
            *buffer++ = gDigitsLut[d2 + 1];

            *buffer++ = gDigitsLut[d3];
            *buffer++ = gDigitsLut[d3 + 1];
            *buffer++ = gDigitsLut[d4];
            *buffer++ = gDigitsLut[d4 + 1];
        }
    }
    else if (value < 10000000000000000) {
        const uint32_t v0 = (uint32_t) (value / 100000000);
        const uint32_t v1 = (uint32_t) (value % 100000000);

        const uint32_t b0 = v0 / 10000;
        const uint32_t c0 = v0 % 10000;

        const uint32_t d1 = (b0 / 100) << 1;
        const uint32_t d2 = (b0 % 100) << 1;

        const uint32_t d3 = (c0 / 100) << 1;
        const uint32_t d4 = (c0 % 100) << 1;

        const uint32_t b1 = v1 / 10000;
        const uint32_t c1 = v1 % 10000;

        const uint32_t d5 = (b1 / 100) << 1;
        const uint32_t d6 = (b1 % 100) << 1;

        const uint32_t d7 = (c1 / 100) << 1;
        const uint32_t d8 = (c1 % 100) << 1;

        if (value >= 1000000000000000)
            *buffer++ = gDigitsLut[d1];
        if (value >= 100000000000000)
            *buffer++ = gDigitsLut[d1 + 1];
        if (value >= 10000000000000)
            *buffer++ = gDigitsLut[d2];
        if (value >= 1000000000000)
            *buffer++ = gDigitsLut[d2 + 1];
        if (value >= 100000000000)
            *buffer++ = gDigitsLut[d3];
        if (value >= 10000000000)
            *buffer++ = gDigitsLut[d3 + 1];
        if (value >= 1000000000)
            *buffer++ = gDigitsLut[d4];
        if (value >= 100000000)
            *buffer++ = gDigitsLut[d4 + 1];

        *buffer++ = gDigitsLut[d5];
        *buffer++ = gDigitsLut[d5 + 1];
        *buffer++ = gDigitsLut[d6];
        *buffer++ = gDigitsLut[d6 + 1];
        *buffer++ = gDigitsLut[d7];
        *buffer++ = gDigitsLut[d7 + 1];
        *buffer++ = gDigitsLut[d8];
        *buffer++ = gDigitsLut[d8 + 1];
    }
    else {
        const uint32_t a = (uint32_t) (value / 10000000000000000); // 1 to 1844
        value %= 10000000000000000;

        if (a < 10)
            *buffer++ = '0' + (char) (a);
        else if (a < 100) {
            const uint32_t i = a << 1;
            *buffer++ = gDigitsLut[i];
            *buffer++ = gDigitsLut[i + 1];
        }
        else if (a < 1000) {
            *buffer++ = '0' + (char) (a / 100);

            const uint32_t i = (a % 100) << 1;
            *buffer++ = gDigitsLut[i];
            *buffer++ = gDigitsLut[i + 1];
        }
        else {
            const uint32_t i = (a / 100) << 1;
            const uint32_t j = (a % 100) << 1;
            *buffer++ = gDigitsLut[i];
            *buffer++ = gDigitsLut[i + 1];
            *buffer++ = gDigitsLut[j];
            *buffer++ = gDigitsLut[j + 1];
        }

        const uint32_t v0 = (uint32_t) (value / 100000000);
        const uint32_t v1 = (uint32_t) (value % 100000000);

        const uint32_t b0 = v0 / 10000;
        const uint32_t c0 = v0 % 10000;

        const uint32_t d1 = (b0 / 100) << 1;
        const uint32_t d2 = (b0 % 100) << 1;

        const uint32_t d3 = (c0 / 100) << 1;
        const uint32_t d4 = (c0 % 100) << 1;

        const uint32_t b1 = v1 / 10000;
        const uint32_t c1 = v1 % 10000;

        const uint32_t d5 = (b1 / 100) << 1;
        const uint32_t d6 = (b1 % 100) << 1;

        const uint32_t d7 = (c1 / 100) << 1;
        const uint32_t d8 = (c1 % 100) << 1;

        *buffer++ = gDigitsLut[d1];
        *buffer++ = gDigitsLut[d1 + 1];
        *buffer++ = gDigitsLut[d2];
        *buffer++ = gDigitsLut[d2 + 1];
        *buffer++ = gDigitsLut[d3];
        *buffer++ = gDigitsLut[d3 + 1];
        *buffer++ = gDigitsLut[d4];
        *buffer++ = gDigitsLut[d4 + 1];
        *buffer++ = gDigitsLut[d5];
        *buffer++ = gDigitsLut[d5 + 1];
        *buffer++ = gDigitsLut[d6];
        *buffer++ = gDigitsLut[d6 + 1];
        *buffer++ = gDigitsLut[d7];
        *buffer++ = gDigitsLut[d7 + 1];
        *buffer++ = gDigitsLut[d8];
        *buffer++ = gDigitsLut[d8 + 1];
    }

    *buffer = '\0';
    return (int)(buffer - start);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
cmpq $0x5f5e0ff, %rdi        # imm = 0x5F5E0FF
ja 0x7c22
cmpq $0x270f, %rdi           # imm = 0x270F
ja 0x7d03
movl $0x64, %ecx
movl %edi, %eax
xorl %edx, %edx
divl %ecx
addq %rax, %rax
addl %edx, %edx
cmpq $0x3e8, %rdi            # imm = 0x3E8
jb 0x7dae
leaq 0x624e(%rip), %rcx      # 0xde60
movb (%rax,%rcx), %dil
leaq 0x1(%rsi), %rcx
movb %dil, (%rsi)
jmp 0x7dbb
movabsq $0x2386f26fc0ffff, %rax # imm = 0x2386F26FC0FFFF
cmpq %rax, %rdi
ja 0x7d73
movl $0x5f5e100, %ecx        # imm = 0x5F5E100
movq %rdi, %rax
xorl %edx, %edx
divq %rcx
movq %rax, %r8
movq %rdx, %rcx
movl $0x2710, %ebp           # imm = 0x2710
xorl %edx, %edx
divl %ebp
movl %eax, %r10d
movl %edx, %r11d
movl $0xf4240, %r12d         # imm = 0xF4240
movl %r8d, %eax
xorl %edx, %edx
divl %r12d
movl %eax, %r9d
movw $0x64, %r15w
movl %r10d, %eax
xorl %edx, %edx
divw %r15w
movl %edx, %r10d
movl %r11d, %eax
xorl %edx, %edx
divw %r15w
movl %edx, %r11d
movl %eax, %ebx
movl %ecx, %eax
xorl %edx, %edx
divl %ebp
movl %edx, %ebp
movl %eax, %r14d
movl %ecx, %eax
xorl %edx, %edx
divl %r12d
movl %eax, %r8d
movl %r14d, %eax
xorl %edx, %edx
divw %r15w
movl %edx, %ecx
movl %ebp, %eax
xorl %edx, %edx
divw %r15w
addl %r9d, %r9d
movzwl %r10w, %r14d
addl %r14d, %r14d
movzwl %bx, %ebx
addl %ebx, %ebx
movzwl %r11w, %r11d
addl %r11d, %r11d
addl %r8d, %r8d
movzwl %cx, %r10d
addl %r10d, %r10d
movzwl %ax, %eax
addl %eax, %eax
movzwl %dx, %edx
addl %edx, %edx
movabsq $0x38d7ea4c68000, %rcx  # imm = 0x38D7EA4C68000
cmpq %rcx, %rdi
jb 0x7df3
leaq 0x616d(%rip), %rcx      # 0xde60
movb (%r9,%rcx), %dil
leaq 0x1(%rsi), %rcx
movb %dil, (%rsi)
jmp 0x7e09
movl $0x2710, %ecx           # imm = 0x2710
movl %edi, %eax
xorl %edx, %edx
divl %ecx
movl %eax, %ecx
movl %edx, %r9d
movl $0xf4240, %r8d          # imm = 0xF4240
movl %edi, %eax
xorl %edx, %edx
divl %r8d
movl %eax, %r8d
movw $0x64, %r10w
movl %ecx, %eax
xorl %edx, %edx
divw %r10w
movl %edx, %ecx
movl %r9d, %eax
xorl %edx, %edx
divw %r10w
addl %r8d, %r8d
movzwl %cx, %r9d
addl %r9d, %r9d
movzwl %ax, %eax
addl %eax, %eax
movzwl %dx, %edx
addl %edx, %edx
cmpq $0x989680, %rdi         # imm = 0x989680
jb 0x7ee6
leaq 0x60fd(%rip), %rcx      # 0xde60
movb (%r8,%rcx), %dil
leaq 0x1(%rsi), %rcx
movb %dil, (%rsi)
jmp 0x7ef6
movabsq $0x2386f26fc10000, %rcx # imm = 0x2386F26FC10000
movq %rdi, %rax
xorl %edx, %edx
divq %rcx
movq %rax, %r9
movq %rdx, %r8
movabsq $0x16345785d89ffff, %rax # imm = 0x16345785D89FFFF
cmpq %rax, %rdi
ja 0x7f5d
orb $0x30, %r9b
leaq 0x1(%rsi), %rcx
movb %r9b, (%rsi)
jmp 0x80a6
movq %rsi, %rcx
cmpq $0x64, %rdi
jb 0x7f94
movl %eax, %eax
leaq 0x609c(%rip), %rdi      # 0xde60
movb 0x1(%rax,%rdi), %al
movb %al, (%rcx)
incq %rcx
leaq 0x608c(%rip), %rax      # 0xde60
movb (%rdx,%rax), %al
movb %al, (%rcx)
incq %rcx
movl %edx, %eax
leaq 0x607b(%rip), %rdx      # 0xde60
movb 0x1(%rax,%rdx), %al
movb %al, (%rcx)
incq %rcx
jmp 0x8186
movabsq $0x5af3107a4000, %r15   # imm = 0x5AF3107A4000
movq %rsi, %rcx
cmpq %r15, %rdi
jb 0x7fa6
movl %r9d, %edi
leaq 0x604d(%rip), %r9       # 0xde60
movb 0x1(%rdi,%r9), %dil
movb %dil, (%rcx)
incq %rcx
leaq 0x603b(%rip), %rdi      # 0xde60
movb (%r14,%rdi), %dil
movb %dil, (%rcx)
incq %rcx
movzwl %r14w, %edi
leaq 0x6026(%rip), %r9       # 0xde60
movb 0x1(%rdi,%r9), %dil
movb %dil, (%rcx)
incq %rcx
leaq 0x6014(%rip), %rdi      # 0xde60
movb (%rbx,%rdi), %dil
movb %dil, (%rcx)
incq %rcx
movzwl %bx, %edi
leaq 0x6000(%rip), %r9       # 0xde60
movb 0x1(%rdi,%r9), %dil
movb %dil, (%rcx)
incq %rcx
leaq 0x5fee(%rip), %rdi      # 0xde60
movb (%r11,%rdi), %dil
movb %dil, (%rcx)
incq %rcx
movzwl %r11w, %edi
leaq 0x5fd9(%rip), %r9       # 0xde60
movb 0x1(%rdi,%r9), %dil
movb %dil, (%rcx)
movb (%r8,%r9), %dil
movb %dil, 0x1(%rcx)
movl %r8d, %edi
movb 0x1(%rdi,%r9), %dil
movb %dil, 0x2(%rcx)
movb (%r10,%r9), %dil
movb %dil, 0x3(%rcx)
movzwl %r10w, %edi
movb 0x1(%rdi,%r9), %dil
movb %dil, 0x4(%rcx)
movb (%rax,%r9), %dil
movb %dil, 0x5(%rcx)
movzwl %ax, %eax
movb 0x1(%rax,%r9), %al
movb %al, 0x6(%rcx)
movb (%rdx,%r9), %al
movb %al, 0x7(%rcx)
movzwl %dx, %eax
movb 0x1(%rax,%r9), %al
movb %al, 0x8(%rcx)
addq $0x9, %rcx
jmp 0x8186
movq %rsi, %rcx
cmpq $0xf4240, %rdi          # imm = 0xF4240
jb 0x8017
movl %r8d, %edi
leaq 0x5f60(%rip), %r8       # 0xde60
movb 0x1(%rdi,%r8), %dil
movb %dil, (%rcx)
incq %rcx
leaq 0x5f4e(%rip), %rdi      # 0xde60
movb (%r9,%rdi), %dil
movb %dil, (%rcx)
incq %rcx
movzwl %r9w, %edi
leaq 0x5f39(%rip), %r8       # 0xde60
movb 0x1(%rdi,%r8), %dil
movb %dil, (%rcx)
movb (%rax,%r8), %dil
movb %dil, 0x1(%rcx)
movzwl %ax, %eax
movb 0x1(%rax,%r8), %al
movb %al, 0x2(%rcx)
movb (%rdx,%r8), %al
movb %al, 0x3(%rcx)
movzwl %dx, %eax
movb 0x1(%rax,%r8), %al
movb %al, 0x4(%rcx)
addq $0x5, %rcx
jmp 0x8186
movabsq $0xde0b6b3a763ffff, %rax # imm = 0xDE0B6B3A763FFFF
cmpq %rax, %rdi
ja 0x802c
movl %r9d, %eax
leaq 0x5ee6(%rip), %rcx      # 0xde60
movb (%rcx,%rax,2), %dl
addq %rax, %rax
movb %dl, (%rsi)
movl %eax, %eax
movb 0x1(%rax,%rcx), %al
leaq 0x2(%rsi), %rcx
movb %al, 0x1(%rsi)
jmp 0x80a6
movq %rsi, %rcx
cmpq $0xa, %rdi
jae 0x7dcd
jmp 0x7ddc
movq %rdi, %r9
shrq $0xd, %r9
movq %rsi, %rcx
cmpq $0x48c27395, %r9        # imm = 0x48C27395
jae 0x7e1e
movq %rdi, %r9
shrq $0xc, %r9
movq %rsi, %rcx
cmpq $0xe8d4a51, %r9         # imm = 0xE8D4A51
jae 0x7e2f
movq %rdi, %r9
shrq $0xb, %r9
movq %rsi, %rcx
cmpq $0x2e90edd, %r9         # imm = 0x2E90EDD
jae 0x7e45
movq %rdi, %r9
shrq $0xa, %r9
movq %rsi, %rcx
cmpq $0x9502f9, %r9          # imm = 0x9502F9
jae 0x7e56
movq %rsi, %rcx
cmpq $0x3b9aca00, %rdi       # imm = 0x3B9ACA00
jae 0x7e6b
jmp 0x7e7c
movq %rsi, %rcx
cmpq $0x186a0, %rdi          # imm = 0x186A0
jae 0x7f0b
jmp 0x7f1c
movw $0x64, %cx
movl %r9d, %eax
xorl %edx, %edx
divw %cx
movabsq $-0x7538dcfb76180001, %r10 # imm = 0x8AC7230489E7FFFF
cmpq %r10, %rdi
ja 0x806b
addb $0x30, %al
movb %al, (%rsi)
movl %r9d, %eax
xorl %edx, %edx
divw %cx
movzwl %dx, %eax
leaq 0x5e03(%rip), %rcx      # 0xde60
movzwl (%rcx,%rax,2), %eax
movw %ax, 0x1(%rsi)
leaq 0x3(%rsi), %rcx
jmp 0x80a6
movzwl %ax, %eax
addl %eax, %eax
movzwl %dx, %ecx
addl %ecx, %ecx
leaq 0x5de4(%rip), %rdx      # 0xde60
movb (%rax,%rdx), %dil
movb %dil, (%rsi)
movl $0xffff, %edi           # imm = 0xFFFF
andq %rdi, %rax
movb 0x1(%rax,%rdx), %al
movb %al, 0x1(%rsi)
movb (%rcx,%rdx), %al
movb %al, 0x2(%rsi)
andq %rdi, %rcx
movb 0x1(%rcx,%rdx), %al
leaq 0x4(%rsi), %rcx
movb %al, 0x3(%rsi)
movl $0x5f5e100, %edi        # imm = 0x5F5E100
movq %r8, %rax
xorl %edx, %edx
divq %rdi
movq %rax, %rdi
movq %rdx, %r8
movl $0x2710, %ebx           # imm = 0x2710
xorl %edx, %edx
divl %ebx
movl %eax, %r9d
movl %edx, %r10d
movl $0xf4240, %r15d         # imm = 0xF4240
movl %edi, %eax
xorl %edx, %edx
divl %r15d
movl %eax, %edi
movw $0x64, %r14w
movl %r9d, %eax
xorl %edx, %edx
divw %r14w
movl %edx, %r9d
movl %r10d, %eax
xorl %edx, %edx
divw %r14w
movl %edx, %r10d
movl %eax, %r11d
movl %r8d, %eax
xorl %edx, %edx
divl %ebx
movl %edx, %ebx
movl %eax, %ebp
movl %r8d, %eax
xorl %edx, %edx
divl %r15d
movl %eax, %r8d
movl %ebp, %eax
xorl %edx, %edx
divw %r14w
movl %edx, %ebp
movl %ebx, %eax
xorl %edx, %edx
divw %r14w
movzwl %r9w, %r9d
movzwl %r11w, %r11d
movzwl %r10w, %r10d
movzwl %bp, %ebx
movzwl %ax, %eax
movzwl %dx, %edx
leaq 0x5d25(%rip), %r14      # 0xde60
movzwl (%r14,%rdi,2), %edi
movw %di, (%rcx)
movzwl (%r14,%r9,2), %edi
movw %di, 0x2(%rcx)
movzwl (%r14,%r11,2), %edi
movw %di, 0x4(%rcx)
movzwl (%r14,%r10,2), %edi
movw %di, 0x6(%rcx)
movzwl (%r14,%r8,2), %edi
movw %di, 0x8(%rcx)
movzwl (%r14,%rbx,2), %edi
movw %di, 0xa(%rcx)
movzwl (%r14,%rax,2), %eax
movw %ax, 0xc(%rcx)
movzwl (%r14,%rdx,2), %eax
movw %ax, 0xe(%rcx)
addq $0x10, %rcx
movb $0x0, (%rcx)
subl %esi, %ecx
movl %ecx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq