// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x57d2
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x59a1
movslq -0x14(%rbp), %rdi
callq 0x5450
addl $0x1, %eax
addl $0x2, %eax
movl %eax, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x584a
cmpq $0x0, -0x28(%rbp)
je 0x580c
movq -0x28(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
jmp 0x5821
movq -0x20(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3140
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0x5420
movq %rax, %rcx
movslq -0x44(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x44(%rbp)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x57eb
movl -0x44(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
callq 0x3350
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x586f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x59a1
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %edx
leaq 0x787f(%rip), %rsi      # 0xd0fc
movb $0x0, %al
callq 0x3470
movl %eax, -0x34(%rbp)
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x595b
cmpq $0x0, -0x28(%rbp)
je 0x58b3
movq -0x28(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
jmp 0x58c8
movq -0x20(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3140
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rdi
movslq -0x34(%rbp), %rax
addq %rax, %rdi
movq -0x40(%rbp), %rdx
leaq 0x781c(%rip), %rsi      # 0xd102
movb $0x0, %al
callq 0x3470
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rdi
movslq -0x34(%rbp), %rax
addq %rax, %rdi
movq -0x20(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x40(%rbp), %rdx
callq 0x32f0
movq -0x40(%rbp), %rcx
movslq -0x34(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rax
movl -0x34(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x34(%rbp)
movslq %ecx, %rcx
movb $0xd, (%rax,%rcx)
movq -0x30(%rbp), %rax
movl -0x34(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x34(%rbp)
movslq %ecx, %rcx
movb $0xa, (%rax,%rcx)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x588e
movl -0x34(%rbp), %eax
cmpl -0x44(%rbp), %eax
jne 0x5965
jmp 0x5984
leaq 0x779d(%rip), %rdi      # 0xd109
leaq 0x77a4(%rip), %rsi      # 0xd117
movl $0x231, %edx            # imm = 0x231
leaq 0x7852(%rip), %rcx      # 0xd1d1
callq 0x31c0
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)