// File: /workspace/github_c_makefile_star2_O1/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 0x34860
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 0x281b2
movabsq $0x3000000008, %rcx     # imm = 0x3000000008
movq %rcx, (%rsp)
leaq 0x200(%rsp), %rcx
movq %rcx, 0x8(%rsp)
movq %r14, 0x10(%rsp)
leaq 0x65b3b(%rip), %r14     # 0x9a3c7
movl (%rsp), %edx
cmpq $0x28, %rdx
ja 0x348a5
movq %rdx, %rcx
addq 0x10(%rsp), %rcx
addl $0x8, %edx
movl %edx, (%rsp)
jmp 0x348b3
movq 0x8(%rsp), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movq (%rcx), %r15
testq %r15, %r15
je 0x348de
cmpl $0x0, -0x8(%rax)
je 0x348d1
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x28380
movq %rax, %rdi
movq %r15, %rsi
callq 0x283d7
jmp 0x3488c
leaq 0x64de2(%rip), %rsi     # 0x996c7
movl $0x2, %edx
movq %rax, %rdi
callq 0x28380
movq %rax, %r14
movslq -0x8(%rax), %rdx
leaq 0x956a8(%rip), %r12     # 0xc9fa8
movslq 0x670(%r12), %rax
imulq $0x3e8, %rax, %rcx      # imm = 0x3E8
movl %ebx, %edi
movq %r14, %rsi
callq 0x4fa20
movq %rax, %r15
movq %r14, %rdi
callq 0x28204
cmpq $-0x1, %r15
je 0x34962
movslq 0x670(%r12), %rax
imulq $0x3e8, %rax, %rcx      # imm = 0x3E8
leaq 0xd0(%rsp), %rsi
movl $0x100, %edx            # imm = 0x100
movl %ebx, %edi
callq 0x4fbd5
cmpq $-0x1, %rax
je 0x3497f
leaq 0xd0(%rsp), %rdi
callq 0x281da
jmp 0x349a7
callq 0x281b2
movq %rax, %rbx
callq 0x1f810
movl (%rax), %edi
callq 0x1f630
leaq 0x63773(%rip), %rsi     # 0x980f0
jmp 0x3499a
callq 0x281b2
movq %rax, %rbx
callq 0x1f810
movl (%rax), %edi
callq 0x1f630
leaq 0x6376d(%rip), %rsi     # 0x98107
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x28760
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r14
popq %r15
retq