// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/redis-cli.c
// Function: cliFormatReplyTTY
static sds cliFormatReplyTTY(redisReply *r, char *prefix) {
    sds out = sdsempty();
    switch (r->type) {
    case REDIS_REPLY_ERROR:
        out = sdscatprintf(out,"(error) %s\n", r->str);
    break;
    case REDIS_REPLY_STATUS:
        out = sdscat(out,r->str);
        out = sdscat(out,"\n");
    break;
    case REDIS_REPLY_INTEGER:
        out = sdscatprintf(out,"(integer) %lld\n",r->integer);
    break;
    case REDIS_REPLY_STRING:
        /* If you are producing output for the standard output we want
        * a more interesting output with quoted characters and so forth */
        out = sdscatrepr(out,r->str,r->len);
        out = sdscat(out,"\n");
    break;
    case REDIS_REPLY_NIL:
        out = sdscat(out,"(nil)\n");
    break;
    case REDIS_REPLY_ARRAY:
        if (r->elements == 0) {
            out = sdscat(out,"(empty list or set)\n");
        } else {
            unsigned int i, idxlen = 0;
            char _prefixlen[16];
            char _prefixfmt[16];
            sds _prefix;
            sds tmp;

            /* Calculate chars needed to represent the largest index */
            i = r->elements;
            do {
                idxlen++;
                i /= 10;
            } while(i);

            /* Prefix for nested multi bulks should grow with idxlen+2 spaces */
            memset(_prefixlen,' ',idxlen+2);
            _prefixlen[idxlen+2] = '\0';
            _prefix = sdscat(sdsnew(prefix),_prefixlen);

            /* Setup prefix format for every entry */
            snprintf(_prefixfmt,sizeof(_prefixfmt),"%%s%%%ud) ",idxlen);

            for (i = 0; i < r->elements; i++) {
                /* Don't use the prefix for the first element, as the parent
                 * caller already prepended the index number. */
                out = sdscatprintf(out,_prefixfmt,i == 0 ? "" : prefix,i+1);

                /* Format the multi bulk entry */
                tmp = cliFormatReplyTTY(r->element[i],_prefix);
                out = sdscatlen(out,tmp,sdslen(tmp));
                sdsfree(tmp);
            }
            sdsfree(_prefix);
        }
    break;
    default:
        fprintf(stderr,"Unknown reply type: %d\n", r->type);
        exit(1);
    }
    return out;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, %rbx
callq 0x18ec4
movq %rax, %r15
movl (%rbx), %edx
leal -0x1(%rdx), %eax
cmpl $0x5, %eax
ja 0x1587b
leaq 0x25b5e(%rip), %rcx     # 0x3b254
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x18(%rbx), %rsi
movslq 0x10(%rbx), %rdx
movq %r15, %rdi
callq 0x19f69
jmp 0x1571d
movq 0x18(%rbx), %rsi
movq %r15, %rdi
callq 0x1952f
leaq 0x2aabb(%rip), %rsi     # 0x401df
movq %rax, %rdi
jmp 0x15868
movq 0x8(%rbx), %rdx
leaq 0x2a774(%rip), %rsi     # 0x3feab
jmp 0x1582c
leaq 0x2a778(%rip), %rsi     # 0x3febb
jmp 0x15865
movq 0x20(%rbx), %rcx
testq %rcx, %rcx
je 0x1585e
pushq $0x2
popq %rbp
pushq $0xa
popq %rsi
movl %ecx, %eax
xorl %edx, %edx
divl %esi
incl %ebp
cmpl $0x9, %ecx
movl %eax, %ecx
ja 0x1575b
movl %ebp, %r12d
leaq 0x10(%rsp), %r13
pushq $0x20
popq %rsi
movq %r13, %rdi
movq %r12, %rdx
callq 0x10270
movb $0x0, 0x10(%rsp,%r12)
movq %r14, %rdi
callq 0x18ed2
movq %rax, %rdi
movq %r13, %rsi
callq 0x1952f
movq %rax, %r12
addl $-0x2, %ebp
leaq 0x2a731(%rip), %rdx     # 0x3fed7
movq %rsp, %rdi
pushq $0x10
popq %rsi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x10200
xorl %ebp, %ebp
movl %ebp, %r13d
cmpq %r13, 0x20(%rbx)
jbe 0x15844
testq %r13, %r13
movq %r14, %rdx
leaq 0x2aa0f(%rip), %rax     # 0x401e0
cmoveq %rax, %rdx
leal 0x1(%r13), %ebp
movq %r15, %rdi
movq %rsp, %rsi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x197b0
movq %rax, %r15
movq 0x28(%rbx), %rax
movq (%rax,%r13,8), %rdi
movq %r12, %rsi
callq 0x156c5
movq %rax, %r13
movq %rax, %rdi
callq 0x159d8
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x194d0
movq %rax, %r15
movq %r13, %rdi
callq 0x18f40
jmp 0x157b7
movq 0x18(%rbx), %rdx
leaq 0x2a673(%rip), %rsi     # 0x3fe9f
movq %r15, %rdi
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x197b0
movq %r12, %rdi
callq 0x18f40
movq %r15, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2a65d(%rip), %rsi     # 0x3fec2
movq %r15, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1952f
movq 0x3e776(%rip), %rax     # 0x53ff8
movq (%rax), %rdi
leaq 0x2a5fb(%rip), %rsi     # 0x3fe87
xorl %eax, %eax
callq 0x103b0
pushq $0x1
popq %rdi
callq 0x10630