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

        if (value >= 1000)
            *buffer++ = gDigitsLut[d1];
        if (value >= 100)
            *buffer++ = gDigitsLut[d1 + 1];
        if (value >= 10)
            *buffer++ = gDigitsLut[d2];
        *buffer++ = gDigitsLut[d2 + 1];
    }
    else if (value < 100000000) {
        // value = bbbbcccc
        const uint32_t b = value / 10000;
        const uint32_t c = value % 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 {
        // value = aabbbbcccc in decimal

        const uint32_t a = value / 100000000; // 1 to 42
        value %= 100000000;

        if (a >= 10) {
            const unsigned i = a << 1;
            *buffer++ = gDigitsLut[i];
            *buffer++ = gDigitsLut[i + 1];
        }
        else
            *buffer++ = '0' + (char) (a);

        const uint32_t b = value / 10000; // 0 to 9999
        const uint32_t c = value % 10000; // 0 to 9999

        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;

        *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++ = '\0';
    return (int)(buffer - start);
}

// Assembly:
movl %edi, -0x4(%rsp)
movq %rsi, -0x10(%rsp)
movq -0x10(%rsp), %rax
movq %rax, -0x18(%rsp)
cmpl $0x2710, -0x4(%rsp)     # imm = 0x2710
jae 0x15f8a
movl -0x4(%rsp), %eax
movl $0x64, %ecx
xorl %edx, %edx
divl %ecx
shll %eax
movl %eax, -0x1c(%rsp)
movl -0x4(%rsp), %eax
movl $0x64, %ecx
xorl %edx, %edx
divl %ecx
shll %edx
movl %edx, -0x20(%rsp)
cmpl $0x3e8, -0x4(%rsp)      # imm = 0x3E8
jb 0x15f04
movl -0x1c(%rsp), %eax
movl %eax, %ecx
leaq 0x7b12(%rip), %rax      # 0x1da00
movb (%rax,%rcx), %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
cmpl $0x64, -0x4(%rsp)
jb 0x15f33
movl -0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x7ae3(%rip), %rax      # 0x1da00
movb (%rax,%rcx), %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
cmpl $0xa, -0x4(%rsp)
jb 0x15f5d
movl -0x20(%rsp), %eax
movl %eax, %ecx
leaq 0x7ab9(%rip), %rax      # 0x1da00
movb (%rax,%rcx), %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
movl -0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x7a91(%rip), %rax      # 0x1da00
movb (%rax,%rcx), %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
jmp 0x16390
cmpl $0x5f5e100, -0x4(%rsp)  # imm = 0x5F5E100
jae 0x16155
movl -0x4(%rsp), %eax
movl $0x2710, %ecx           # imm = 0x2710
xorl %edx, %edx
divl %ecx
movl %eax, -0x24(%rsp)
movl -0x4(%rsp), %eax
movl $0x2710, %ecx           # imm = 0x2710
xorl %edx, %edx
divl %ecx
movl %edx, -0x28(%rsp)
movl -0x24(%rsp), %eax
movl $0x64, %ecx
xorl %edx, %edx
divl %ecx
shll %eax
movl %eax, -0x2c(%rsp)
movl -0x24(%rsp), %eax
movl $0x64, %ecx
xorl %edx, %edx
divl %ecx
shll %edx
movl %edx, -0x30(%rsp)
movl -0x28(%rsp), %eax
movl $0x64, %ecx
xorl %edx, %edx
divl %ecx
shll %eax
movl %eax, -0x34(%rsp)
movl -0x28(%rsp), %eax
movl $0x64, %ecx
xorl %edx, %edx
divl %ecx
shll %edx
movl %edx, -0x38(%rsp)
cmpl $0x989680, -0x4(%rsp)   # imm = 0x989680
jb 0x16033
movl -0x2c(%rsp), %eax
movl %eax, %ecx
leaq 0x79e3(%rip), %rax      # 0x1da00
movb (%rax,%rcx), %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
cmpl $0xf4240, -0x4(%rsp)    # imm = 0xF4240
jb 0x16065
movl -0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x79b1(%rip), %rax      # 0x1da00
movb (%rax,%rcx), %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
cmpl $0x186a0, -0x4(%rsp)    # imm = 0x186A0
jb 0x16092
movl -0x30(%rsp), %eax
movl %eax, %ecx
leaq 0x7984(%rip), %rax      # 0x1da00
movb (%rax,%rcx), %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
movl -0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x795c(%rip), %rax      # 0x1da00
movb (%rax,%rcx), %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
movl -0x34(%rsp), %eax
movl %eax, %ecx
leaq 0x7939(%rip), %rax      # 0x1da00
movb (%rax,%rcx), %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
movl -0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x7911(%rip), %rax      # 0x1da00
movb (%rax,%rcx), %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
movl -0x38(%rsp), %eax
movl %eax, %ecx
leaq 0x78ee(%rip), %rax      # 0x1da00
movb (%rax,%rcx), %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
movl -0x38(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x78c6(%rip), %rax      # 0x1da00
movb (%rax,%rcx), %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
jmp 0x1638e
movl -0x4(%rsp), %eax
movl $0x5f5e100, %ecx        # imm = 0x5F5E100
xorl %edx, %edx
divl %ecx
movl %eax, -0x3c(%rsp)
movl -0x4(%rsp), %eax
movl $0x5f5e100, %ecx        # imm = 0x5F5E100
xorl %edx, %edx
divl %ecx
movl %edx, -0x4(%rsp)
cmpl $0xa, -0x3c(%rsp)
jb 0x161d5
movl -0x3c(%rsp), %eax
shll %eax
movl %eax, -0x40(%rsp)
movl -0x40(%rsp), %eax
movl %eax, %ecx
leaq 0x786b(%rip), %rax      # 0x1da00
movb (%rax,%rcx), %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
movl -0x40(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x7843(%rip), %rax      # 0x1da00
movb (%rax,%rcx), %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
jmp 0x161f4
movl -0x3c(%rsp), %eax
movsbl %al, %eax
addl $0x30, %eax
movb %al, %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
movl -0x4(%rsp), %eax
movl $0x2710, %ecx           # imm = 0x2710
xorl %edx, %edx
divl %ecx
movl %eax, -0x44(%rsp)
movl -0x4(%rsp), %eax
movl $0x2710, %ecx           # imm = 0x2710
xorl %edx, %edx
divl %ecx
movl %edx, -0x48(%rsp)
movl -0x44(%rsp), %eax
movl $0x64, %ecx
xorl %edx, %edx
divl %ecx
shll %eax
movl %eax, -0x4c(%rsp)
movl -0x44(%rsp), %eax
movl $0x64, %ecx
xorl %edx, %edx
divl %ecx
shll %edx
movl %edx, -0x50(%rsp)
movl -0x48(%rsp), %eax
movl $0x64, %ecx
xorl %edx, %edx
divl %ecx
shll %eax
movl %eax, -0x54(%rsp)
movl -0x48(%rsp), %eax
movl $0x64, %ecx
xorl %edx, %edx
divl %ecx
shll %edx
movl %edx, -0x58(%rsp)
movl -0x4c(%rsp), %eax
movl %eax, %ecx
leaq 0x7791(%rip), %rax      # 0x1da00
movb (%rax,%rcx), %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
movl -0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x7769(%rip), %rax      # 0x1da00
movb (%rax,%rcx), %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
movl -0x50(%rsp), %eax
movl %eax, %ecx
leaq 0x7746(%rip), %rax      # 0x1da00
movb (%rax,%rcx), %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
movl -0x50(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x771e(%rip), %rax      # 0x1da00
movb (%rax,%rcx), %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
movl -0x54(%rsp), %eax
movl %eax, %ecx
leaq 0x76fb(%rip), %rax      # 0x1da00
movb (%rax,%rcx), %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
movl -0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x76d3(%rip), %rax      # 0x1da00
movb (%rax,%rcx), %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
movl -0x58(%rsp), %eax
movl %eax, %ecx
leaq 0x76b0(%rip), %rax      # 0x1da00
movb (%rax,%rcx), %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
movl -0x58(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x7688(%rip), %rax      # 0x1da00
movb (%rax,%rcx), %cl
movq -0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movb %cl, (%rax)
jmp 0x16390
movq -0x10(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rsp)
movb $0x0, (%rax)
movq -0x10(%rsp), %rax
movq -0x18(%rsp), %rcx
subq %rcx, %rax
retq
nopw %cs:(%rax,%rax)