// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/replication.c
// Function: sendSynchronousCommand
char *sendSynchronousCommand(int flags, int fd, ...) {

    /* Create the command to send to the master, we use simple inline
     * protocol for simplicity as currently we only send simple strings. */
    if (flags & SYNC_CMD_WRITE) {
        char *arg;
        va_list ap;
        sds cmd = sdsempty();
        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);
        va_end(ap);
    }

    /* Read the reply from the server. */
    if (flags & SYNC_CMD_READ) {
        char buf[256];

        if (syncReadLine(fd,buf,sizeof(buf),server.repl_syncio_timeout*1000)
            == -1)
        {
            return sdscatprintf(sdsempty(),"-Reading from master: %s",
                    strerror(errno));
        }
        server.repl_transfer_lastio = server.unixtime;
        return sdsnew(buf);
    }
    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1b0, %rsp            # imm = 0x1B0
movl %esi, %ebx
movl %edi, %ebp
movq %rdx, 0x110(%rsp)
movq %rcx, 0x118(%rsp)
movq %r8, 0x120(%rsp)
movq %r9, 0x128(%rsp)
testb %al, %al
je 0x49004
movaps %xmm0, 0x130(%rsp)
movaps %xmm1, 0x140(%rsp)
movaps %xmm2, 0x150(%rsp)
movaps %xmm3, 0x160(%rsp)
movaps %xmm4, 0x170(%rsp)
movaps %xmm5, 0x180(%rsp)
movaps %xmm6, 0x190(%rsp)
movaps %xmm7, 0x1a0(%rsp)
testb $0x2, %bpl
je 0x49188
callq 0x39222
movabsq $0x3000000010, %rcx     # imm = 0x3000000010
movq %rcx, (%rsp)
leaq 0x1e0(%rsp), %rcx
movq %rcx, 0x8(%rsp)
leaq 0x100(%rsp), %rcx
movq %rcx, 0x10(%rsp)
leaq 0x7ebef(%rip), %r14     # 0xc7c31
leaq 0x7b0df(%rip), %r12     # 0xc4128
movl (%rsp), %edx
cmpq $0x28, %rdx
ja 0x49062
movq %rdx, %rcx
addq 0x10(%rsp), %rcx
addl $0x8, %edx
movl %edx, (%rsp)
jmp 0x49070
movq 0x8(%rsp), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movq (%rcx), %r15
testq %r15, %r15
je 0x490d2
movzbl -0x1(%rax), %ecx
movl %ecx, %edx
andl $0x7, %edx
cmpl $0x4, %edx
ja 0x490ab
movslq (%r12,%rdx,4), %rdx
addq %r12, %rdx
jmpq *%rdx
shrl $0x3, %ecx
jmp 0x490ad
movq -0x11(%rax), %rcx
jmp 0x490ad
movzwl -0x5(%rax), %ecx
jmp 0x490ad
movl -0x9(%rax), %ecx
jmp 0x490ad
movzbl -0x3(%rax), %ecx
jmp 0x490ad
xorl %ecx, %ecx
testq %rcx, %rcx
je 0x490c2
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x39a56
movq %rax, %rdi
movq %r15, %rsi
callq 0x39b26
jmp 0x49049
leaq 0x7dc97(%rip), %rsi     # 0xc6d70
movl $0x2, %edx
movq %rax, %rdi
callq 0x39a56
movq %rax, %r14
movzbl -0x1(%rax), %edx
movl %edx, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x49126
leaq 0x7b03e(%rip), %rcx     # 0xc413c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
shrl $0x3, %edx
jmp 0x49128
movq -0x11(%r14), %rdx
jmp 0x49128
movzwl -0x5(%r14), %edx
jmp 0x49128
movl -0x9(%r14), %edx
jmp 0x49128
movzbl -0x3(%r14), %edx
jmp 0x49128
xorl %edx, %edx
leaq 0xbd729(%rip), %rax     # 0x106858
movslq 0x838(%rax), %rax
imulq $0x3e8, %rax, %rcx      # imm = 0x3E8
movl %ebx, %edi
movq %r14, %rsi
callq 0x68a80
movq %rax, %r15
movq %r14, %rdi
callq 0x392b6
cmpq $-0x1, %r15
je 0x4915a
jmp 0x49182
callq 0x39222
movq %rax, %r14
callq 0x26890
movl (%rax), %edi
callq 0x26690
leaq 0x7bc46(%rip), %rsi     # 0xc4dbb
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x39eb7
cmpq $-0x1, %r15
je 0x491fc
testb $0x1, %bpl
jne 0x49192
xorl %eax, %eax
jmp 0x491fc
leaq 0xbd6bf(%rip), %r14     # 0x106858
movslq 0x838(%r14), %rax
imulq $0x3e8, %rax, %rcx      # imm = 0x3E8
movq %rsp, %rsi
movl $0x100, %edx            # imm = 0x100
movl %ebx, %edi
callq 0x68c35
cmpq $-0x1, %rax
je 0x491d4
movq 0x968(%r14), %rax
movq %rax, 0x868(%r14)
movq %rsp, %rdi
callq 0x39245
jmp 0x491fc
callq 0x39222
movq %rax, %rbx
callq 0x26890
movl (%rax), %edi
callq 0x26690
leaq 0x7bbe3(%rip), %rsi     # 0xc4dd2
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x39eb7
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq