// File: /workspace/github_c_makefile_star2_O1/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 0x4be1
movq %rcx, %r14
movq %rdx, %r13
movl %esi, %ebp
movl $0x1, %r12d
cmpl $0xa, %esi
jb 0x4ad9
movslq %ebp, %rcx
movl $0x4, %r12d
movabsq $0x346dc5d63886594b, %rsi # imm = 0x346DC5D63886594B
cmpq $0x63, %rcx
jbe 0x4ad0
cmpq $0x3e7, %rcx            # imm = 0x3E7
jbe 0x4ad6
cmpq $0x2710, %rcx           # imm = 0x2710
jb 0x4ad9
movq %rcx, %rax
mulq %rsi
shrq $0xb, %rdx
addl $0x4, %r12d
cmpq $0x1869f, %rcx          # imm = 0x1869F
movq %rdx, %rcx
ja 0x4a98
addl $-0x3, %r12d
jmp 0x4ad9
addl $-0x2, %r12d
jmp 0x4ad9
decl %r12d
addl $0x3, %r12d
movl %ebp, %eax
movq %rax, 0x10(%rsp)
testl %ebp, %ebp
movq %rdi, 0x18(%rsp)
jle 0x4b1a
xorl %r15d, %r15d
testq %r14, %r14
je 0x4afb
movq (%r14,%r15,8), %rdi
jmp 0x4b08
movq (%r13,%r15,8), %rdi
callq 0x3130
movq %rax, %rdi
callq 0x47a4
addl %eax, %r12d
incq %r15
cmpq %r15, 0x10(%rsp)
jne 0x4af0
movq %r13, 0x8(%rsp)
leal 0x1(%r12), %eax
movslq %eax, %rdi
callq 0x3340
testq %rax, %rax
je 0x4be1
movq %rax, %r13
leaq 0x4598(%rip), %rsi      # 0x90d7
movq %rax, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x3460
movl %eax, %ebx
testl %ebp, %ebp
jle 0x4bc8
xorl %r15d, %r15d
movq %r14, 0x20(%rsp)
testq %r14, %r14
je 0x4b69
movq (%r14,%r15,8), %rbp
movq 0x8(%rsp), %r14
jmp 0x4b7a
movq 0x8(%rsp), %r14
movq (%r14,%r15,8), %rdi
callq 0x3130
movq %rax, %rbp
movslq %ebx, %rbx
leaq (%rbx,%r13), %rdi
leaq 0x4555(%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 0x4b59
cmpl %r12d, %ebx
jne 0x4bf2
movslq %ebx, %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 0x44eb(%rip), %rdi      # 0x90e4
leaq 0x44f2(%rip), %rsi      # 0x90f2
leaq 0x45a5(%rip), %rcx      # 0x91ac
movl $0x231, %edx            # imm = 0x231
callq 0x31b0