// File: /workspace/github_c_makefile_star2_O3/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 0x1d966
movq %rax, %r15
movl (%rbx), %edi
leal -0x1(%rdi), %eax
cmpl $0x5, %eax
ja 0x19b1e
leaq 0x26984(%rip), %rcx     # 0x402d0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x18(%rbx), %rsi
movslq 0x10(%rbx), %rdx
movq %r15, %rdi
callq 0x1f313
jmp 0x19973
movq 0x18(%rbx), %rsi
movq %r15, %rdi
callq 0x1e279
leaq 0x2b915(%rip), %rsi     # 0x4528f
movq %rax, %rdi
jmp 0x19b0b
movq 0x8(%rbx), %rdx
leaq 0x2b5ce(%rip), %rsi     # 0x44f5b
jmp 0x19ae9
leaq 0x2b5d2(%rip), %rsi     # 0x44f6b
jmp 0x19b08
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x19b01
movl $0x2, %ebp
movl $0xcccccccd, %ecx       # imm = 0xCCCCCCCD
movl %eax, %edx
imulq %rcx, %rdx
shrq $0x23, %rdx
incl %ebp
cmpl $0x9, %eax
movl %edx, %eax
ja 0x199b5
movl %ebp, %r12d
leaq 0x10(%rsp), %r13
movq %r13, %rdi
movl $0x20, %esi
movq %r12, %rdx
callq 0x10270
movb $0x0, 0x10(%rsp,%r12)
movq %r14, %rdi
callq 0x1d989
movq %rax, %rdi
movq %r13, %rsi
callq 0x1e279
movq %rax, %r12
addl $-0x2, %ebp
leaq 0x2b581(%rip), %rdx     # 0x44f87
movq %rsp, %rdi
movl $0x10, %esi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x10200
cmpq $0x0, 0x20(%rbx)
je 0x19ac4
movl $0x1, %ebp
xorl %r13d, %r13d
cmpl $0x1, %ebp
movq %r14, %rdx
leaq 0x2b859(%rip), %rax     # 0x45290
cmoveq %rax, %rdx
movq %r15, %rdi
movq %rsp, %rsi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x1e60a
movq %rax, %r15
movq 0x28(%rbx), %rax
movq (%rax,%r13,8), %rdi
movq %r12, %rsi
callq 0x1991b
movq %rax, %r13
movzbl -0x1(%rax), %edx
movl %edx, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x19a9d
leaq 0x26873(%rip), %rcx     # 0x402e8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
shrl $0x3, %edx
jmp 0x19a9f
movq -0x11(%r13), %rdx
jmp 0x19a9f
movzwl -0x5(%r13), %edx
jmp 0x19a9f
movl -0x9(%r13), %edx
jmp 0x19a9f
movzbl -0x3(%r13), %edx
jmp 0x19a9f
xorl %edx, %edx
movq %r15, %rdi
movq %r13, %rsi
callq 0x1e1ae
movq %rax, %r15
movq %r13, %rdi
callq 0x1da09
movl %ebp, %r13d
incl %ebp
cmpq %r13, 0x20(%rbx)
ja 0x19a2a
movq %r12, %rdi
callq 0x1da09
movq %r15, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rbx), %rdx
leaq 0x2b466(%rip), %rsi     # 0x44f4f
movq %r15, %rdi
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1e60a
leaq 0x2b46a(%rip), %rsi     # 0x44f72
movq %r15, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1e279
callq 0x10e7b