// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
callq 0x384f0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7cf60
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq %rax, %rdx
callq 0x39040
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
leaq 0xc5c74(%rip), %rsi     # 0x14b898
movl $0x1, %edx
callq 0x39040
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7cf60
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq %rax, %rdx
callq 0x39040
movq %rax, -0x38(%rbp)
leaq 0xf256a(%rip), %rax     # 0x1781d8
movq 0x308(%rax), %rdi
movq -0x38(%rbp), %rsi
callq 0x2e280
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x85cb5
movq -0x38(%rbp), %rdi
callq 0x38620
leaq 0xf253f(%rip), %rax     # 0x1781d8
movq 0x978(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x85e77
leaq 0xf251c(%rip), %rax     # 0x1781d8
movq 0x308(%rax), %rax
movq 0x28(%rax), %rax
leaq 0xf250a(%rip), %rcx     # 0x1781d8
movq 0x308(%rcx), %rcx
addq 0x48(%rcx), %rax
cmpq $0x40, %rax
jne 0x85d30
leaq 0xf24f2(%rip), %rax     # 0x1781d8
movq 0x308(%rax), %rdi
callq 0x2e6a0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movl (%rax), %edi
callq 0x26180
movq -0x40(%rbp), %rdi
callq 0x3afa0
leaq 0xf24bb(%rip), %rax     # 0x1781d8
movq 0x308(%rax), %rdi
movq -0x48(%rbp), %rax
movq (%rax), %rsi
callq 0x2de50
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rdi
callq 0x26760
movq -0x70(%rbp), %rsi
movl %eax, %edx
leaq 0xf2472(%rip), %rdi     # 0x1781d8
addq $0x208, %rdi            # imm = 0x208
callq 0x2c220
movl %eax, -0x2c(%rbp)
cmpl $-0x1, -0x2c(%rbp)
jne 0x85db1
movq -0x38(%rbp), %rdi
callq 0x38620
movq -0x10(%rbp), %rdi
leaq 0xbd2c7(%rip), %rsi     # 0x143056
leaq 0xf2442(%rip), %rdx     # 0x1781d8
addq $0x208, %rdx            # imm = 0x208
movb $0x0, %al
callq 0x42fd0
movq $0x0, -0x8(%rbp)
jmp 0x85e77
movl -0x2c(%rbp), %esi
leaq 0xf241d(%rip), %rdi     # 0x1781d8
addq $0x208, %rdi            # imm = 0x208
callq 0x2ba60
movl -0x2c(%rbp), %edi
movq -0x28(%rbp), %rdx
movl $0x2, %esi
callq 0x2b540
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x85e1b
movq -0x38(%rbp), %rdi
callq 0x38620
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq 0xbd27f(%rip), %rdi     # 0x143077
callq 0x38510
movq -0x78(%rbp), %rdi
movq %rax, %rsi
callq 0x42e50
movl -0x2c(%rbp), %edi
callq 0x26180
movq $0x0, -0x8(%rbp)
jmp 0x85e77
movl $0x18, %edi
callq 0x3acd0
movq %rax, -0x40(%rbp)
movl -0x2c(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, (%rax)
movq -0x40(%rbp), %rax
movq $-0x1, 0x8(%rax)
leaq 0xf2393(%rip), %rax     # 0x1781d8
movq 0x978(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
leaq 0xf237d(%rip), %rax     # 0x1781d8
movq 0x308(%rax), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x2d8c0
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)