// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/util.c
// Function: ll2string
int ll2string(char* dst, size_t dstlen, long long svalue) {
    static const char digits[201] =
        "0001020304050607080910111213141516171819"
        "2021222324252627282930313233343536373839"
        "4041424344454647484950515253545556575859"
        "6061626364656667686970717273747576777879"
        "8081828384858687888990919293949596979899";
    int negative;
    unsigned long long value;

    /* The main loop works with 64bit unsigned integers for simplicity, so
     * we convert the number here and remember if it is negative. */
    if (svalue < 0) {
        if (svalue != LLONG_MIN) {
            value = -svalue;
        } else {
            value = ((unsigned long long) LLONG_MAX)+1;
        }
        negative = 1;
    } else {
        value = svalue;
        negative = 0;
    }

    /* Check length. */
    uint32_t const length = digits10(value)+negative;
    if (length >= dstlen) return 0;

    /* Null term. */
    uint32_t next = length;
    dst[next] = '\0';
    next--;
    while (value >= 100) {
        int const i = (value % 100) * 2;
        value /= 100;
        dst[next] = digits[i + 1];
        dst[next - 1] = digits[i];
        next -= 2;
    }

    /* Handle last 1-2 digits. */
    if (value < 10) {
        dst[next] = '0' + (uint32_t) value;
    } else {
        int i = (uint32_t) value * 2;
        dst[next] = digits[i + 1];
        dst[next - 1] = digits[i];
    }

    /* Add sign. */
    if (negative) dst[0] = '-';
    return length;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jge 0x4782e
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
cmpq %rax, -0x20(%rbp)
je 0x47817
xorl %eax, %eax
subq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x47825
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movq %rax, -0x30(%rbp)
movl $0x1, -0x24(%rbp)
jmp 0x4783d
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x30(%rbp), %rdi
callq 0x47640
addl -0x24(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpq -0x18(%rbp), %rax
jb 0x47861
movl $0x0, -0x4(%rbp)
jmp 0x47961
movl -0x34(%rbp), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
movb $0x0, (%rax,%rcx)
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
cmpq $0x64, -0x30(%rbp)
jb 0x478ef
movq -0x30(%rbp), %rax
movl $0x64, %ecx
xorl %edx, %edx
divq %rcx
shlq %rdx
movl %edx, %eax
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rax
movl $0x64, %ecx
xorl %edx, %edx
divq %rcx
movq %rax, -0x30(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0xf3c66(%rip), %rax     # 0x13b520
movb (%rax,%rcx), %dl
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
movb %dl, (%rax,%rcx)
movslq -0x3c(%rbp), %rcx
leaq 0xf3c4e(%rip), %rax     # 0x13b520
movb (%rax,%rcx), %dl
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movl -0x38(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x38(%rbp)
jmp 0x4787b
cmpq $0xa, -0x30(%rbp)
jae 0x4790b
movq -0x30(%rbp), %rax
addl $0x30, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
movb %dl, (%rax,%rcx)
jmp 0x4794e
movq -0x30(%rbp), %rax
shll %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0xf3bfc(%rip), %rax     # 0x13b520
movb (%rax,%rcx), %dl
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
movb %dl, (%rax,%rcx)
movslq -0x40(%rbp), %rcx
leaq 0xf3be4(%rip), %rax     # 0x13b520
movb (%rax,%rcx), %dl
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
cmpl $0x0, -0x24(%rbp)
je 0x4795b
movq -0x10(%rbp), %rax
movb $0x2d, (%rax)
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)