// File: /workspace/github_c_makefile_star2_O1/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 0x8df9
movl %edi, %eax
movl %edi, %ecx
cmpq $0x270f, %rdi           # imm = 0x270F
ja 0x9015
imulq $0x51eb851f, %rcx, %rdx # imm = 0x51EB851F
shrq $0x25, %rdx
imull $0x64, %edx, %r8d
addl %edx, %edx
movq %rsi, %rcx
cmpq $0x3e8, %rdi            # imm = 0x3E8
jb 0x8daf
leaq 0x625c(%rip), %rcx      # 0xf000
movb (%rdx,%rcx), %r9b
leaq 0x1(%rsi), %rcx
movb %r9b, (%rsi)
subl %r8d, %eax
cmpq $0x64, %rdi
jb 0x8dcb
movl %edx, %edx
leaq 0x623f(%rip), %r8       # 0xf000
movb 0x1(%rdx,%r8), %dl
movb %dl, (%rcx)
incq %rcx
addl %eax, %eax
cmpq $0xa, %rdi
jb 0x8de2
leaq 0x6226(%rip), %rdx      # 0xf000
movb (%rax,%rdx), %dl
movb %dl, (%rcx)
incq %rcx
movl %eax, %eax
leaq 0x6215(%rip), %rdx      # 0xf000
movb 0x1(%rax,%rdx), %al
movb %al, (%rcx)
incq %rcx
jmp 0x92d6
movabsq $0x2386f26fc0ffff, %rax # imm = 0x2386F26FC0FFFF
cmpq %rax, %rdi
ja 0x90f3
movabsq $-0x543388ee7b9e3103, %rcx # imm = 0xABCC77118461CEFD
movq %rdi, %rax
mulq %rcx
shrq $0x1a, %rdx
imulq $0x5f5e100, %rdx, %rax  # imm = 0x5F5E100
movq %rdi, %r10
subq %rax, %r10
movl %edx, %eax
movl $0xd1b71759, %ebx       # imm = 0xD1B71759
imulq %rax, %rbx
shrq $0x2d, %rbx
imull $0x2710, %ebx, %ecx     # imm = 0x2710
subl %ecx, %edx
imulq $0x431bde83, %rax, %r15 # imm = 0x431BDE83
shrq $0x31, %r15
andl $-0x2, %r15d
imulq $0x28f5c29, %rbx, %rax  # imm = 0x28F5C29
shrq $0x20, %rax
imull $0x64, %eax, %ebp
imulq $0x68db8bb, %r10, %r8   # imm = 0x68DB8BB
shrq $0x28, %r8
imull $0x2710, %r8d, %ecx     # imm = 0x2710
movl %r10d, %eax
subl %ecx, %eax
imulq $0x28f5c29, %r8, %r14   # imm = 0x28F5C29
imulq $0x28f5c29, %rax, %r9   # imm = 0x28F5C29
movabsq $0x38d7ea4c68000, %r11  # imm = 0x38D7EA4C68000
movq %rsi, %rcx
cmpq %r11, %rdi
jb 0x8eaa
leaq 0x6161(%rip), %rcx      # 0xf000
movb (%r15,%rcx), %r11b
leaq 0x1(%rsi), %rcx
movb %r11b, (%rsi)
imulq $0x28f5c29, %rdx, %r11  # imm = 0x28F5C29
shrq $0x20, %r14
shrq $0x20, %r9
subl %ebp, %ebx
movabsq $0x5af3107a4000, %r12   # imm = 0x5AF3107A4000
cmpq %r12, %rdi
jb 0x8edf
movl %r15d, %r15d
leaq 0x612c(%rip), %r12      # 0xf000
movb 0x1(%r15,%r12), %bpl
movb %bpl, (%rcx)
incq %rcx
shrq $0x20, %r11
imulq $0x8637bd1, %r10, %r10  # imm = 0x8637BD1
addl %ebx, %ebx
movq %rdi, %r15
shrq $0xd, %r15
cmpq $0x48c27395, %r15       # imm = 0x48C27395
jb 0x8f0d
leaq 0x60fd(%rip), %r15      # 0xf000
movb (%rbx,%r15), %bpl
movb %bpl, (%rcx)
incq %rcx
shrq $0x2e, %r10
imull $0x64, %r14d, %r14d
imull $0x64, %r9d, %ebp
movq %rdi, %r15
shrq $0xc, %r15
cmpq $0xe8d4a51, %r15        # imm = 0xE8D4A51
jb 0x8f3c
movl %ebx, %ebx
leaq 0x60ce(%rip), %r15      # 0xf000
movb 0x1(%rbx,%r15), %bl
movb %bl, (%rcx)
incq %rcx
imull $0x64, %r11d, %ebx
subl %r14d, %r8d
subl %ebp, %eax
addl %r11d, %r11d
movq %rdi, %r14
shrq $0xb, %r14
cmpq $0x2e90edd, %r14        # imm = 0x2E90EDD
jb 0x8f69
leaq 0x60a1(%rip), %r14      # 0xf000
movb (%r11,%r14), %bpl
movb %bpl, (%rcx)
incq %rcx
subl %ebx, %edx
andl $0x1fe, %r10d           # imm = 0x1FE
addl %r8d, %r8d
addl %r9d, %r9d
addl %eax, %eax
movq %rdi, %rbx
shrq $0xa, %rbx
cmpq $0x9502f9, %rbx         # imm = 0x9502F9
jb 0x8f9f
movl %r11d, %r11d
leaq 0x606c(%rip), %rbx      # 0xf000
movb 0x1(%r11,%rbx), %r11b
movb %r11b, (%rcx)
incq %rcx
addl %edx, %edx
cmpq $0x3b9aca00, %rdi       # imm = 0x3B9ACA00
jb 0x8fbb
leaq 0x604f(%rip), %rdi      # 0xf000
movb (%rdx,%rdi), %dil
movb %dil, (%rcx)
incq %rcx
movl %edx, %edx
leaq 0x603c(%rip), %rdi      # 0xf000
movb 0x1(%rdx,%rdi), %dl
movb %dl, (%rcx)
movb (%r10,%rdi), %dl
movb %dl, 0x1(%rcx)
movl %r10d, %edx
movb 0x1(%rdx,%rdi), %dl
movb %dl, 0x2(%rcx)
movb (%r8,%rdi), %dl
movb %dl, 0x3(%rcx)
movl %r8d, %edx
movb 0x1(%rdx,%rdi), %dl
movb %dl, 0x4(%rcx)
movb (%r9,%rdi), %dl
movb %dl, 0x5(%rcx)
movl %r9d, %edx
movb 0x1(%rdx,%rdi), %dl
movb %dl, 0x6(%rcx)
movb (%rax,%rdi), %dl
movb %dl, 0x7(%rcx)
movl %eax, %eax
movb 0x1(%rax,%rdi), %al
movb %al, 0x8(%rcx)
addq $0x9, %rcx
jmp 0x92d6
movl $0xd1b71759, %edx       # imm = 0xD1B71759
imulq %rcx, %rdx
shrq $0x2d, %rdx
imull $0x2710, %edx, %r8d     # imm = 0x2710
subl %r8d, %eax
imulq $0x431bde83, %rcx, %r9  # imm = 0x431BDE83
shrq $0x31, %r9
andl $-0x2, %r9d
imulq $0x28f5c29, %rdx, %rcx  # imm = 0x28F5C29
shrq $0x20, %rcx
imull $0x64, %ecx, %r10d
imulq $0x28f5c29, %rax, %r8   # imm = 0x28F5C29
shrq $0x20, %r8
imull $0x64, %r8d, %ecx
subl %ecx, %eax
movq %rsi, %rcx
cmpq $0x989680, %rdi         # imm = 0x989680
jb 0x9079
leaq 0x5f92(%rip), %rcx      # 0xf000
movb (%r9,%rcx), %r11b
leaq 0x1(%rsi), %rcx
movb %r11b, (%rsi)
subl %r10d, %edx
addl %r8d, %r8d
addl %eax, %eax
cmpq $0xf4240, %rdi          # imm = 0xF4240
jb 0x909f
movl %r9d, %r9d
leaq 0x5f6c(%rip), %r10      # 0xf000
movb 0x1(%r9,%r10), %r9b
movb %r9b, (%rcx)
incq %rcx
addl %edx, %edx
cmpq $0x186a0, %rdi          # imm = 0x186A0
jb 0x90bb
leaq 0x5f4f(%rip), %rdi      # 0xf000
movb (%rdx,%rdi), %dil
movb %dil, (%rcx)
incq %rcx
movl %edx, %edx
leaq 0x5f3c(%rip), %rdi      # 0xf000
movb 0x1(%rdx,%rdi), %dl
movb %dl, (%rcx)
movb (%r8,%rdi), %dl
movb %dl, 0x1(%rcx)
movl %r8d, %edx
movb 0x1(%rdx,%rdi), %dl
movb %dl, 0x2(%rcx)
movb (%rax,%rdi), %dl
movb %dl, 0x3(%rcx)
movl %eax, %eax
movb 0x1(%rax,%rdi), %al
movb %al, 0x4(%rcx)
addq $0x5, %rcx
jmp 0x92d6
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 0x9138
orb $0x30, %dl
leaq 0x1(%rsi), %rcx
movb %dl, (%rsi)
jmp 0x91cf
movabsq $0xde0b6b3a763ffff, %rax # imm = 0xDE0B6B3A763FFFF
cmpq %rax, %rdi
ja 0x915d
movl %edx, %eax
leaq 0x5eb0(%rip), %rcx      # 0xf000
movzwl (%rcx,%rax,2), %eax
movw %ax, (%rsi)
leaq 0x2(%rsi), %rcx
jmp 0x91cf
movl %edx, %ecx
imulq $0x28f5c29, %rcx, %rax  # imm = 0x28F5C29
shrq $0x20, %rax
movabsq $-0x7538dcfb76180001, %r9 # imm = 0x8AC7230489E7FFFF
cmpq %r9, %rdi
ja 0x91a2
addb $0x30, %al
movb %al, (%rsi)
imulq $0x28f5c29, %rcx, %rax  # imm = 0x28F5C29
shrq $0x20, %rax
imull $0x64, %eax, %eax
subl %eax, %edx
leaq 0x5e6c(%rip), %rax      # 0xf000
movzwl (%rax,%rdx,2), %eax
movw %ax, 0x1(%rsi)
leaq 0x3(%rsi), %rcx
jmp 0x91cf
imull $0x64, %eax, %ecx
subl %ecx, %edx
movl %eax, %eax
movl %edx, %ecx
leaq 0x5e4e(%rip), %rdx      # 0xf000
movzwl (%rdx,%rax,2), %eax
movw %ax, (%rsi)
movb (%rdx,%rcx,2), %al
addq %rcx, %rcx
movb %al, 0x2(%rsi)
movl %ecx, %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
imulq $0x28f5c29, %rax, %r9   # imm = 0x28F5C29
shrq $0x20, %r9
imull $0x64, %r9d, %r9d
subl %r9d, %eax
imulq $0x28f5c29, %rdx, %r9   # imm = 0x28F5C29
shrq $0x20, %r9
imull $0x64, %r9d, %r10d
subl %r10d, %edx
imulq $0x68db8bb, %r8, %r10   # imm = 0x68DB8BB
shrq $0x28, %r10
imull $0x2710, %r10d, %ebx    # imm = 0x2710
movl %r8d, %r11d
subl %ebx, %r11d
imulq $0x8637bd1, %r8, %r8    # imm = 0x8637BD1
shrq $0x2e, %r8
andl $0x1fe, %r8d            # imm = 0x1FE
imulq $0x28f5c29, %r10, %rbx  # imm = 0x28F5C29
shrq $0x20, %rbx
imull $0x64, %ebx, %ebx
subl %ebx, %r10d
imulq $0x28f5c29, %r11, %rbx  # imm = 0x28F5C29
shrq $0x20, %rbx
imull $0x64, %ebx, %ebp
subl %ebp, %r11d
leaq 0x5d75(%rip), %r14      # 0xf000
movzwl (%rdi,%r14), %edi
movw %di, (%rcx)
movzwl (%r14,%rax,2), %eax
movw %ax, 0x2(%rcx)
movzwl (%r14,%r9,2), %eax
movw %ax, 0x4(%rcx)
movzwl (%r14,%rdx,2), %eax
movw %ax, 0x6(%rcx)
movzwl (%r8,%r14), %eax
movw %ax, 0x8(%rcx)
movzwl (%r14,%r10,2), %eax
movw %ax, 0xa(%rcx)
movzwl (%r14,%rbx,2), %eax
movw %ax, 0xc(%rcx)
movzwl (%r14,%r11,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