// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movl %edi, %ebx
leaq 0x20(%rsp), %r14
movq %rsi, 0x8(%r14)
movq %rdx, 0x10(%r14)
movq %rcx, 0x18(%r14)
movq %r8, 0x20(%r14)
movq %r9, 0x28(%r14)
testb %al, %al
je 0x32aac
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
callq 0x271bf
movabsq $0x3000000008, %rcx     # imm = 0x3000000008
movq %rcx, (%rsp)
leaq 0x200(%rsp), %rcx
movq %rcx, 0x8(%rsp)
movq %r14, 0x10(%rsp)
leaq 0x5d8fb(%rip), %r14     # 0x903d3
pushq $0x1
popq %r15
movl (%rsp), %edx
cmpq $0x28, %rdx
ja 0x32af5
movq %rdx, %rcx
addq 0x10(%rsp), %rcx
addl $0x8, %edx
movl %edx, (%rsp)
jmp 0x32b03
movq 0x8(%rsp), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movq (%rcx), %r12
testq %r12, %r12
je 0x32b2c
cmpl $0x0, -0x8(%rax)
je 0x32b1f
movq %rax, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2736d
movq %rax, %rdi
movq %r12, %rsi
callq 0x273bf
jmp 0x32adc
leaq 0x5cba0(%rip), %rsi     # 0x8f6d3
pushq $0x2
popq %rdx
movq %rax, %rdi
callq 0x2736d
movq %rax, %r14
movslq -0x8(%rax), %rdx
leaq 0x9445c(%rip), %r12     # 0xc6fa8
movslq 0x670(%r12), %rax
imulq $0x3e8, %rax, %rcx      # imm = 0x3E8
movl %ebx, %edi
movq %r14, %rsi
callq 0x4b630
movq %rax, %r15
movq %r14, %rdi
callq 0x271f7
cmpq $-0x1, %r15
je 0x32bae
movslq 0x670(%r12), %rax
imulq $0x3e8, %rax, %rcx      # imm = 0x3E8
leaq 0xd0(%rsp), %rsi
movl $0x100, %edx            # imm = 0x100
movl %ebx, %edi
callq 0x4b772
cmpq $-0x1, %rax
je 0x32bcb
leaq 0xd0(%rsp), %rdi
callq 0x271cd
jmp 0x32bf3
callq 0x271bf
movq %rax, %rbx
callq 0x1f810
movl (%rax), %edi
callq 0x1f630
leaq 0x5b55b(%rip), %rsi     # 0x8e124
jmp 0x32be6
callq 0x271bf
movq %rax, %rbx
callq 0x1f810
movl (%rax), %edi
callq 0x1f630
leaq 0x5b555(%rip), %rsi     # 0x8e13b
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2763d
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r14
popq %r15
retq