// File: /workspace/github_c_makefile_star2_O3/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 0x34ca4
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 0x2845e
movabsq $0x3000000008, %rcx     # imm = 0x3000000008
movq %rcx, (%rsp)
leaq 0x200(%rsp), %rcx
movq %rcx, 0x8(%rsp)
movq %r14, 0x10(%rsp)
leaq 0x6573f(%rip), %r14     # 0x9a40f
movl (%rsp), %edx
cmpq $0x28, %rdx
ja 0x34ce9
movq %rdx, %rcx
addq 0x10(%rsp), %rcx
addl $0x8, %edx
movl %edx, (%rsp)
jmp 0x34cf7
movq 0x8(%rsp), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movq (%rcx), %r15
testq %r15, %r15
je 0x34d22
cmpl $0x0, -0x8(%rax)
je 0x34d15
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x28689
movq %rax, %rdi
movq %r15, %rsi
callq 0x286db
jmp 0x34cd0
leaq 0x649e6(%rip), %rsi     # 0x9970f
movl $0x2, %edx
movq %rax, %rdi
callq 0x28689
movq %rax, %r14
movslq -0x8(%rax), %rdx
leaq 0x95264(%rip), %r12     # 0xc9fa8
movslq 0x670(%r12), %rax
imulq $0x3e8, %rax, %rcx      # imm = 0x3E8
movl %ebx, %edi
movq %r14, %rsi
callq 0x4f4d0
movq %rax, %r15
movq %r14, %rdi
callq 0x2850d
cmpq $-0x1, %r15
je 0x34da6
movslq 0x670(%r12), %rax
imulq $0x3e8, %rax, %rcx      # imm = 0x3E8
leaq 0xd0(%rsp), %rsi
movl $0x100, %edx            # imm = 0x100
movl %ebx, %edi
callq 0x4f62f
cmpq $-0x1, %rax
je 0x34dc3
leaq 0xd0(%rsp), %rdi
callq 0x28486
jmp 0x34deb
callq 0x2845e
movq %rax, %rbx
callq 0x1f810
movl (%rax), %edi
callq 0x1f630
leaq 0x6339f(%rip), %rsi     # 0x98160
jmp 0x34dde
callq 0x2845e
movq %rax, %rbx
callq 0x1f810
movl (%rax), %edi
callq 0x1f630
leaq 0x63399(%rip), %rsi     # 0x98177
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x28a5e
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r14
popq %r15
retq