// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/replication.c
// Function: sendSynchronousCommand
char *sendSynchronousCommand(int fd, ...) {
    va_list ap;
    sds cmd = sdsempty();
    char *arg, buf[256];

    /* Create the command to send to the master, we use simple inline
     * protocol for simplicity as currently we only send simple strings. */
    va_start(ap,fd);
    while(1) {
        arg = va_arg(ap, char*);
        if (arg == NULL) break;

        if (sdslen(cmd) != 0) cmd = sdscatlen(cmd," ",1);
        cmd = sdscat(cmd,arg);
    }
    cmd = sdscatlen(cmd,"\r\n",2);

    /* Transfer command to the server. */
    // 发送命令到主服务器
    if (syncWrite(fd,cmd,sdslen(cmd),server.repl_syncio_timeout*1000) == -1) {
        sdsfree(cmd);
        return sdscatprintf(sdsempty(),"-Writing to master: %s",
                strerror(errno));
    }
    sdsfree(cmd);

    /* Read the reply from the server. */
    // 从主服务器中读取回复
    if (syncReadLine(fd,buf,sizeof(buf),server.repl_syncio_timeout*1000) == -1)
    {
        return sdscatprintf(sdsempty(),"-Reading from master: %s",
                strerror(errno));
    }
    return sdsnew(buf);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
testb %al, %al
je 0x41077
movaps %xmm0, -0x1c0(%rbp)
movaps %xmm1, -0x1b0(%rbp)
movaps %xmm2, -0x1a0(%rbp)
movaps %xmm3, -0x190(%rbp)
movaps %xmm4, -0x180(%rbp)
movaps %xmm5, -0x170(%rbp)
movaps %xmm6, -0x160(%rbp)
movaps %xmm7, -0x150(%rbp)
movq %r9, -0x1c8(%rbp)
movq %r8, -0x1d0(%rbp)
movq %rcx, -0x1d8(%rbp)
movq %rdx, -0x1e0(%rbp)
movq %rsi, -0x1e8(%rbp)
movl %edi, -0xc(%rbp)
callq 0x2c0c0
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rax
leaq -0x1f0(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x8, (%rax)
leaq -0x30(%rbp), %rax
movq %rax, -0x200(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x1f4(%rbp)
cmpl $0x28, %eax
ja 0x41105
movq -0x200(%rbp), %rcx
movl -0x1f4(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x208(%rbp)
jmp 0x41122
movq -0x200(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x208(%rbp)
movq -0x208(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x41139
jmp 0x41177
movq -0x38(%rbp), %rdi
callq 0x3ed00
cmpq $0x0, %rax
je 0x41161
movq -0x38(%rbp), %rdi
leaq 0xa338b(%rip), %rsi     # 0xe44de
movl $0x1, %edx
callq 0x2c500
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x2c5b0
movq %rax, -0x38(%rbp)
jmp 0x410ca
movq -0x38(%rbp), %rdi
leaq 0xa265c(%rip), %rsi     # 0xe37de
movl $0x2, %edx
callq 0x2c500
movq %rax, -0x38(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x214(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x210(%rbp)
movq -0x38(%rbp), %rdi
callq 0x3ed00
movl -0x214(%rbp), %edi
movq -0x210(%rbp), %rsi
movq %rax, %rdx
leaq 0xd2734(%rip), %rax     # 0x1138f8
imull $0x3e8, 0x670(%rax), %eax # imm = 0x3E8
movslq %eax, %rcx
callq 0x67bb0
cmpq $-0x1, %rax
jne 0x4121b
movq -0x38(%rbp), %rdi
callq 0x2c160
callq 0x2c0c0
movq %rax, -0x220(%rbp)
callq 0x1f820
movl (%rax), %edi
callq 0x1f630
movq -0x220(%rbp), %rdi
movq %rax, %rdx
leaq 0xa101e(%rip), %rsi     # 0xe222c
movb $0x0, %al
callq 0x2cad0
movq %rax, -0x8(%rbp)
jmp 0x41298
movq -0x38(%rbp), %rdi
callq 0x2c160
movl -0xc(%rbp), %edi
leaq -0x140(%rbp), %rsi
leaq 0xd26c3(%rip), %rax     # 0x1138f8
imull $0x3e8, 0x670(%rax), %eax # imm = 0x3E8
movslq %eax, %rcx
movl $0x100, %edx            # imm = 0x100
callq 0x67e10
cmpq $-0x1, %rax
jne 0x41288
callq 0x2c0c0
movq %rax, -0x228(%rbp)
callq 0x1f820
movl (%rax), %edi
callq 0x1f630
movq -0x228(%rbp), %rdi
movq %rax, %rdx
leaq 0xa0fc8(%rip), %rsi     # 0xe2243
movb $0x0, %al
callq 0x2cad0
movq %rax, -0x8(%rbp)
jmp 0x41298
leaq -0x140(%rbp), %rdi
callq 0x2c0e0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
nopw %cs:(%rax,%rax)