// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/src/cluster.c
// Function: migrateGetSocket
migrateCachedSocket* migrateGetSocket(client *c, robj *host, robj *port, long timeout) {
    int fd;
    sds name = sdsempty();
    migrateCachedSocket *cs;

    /* Check if we have an already cached socket for this ip:port pair. */
    name = sdscatlen(name,host->ptr,sdslen(host->ptr));
    name = sdscatlen(name,":",1);
    name = sdscatlen(name,port->ptr,sdslen(port->ptr));
    cs = dictFetchValue(server.migrate_cached_sockets,name);
    if (cs) {
        sdsfree(name);
        cs->last_use_time = server.unixtime;
        return cs;
    }

    /* No cached socket, create one. */
    if (dictSize(server.migrate_cached_sockets) == MIGRATE_SOCKET_CACHE_ITEMS) {
        /* Too many items, drop one at random. */
        dictEntry *de = dictGetRandomKey(server.migrate_cached_sockets);
        cs = dictGetVal(de);
        close(cs->fd);
        zfree(cs);
        dictDelete(server.migrate_cached_sockets,dictGetKey(de));
    }

    /* Create the socket */
    fd = anetTcpNonBlockConnect(server.neterr,c->argv[1]->ptr,
                                atoi(c->argv[2]->ptr));
    if (fd == -1) {
        sdsfree(name);
        addReplyErrorFormat(c,"Can't connect to target node: %s",
            server.neterr);
        return NULL;
    }
    anetEnableTcpNoDelay(server.neterr,fd);

    /* Check if it connects within the specified timeout. */
    if ((aeWait(fd,AE_WRITABLE,timeout) & AE_WRITABLE) == 0) {
        sdsfree(name);
        addReplySds(c,
            sdsnew("-IOERR error or timeout connecting to the client\r\n"));
        close(fd);
        return NULL;
    }

    /* Add to the cache and return it to the caller. */
    cs = zmalloc(sizeof(*cs));
    cs->fd = fd;
    cs->last_dbid = -1;
    cs->last_use_time = server.unixtime;
    dictAdd(server.migrate_cached_sockets,name,cs);
    return cs;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r13
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
callq 0x3628d
movq 0x8(%r12), %rsi
movzbl -0x1(%rsi), %edx
movl %edx, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x6bbee
leaq 0x5b98b(%rip), %rdi     # 0xc7554
movslq (%rdi,%rcx,4), %rcx
addq %rdi, %rcx
jmpq *%rcx
shrl $0x3, %edx
jmp 0x6bbf0
movq -0x11(%rsi), %rdx
jmp 0x6bbf0
movzwl -0x5(%rsi), %edx
jmp 0x6bbf0
movl -0x9(%rsi), %edx
jmp 0x6bbf0
movzbl -0x3(%rsi), %edx
jmp 0x6bbf0
xorl %edx, %edx
movq %rax, %rdi
callq 0x36ad1
leaq 0x5b62e(%rip), %rsi     # 0xc722d
movl $0x1, %edx
movq %rax, %rdi
callq 0x36ad1
movq 0x8(%r15), %rsi
movzbl -0x1(%rsi), %edx
movl %edx, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x6bc4a
leaq 0x5b943(%rip), %rdi     # 0xc7568
movslq (%rdi,%rcx,4), %rcx
addq %rdi, %rcx
jmpq *%rcx
shrl $0x3, %edx
jmp 0x6bc4c
movq -0x11(%rsi), %rdx
jmp 0x6bc4c
movzwl -0x5(%rsi), %edx
jmp 0x6bc4c
movl -0x9(%rsi), %edx
jmp 0x6bc4c
movzbl -0x3(%rsi), %edx
jmp 0x6bc4c
xorl %edx, %edx
movq %rax, %rdi
callq 0x36ad1
movq %rax, %r15
leaq 0x95c4a(%rip), %r14     # 0x1018a8
movq 0x308(%r14), %rdi
movq %rax, %rsi
callq 0x2ef19
testq %rax, %rax
je 0x6bc9b
movq %rax, %r12
movq %r15, %rdi
callq 0x36330
movq 0x978(%r14), %rax
movq %rax, 0x10(%r12)
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, (%rsp)
movq 0x308(%r14), %rdi
movq 0x48(%rdi), %rax
addq 0x28(%rdi), %rax
cmpq $0x40, %rax
jne 0x6bce1
callq 0x2f141
movq %rax, %r12
movq 0x8(%rax), %r13
movl (%r13), %edi
callq 0x26180
movq %r13, %rdi
callq 0x38413
movq 0x308(%r14), %rdi
movq (%r12), %rsi
callq 0x2ecb5
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rcx
movq 0x10(%rax), %rax
movq 0x8(%rcx), %r12
movq 0x8(%rax), %rdi
callq 0x26760
movl $0x208, %r13d           # imm = 0x208
addq 0x912b1(%rip), %r13     # 0xfcfb8
movq %r13, %rdi
movq %r12, %rsi
movl %eax, %edx
callq 0x2dcd3
cmpl $-0x1, %eax
je 0x6bd67
movl %eax, %ebp
movq %r13, %rdi
movl %eax, %esi
callq 0x2d7d3
movl %ebp, %edi
movl $0x2, %esi
movq (%rsp), %rdx
callq 0x2d4e5
testb $0x2, %al
jne 0x6bd8b
movq %r15, %rdi
callq 0x36330
leaq 0x5d2ae(%rip), %rdi     # 0xc8ff6
callq 0x362b0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3ca86
movl %ebp, %edi
callq 0x26180
xorl %r12d, %r12d
jmp 0x6bc89
movq %r15, %rdi
callq 0x36330
leaq 0x5d25f(%rip), %rsi     # 0xc8fd5
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0x3cc2d
jmp 0x6bc89
movl $0x18, %edi
callq 0x382d1
movq %rax, %r12
movl %ebp, (%rax)
movq $-0x1, 0x8(%rax)
movq 0x978(%r14), %rax
movq %rax, 0x10(%r12)
movq 0x308(%r14), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x2e9b8
jmp 0x6bc89