// File: /workspace/github_c_makefile_star2_O3/andyfighting[P]hiredis_timer_cmpt/hiredis.c
// Function: redisFormatCommandArgv
int redisFormatCommandArgv(char **target, int argc, const char **argv, const size_t *argvlen) {
    char *cmd = NULL; /* final command */
    int pos; /* position in final command */
    size_t len;
    int totlen, j;

    /* Abort on a NULL target */
    if (target == NULL)
        return -1;

    /* Calculate number of bytes needed for the command */
    totlen = 1+countDigits(argc)+2;
    for (j = 0; j < argc; j++) {
        len = argvlen ? argvlen[j] : strlen(argv[j]);
        totlen += bulklen(len);
    }

    /* Build the command at protocol level */
    cmd = malloc(totlen+1);
    if (cmd == NULL)
        return -1;

    pos = sprintf(cmd,"*%d\r\n",argc);
    for (j = 0; j < argc; j++) {
        len = argvlen ? argvlen[j] : strlen(argv[j]);
        pos += sprintf(cmd+pos,"$%zu\r\n",len);
        memcpy(cmd+pos,argv[j],len);
        pos += len;
        cmd[pos++] = '\r';
        cmd[pos++] = '\n';
    }
    assert(pos == totlen);
    cmd[pos] = '\0';

    *target = cmd;
    return totlen;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x4ae0
movq %rcx, %r14
movq %rdx, %r13
movl %esi, %ebp
movl $0x1, %r12d
cmpl $0xa, %esi
jb 0x49d8
movslq %ebp, %rcx
movl $0x4, %r12d
movabsq $0x346dc5d63886594b, %rsi # imm = 0x346DC5D63886594B
cmpq $0x63, %rcx
jbe 0x49cf
cmpq $0x3e7, %rcx            # imm = 0x3E7
jbe 0x49d5
cmpq $0x2710, %rcx           # imm = 0x2710
jb 0x49d8
movq %rcx, %rax
mulq %rsi
shrq $0xb, %rdx
addl $0x4, %r12d
cmpq $0x1869f, %rcx          # imm = 0x1869F
movq %rdx, %rcx
ja 0x4997
addl $-0x3, %r12d
jmp 0x49d8
addl $-0x2, %r12d
jmp 0x49d8
decl %r12d
addl $0x3, %r12d
movl %ebp, %eax
movq %rax, 0x10(%rsp)
testl %ebp, %ebp
movq %rdi, 0x18(%rsp)
jle 0x4a19
xorl %r15d, %r15d
testq %r14, %r14
je 0x49fa
movq (%r14,%r15,8), %rdi
jmp 0x4a07
movq (%r13,%r15,8), %rdi
callq 0x3130
movq %rax, %rdi
callq 0x46a3
addl %eax, %r12d
incq %r15
cmpq %r15, 0x10(%rsp)
jne 0x49ef
movq %r13, 0x8(%rsp)
leal 0x1(%r12), %eax
movslq %eax, %rdi
callq 0x3340
testq %rax, %rax
je 0x4ae0
movq %rax, %r13
leaq 0x4699(%rip), %rsi      # 0x90d7
movq %rax, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x3460
movl %eax, %ebx
testl %ebp, %ebp
jle 0x4ac7
xorl %r15d, %r15d
movq %r14, 0x20(%rsp)
testq %r14, %r14
je 0x4a68
movq (%r14,%r15,8), %rbp
movq 0x8(%rsp), %r14
jmp 0x4a79
movq 0x8(%rsp), %r14
movq (%r14,%r15,8), %rdi
callq 0x3130
movq %rax, %rbp
movslq %ebx, %rbx
leaq (%rbx,%r13), %rdi
leaq 0x4656(%rip), %rsi      # 0x90dd
movq %rbp, %rdx
xorl %eax, %eax
callq 0x3460
addl %eax, %ebx
movslq %ebx, %rbx
leaq (%rbx,%r13), %rdi
movq (%r14,%r15,8), %rsi
movq %rbp, %rdx
callq 0x32f0
leal (%rbx,%rbp), %eax
cltq
movw $0xa0d, (%r13,%rax)     # imm = 0xA0D
addl %ebp, %ebx
addl $0x2, %ebx
incq %r15
cmpq %r15, 0x10(%rsp)
movq 0x20(%rsp), %r14
jne 0x4a58
cmpl %r12d, %ebx
jne 0x4af1
movslq %r12d, %rax
movb $0x0, (%r13,%rax)
movq 0x18(%rsp), %rax
movq %r13, (%rax)
movl %r12d, %ebx
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x45ec(%rip), %rdi      # 0x90e4
leaq 0x45f3(%rip), %rsi      # 0x90f2
leaq 0x46a6(%rip), %rcx      # 0x91ac
movl $0x231, %edx            # imm = 0x231
callq 0x31b0