// File: /workspace/github_c_makefile_star2_O3/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 %rbx
cmpq $0x5f5e0ff, %rdi        # imm = 0x5F5E0FF
ja 0x8e1c
cmpq $0x270f, %rdi           # imm = 0x270F
ja 0x8f38
movl %edi, %eax
imulq $0x51eb851f, %rax, %rdx # imm = 0x51EB851F
shrq $0x25, %rdx
imull $0x64, %edx, %ecx
addl %edx, %edx
movl %edi, %eax
subl %ecx, %eax
addl %eax, %eax
cmpq $0x3e8, %rdi            # imm = 0x3E8
jb 0x900e
leaq 0x6054(%rip), %rcx      # 0xee60
movb (%rdx,%rcx), %dil
leaq 0x1(%rsi), %rcx
movb %dil, (%rsi)
jmp 0x901b
movabsq $0x2386f26fc0ffff, %rax # imm = 0x2386F26FC0FFFF
cmpq %rax, %rdi
ja 0x8fc5
movabsq $-0x543388ee7b9e3103, %rcx # imm = 0xABCC77118461CEFD
movq %rdi, %rax
mulq %rcx
shrq $0x1a, %rdx
imulq $0x5f5e100, %rdx, %rcx  # imm = 0x5F5E100
movq %rdi, %rax
subq %rcx, %rax
movl %edx, %ecx
movl $0xd1b71759, %ebx       # imm = 0xD1B71759
imulq %rcx, %rbx
shrq $0x2d, %rbx
imull $0x2710, %ebx, %r8d     # imm = 0x2710
subl %r8d, %edx
imulq $0x431bde83, %rcx, %r14 # imm = 0x431BDE83
shrq $0x31, %r14
andl $-0x2, %r14d
movl $0xffff, %ecx           # imm = 0xFFFF
movl %ebx, %r8d
andl %ecx, %r8d
shrl $0x2, %r8d
imull $0x147b, %r8d, %r8d     # imm = 0x147B
shrl $0x11, %r8d
imull $0x64, %r8d, %r8d
subl %r8d, %ebx
andl %ecx, %ebx
addl %ebx, %ebx
imull $0x147b, %edx, %r11d    # imm = 0x147B
shrl $0x13, %r11d
imull $0x64, %r11d, %r8d
addl %r11d, %r11d
subl %r8d, %edx
andl %ecx, %edx
addl %edx, %edx
imulq $0x68db8bb, %rax, %r8   # imm = 0x68DB8BB
shrq $0x28, %r8
imull $0x2710, %r8d, %r10d    # imm = 0x2710
imulq $0x8637bd1, %rax, %r9   # imm = 0x8637BD1
subl %r10d, %eax
shrq $0x2e, %r9
andl $0x1fe, %r9d            # imm = 0x1FE
imull $0x147b, %r8d, %r10d    # imm = 0x147B
shrl $0x13, %r10d
imull $0x64, %r10d, %r10d
subl %r10d, %r8d
andl %ecx, %r8d
addl %r8d, %r8d
imull $0x147b, %eax, %r15d    # imm = 0x147B
shrl $0x13, %r15d
leal (%r15,%r15), %r10d
imull $0x64, %r15d, %ebp
subl %ebp, %eax
andl %ecx, %eax
addl %eax, %eax
movabsq $0x38d7ea4c68000, %rcx  # imm = 0x38D7EA4C68000
cmpq %rcx, %rdi
jb 0x9053
leaq 0x5f38(%rip), %rcx      # 0xee60
movb (%r14,%rcx), %dil
leaq 0x1(%rsi), %rcx
movb %dil, (%rsi)
jmp 0x9069
movl %edi, %ecx
movl $0xd1b71759, %edx       # imm = 0xD1B71759
imulq %rcx, %rdx
shrq $0x2d, %rdx
imull $0x2710, %edx, %r8d     # imm = 0x2710
movl %edi, %eax
subl %r8d, %eax
imulq $0x431bde83, %rcx, %r9  # imm = 0x431BDE83
shrq $0x31, %r9
andl $-0x2, %r9d
movl $0xffff, %ecx           # imm = 0xFFFF
movl %edx, %r8d
andl %ecx, %r8d
shrl $0x2, %r8d
imull $0x147b, %r8d, %r8d     # imm = 0x147B
shrl $0x11, %r8d
imull $0x64, %r8d, %r8d
subl %r8d, %edx
andl %ecx, %edx
addl %edx, %edx
imull $0x147b, %eax, %r10d    # imm = 0x147B
shrl $0x13, %r10d
leal (%r10,%r10), %r8d
imull $0x64, %r10d, %r10d
subl %r10d, %eax
andl %ecx, %eax
addl %eax, %eax
cmpq $0x989680, %rdi         # imm = 0x989680
jb 0x913a
leaq 0x5eab(%rip), %rcx      # 0xee60
movb (%r9,%rcx), %dil
leaq 0x1(%rsi), %rcx
movb %dil, (%rsi)
jmp 0x914a
movabsq $0x39a5652fb1137857, %rcx # imm = 0x39A5652FB1137857
movq %rdi, %rax
mulq %rcx
shrq $0x33, %rdx
movabsq $0x2386f26fc10000, %rax # imm = 0x2386F26FC10000
imulq %rdx, %rax
movq %rdi, %r8
subq %rax, %r8
movabsq $0x16345785d89ffff, %rax # imm = 0x16345785D89FFFF
cmpq %rax, %rdi
ja 0x91ab
orb $0x30, %dl
leaq 0x1(%rsi), %rcx
movb %dl, (%rsi)
jmp 0x92e4
movq %rsi, %rcx
cmpq $0x64, %rdi
jb 0x91d7
movl %edx, %edx
leaq 0x5e3c(%rip), %rdi      # 0xee60
movb 0x1(%rdx,%rdi), %dl
movb %dl, (%rcx)
incq %rcx
leaq 0x5e2c(%rip), %rdx      # 0xee60
movb (%rax,%rdx), %dl
movb %dl, (%rcx)
incq %rcx
movl %eax, %eax
leaq 0x5e1b(%rip), %rdx      # 0xee60
movb 0x1(%rax,%rdx), %al
movb %al, (%rcx)
incq %rcx
jmp 0x9405
movabsq $0x5af3107a4000, %r15   # imm = 0x5AF3107A4000
movq %rsi, %rcx
cmpq %r15, %rdi
jb 0x91e9
movl %r14d, %edi
leaq 0x5ded(%rip), %r14      # 0xee60
movb 0x1(%rdi,%r14), %dil
movb %dil, (%rcx)
incq %rcx
leaq 0x5ddb(%rip), %rdi      # 0xee60
movb (%rbx,%rdi), %dil
movb %dil, (%rcx)
incq %rcx
movzwl %bx, %edi
leaq 0x5dc7(%rip), %rbx      # 0xee60
movb 0x1(%rdi,%rbx), %dil
movb %dil, (%rcx)
incq %rcx
leaq 0x5db5(%rip), %rdi      # 0xee60
movb (%r11,%rdi), %dil
movb %dil, (%rcx)
incq %rcx
movzwl %r11w, %edi
leaq 0x5da0(%rip), %r11      # 0xee60
movb 0x1(%rdi,%r11), %dil
movb %dil, (%rcx)
incq %rcx
leaq 0x5d8e(%rip), %rdi      # 0xee60
movb (%rdx,%rdi), %dil
movb %dil, (%rcx)
incq %rcx
movzwl %dx, %edx
leaq 0x5d7a(%rip), %rdi      # 0xee60
movb 0x1(%rdx,%rdi), %dl
movb %dl, (%rcx)
movb (%r9,%rdi), %dl
movb %dl, 0x1(%rcx)
movl %r9d, %edx
movb 0x1(%rdx,%rdi), %dl
movb %dl, 0x2(%rcx)
movb (%r8,%rdi), %dl
movb %dl, 0x3(%rcx)
movzwl %r8w, %edx
movb 0x1(%rdx,%rdi), %dl
movb %dl, 0x4(%rcx)
movb (%r10,%rdi), %dl
movb %dl, 0x5(%rcx)
movzwl %r10w, %edx
movb 0x1(%rdx,%rdi), %dl
movb %dl, 0x6(%rcx)
movb (%rax,%rdi), %dl
movb %dl, 0x7(%rcx)
movzwl %ax, %eax
movb 0x1(%rax,%rdi), %al
movb %al, 0x8(%rcx)
addq $0x9, %rcx
jmp 0x9405
movq %rsi, %rcx
cmpq $0xf4240, %rdi          # imm = 0xF4240
jb 0x925a
movl %r9d, %edi
leaq 0x5d0c(%rip), %r9       # 0xee60
movb 0x1(%rdi,%r9), %dil
movb %dil, (%rcx)
incq %rcx
leaq 0x5cfa(%rip), %rdi      # 0xee60
movb (%rdx,%rdi), %dil
movb %dil, (%rcx)
incq %rcx
movzwl %dx, %edx
leaq 0x5ce6(%rip), %rdi      # 0xee60
movb 0x1(%rdx,%rdi), %dl
movb %dl, (%rcx)
movb (%r8,%rdi), %dl
movb %dl, 0x1(%rcx)
movzwl %r8w, %edx
movb 0x1(%rdx,%rdi), %dl
movb %dl, 0x2(%rcx)
movb (%rax,%rdi), %dl
movb %dl, 0x3(%rcx)
movzwl %ax, %eax
movb 0x1(%rax,%rdi), %al
movb %al, 0x4(%rcx)
addq $0x5, %rcx
jmp 0x9405
movabsq $0xde0b6b3a763ffff, %rax # imm = 0xDE0B6B3A763FFFF
cmpq %rax, %rdi
ja 0x926f
movl %edx, %eax
leaq 0x5c99(%rip), %rcx      # 0xee60
movzwl (%rcx,%rax,2), %eax
movw %ax, (%rsi)
leaq 0x2(%rsi), %rcx
jmp 0x92e4
movq %rsi, %rcx
cmpq $0xa, %rdi
jae 0x902d
jmp 0x903c
movq %rdi, %r14
shrq $0xd, %r14
movq %rsi, %rcx
cmpq $0x48c27395, %r14       # imm = 0x48C27395
jae 0x907e
movq %rdi, %r14
shrq $0xc, %r14
movq %rsi, %rcx
cmpq $0xe8d4a51, %r14        # imm = 0xE8D4A51
jae 0x908f
movq %rdi, %rbx
shrq $0xb, %rbx
movq %rsi, %rcx
cmpq $0x2e90edd, %rbx        # imm = 0x2E90EDD
jae 0x90a4
movq %rdi, %rbx
shrq $0xa, %rbx
movq %rsi, %rcx
cmpq $0x9502f9, %rbx         # imm = 0x9502F9
jae 0x90b5
movq %rsi, %rcx
cmpq $0x3b9aca00, %rdi       # imm = 0x3B9ACA00
jae 0x90cb
jmp 0x90dc
movq %rsi, %rcx
cmpq $0x186a0, %rdi          # imm = 0x186A0
jae 0x915f
jmp 0x9170
imull $0x51f, %edx, %eax      # imm = 0x51F
shrl $0x11, %eax
movabsq $-0x7538dcfb76180001, %rcx # imm = 0x8AC7230489E7FFFF
cmpq %rcx, %rdi
ja 0x92b5
addl $0x30, %eax
movb %al, (%rsi)
movzwl %dx, %eax
imull $0x51f, %eax, %ecx      # imm = 0x51F
shrl $0x11, %ecx
imull $0x64, %ecx, %ecx
subl %ecx, %eax
movzwl %ax, %eax
leaq 0x5bb9(%rip), %rcx      # 0xee60
movzwl (%rcx,%rax,2), %eax
movw %ax, 0x1(%rsi)
leaq 0x3(%rsi), %rcx
jmp 0x92e4
imull $0x64, %eax, %ecx
subl %ecx, %edx
movzwl %ax, %eax
movzwl %dx, %ecx
addl %ecx, %ecx
leaq 0x5b97(%rip), %rdx      # 0xee60
movzwl (%rdx,%rax,2), %eax
movw %ax, (%rsi)
movb (%rcx,%rdx), %al
movb %al, 0x2(%rsi)
movzwl %cx, %eax
movb 0x1(%rax,%rdx), %al
leaq 0x4(%rsi), %rcx
movb %al, 0x3(%rsi)
movabsq $-0x543388ee7b9e3103, %rdx # imm = 0xABCC77118461CEFD
movq %r8, %rax
mulq %rdx
shrq $0x1a, %rdx
imulq $0x5f5e100, %rdx, %rax  # imm = 0x5F5E100
subq %rax, %r8
movl %edx, %edi
movl $0xd1b71759, %eax       # imm = 0xD1B71759
imulq %rdi, %rax
shrq $0x2d, %rax
imull $0x2710, %eax, %r9d     # imm = 0x2710
subl %r9d, %edx
imulq $0x431bde83, %rdi, %rdi # imm = 0x431BDE83
shrq $0x31, %rdi
andl $-0x2, %edi
movl $0xffff, %r9d           # imm = 0xFFFF
movl %eax, %r10d
andl %r9d, %r10d
shrl $0x2, %r10d
imull $0x147b, %r10d, %r10d   # imm = 0x147B
shrl $0x11, %r10d
imull $0x64, %r10d, %r10d
subl %r10d, %eax
andl %r9d, %eax
imull $0x147b, %edx, %r10d    # imm = 0x147B
shrl $0x13, %r10d
imull $0x64, %r10d, %r11d
subl %r11d, %edx
andl %r9d, %edx
imulq $0x68db8bb, %r8, %r11   # imm = 0x68DB8BB
shrq $0x28, %r11
imull $0x2710, %r11d, %ebp    # imm = 0x2710
movl %r8d, %ebx
subl %ebp, %ebx
imulq $0x8637bd1, %r8, %r8    # imm = 0x8637BD1
shrq $0x2e, %r8
andl $0x1fe, %r8d            # imm = 0x1FE
imull $0x147b, %r11d, %ebp    # imm = 0x147B
shrl $0x13, %ebp
imull $0x64, %ebp, %ebp
subl %ebp, %r11d
andl %r9d, %r11d
imull $0x147b, %ebx, %r14d    # imm = 0x147B
shrl $0x13, %r14d
imull $0x64, %r14d, %ebp
subl %ebp, %ebx
andl %r9d, %ebx
leaq 0x5aa6(%rip), %r9       # 0xee60
movzwl (%rdi,%r9), %edi
movw %di, (%rcx)
movzwl (%r9,%rax,2), %eax
movw %ax, 0x2(%rcx)
movzwl (%r9,%r10,2), %eax
movw %ax, 0x4(%rcx)
movzwl (%r9,%rdx,2), %eax
movw %ax, 0x6(%rcx)
movzwl (%r8,%r9), %eax
movw %ax, 0x8(%rcx)
movzwl (%r9,%r11,2), %eax
movw %ax, 0xa(%rcx)
movzwl (%r9,%r14,2), %eax
movw %ax, 0xc(%rcx)
movzwl (%r9,%rbx,2), %eax
movw %ax, 0xe(%rcx)
addq $0x10, %rcx
movb $0x0, (%rcx)
subl %esi, %ecx
movl %ecx, %eax
popq %rbx
popq %r14
popq %r15
popq %rbp
retq