// File: /workspace/github_c_makefile_star2_O1/winton[P]redis_parse/hiredis/net.c
// Function: redisContextConnectTcp
int redisContextConnectTcp(redisContext *c, const char *addr, int port, struct timeval *timeout) {
    int s, rv;
    char _port[6];  /* strlen("65535"); */
    struct addrinfo hints, *servinfo, *p;
    int blocking = (c->flags & REDIS_BLOCK);

    snprintf(_port, 6, "%d", port);
    memset(&hints,0,sizeof(hints));
    hints.ai_family = AF_INET;
    hints.ai_socktype = SOCK_STREAM;

    if ((rv = getaddrinfo(addr,_port,&hints,&servinfo)) != 0) {
        __redisSetError(c,REDIS_ERR_OTHER,gai_strerror(rv));
        return REDIS_ERR;
    }
    for (p = servinfo; p != NULL; p = p->ai_next) {
        if ((s = socket(p->ai_family,p->ai_socktype,p->ai_protocol)) == -1)
            continue;

        if (redisSetBlocking(c,s,0) != REDIS_OK)
            goto error;
        if (connect(s,p->ai_addr,p->ai_addrlen) == -1) {
            if (errno == EHOSTUNREACH) {
                close(s);
                continue;
            } else if (errno == EINPROGRESS && !blocking) {
                /* This is ok. */
            } else {
                if (redisContextWaitReady(c,s,timeout) != REDIS_OK)
                    goto error;
            }
        }
        if (blocking && redisSetBlocking(c,s,1) != REDIS_OK)
            goto error;
        if (redisSetTcpNoDelay(c,s) != REDIS_OK)
            goto error;

        c->fd = s;
        c->flags |= REDIS_CONNECTED;
        rv = REDIS_OK;
        goto end;
    }
    if (p == NULL) {
        char buf[128];
        snprintf(buf,sizeof(buf),"Can't create socket: %s",strerror(errno));
        __redisSetError(c,REDIS_ERR_OTHER,buf);
        goto error;
    }

error:
    rv = REDIS_ERR;
end:
    freeaddrinfo(servinfo);
    return rv;  // Need to return REDIS_OK if alright
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rcx, %r14
movl %edx, %ecx
movq %rsi, %r15
movq %rdi, %rbx
movl 0x88(%rdi), %r13d
leaq 0x4945(%rip), %rdx      # 0x7045
leaq 0xa(%rsp), %r12
movl $0x6, %esi
movq %r12, %rdi
xorl %eax, %eax
callq 0x2180
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x10(%rdx)
movaps %xmm0, 0x20(%rdx)
movabsq $0x100000002, %rax      # imm = 0x100000002
movq %rax, 0x4(%rdx)
movq %rsp, %rcx
movq %r15, %rdi
movq %r12, %rsi
callq 0x2410
testl %eax, %eax
je 0x2768
movl %eax, %edi
callq 0x2190
movq %rbx, %rdi
movl $0x2, %esi
movq %rax, %rdx
callq 0x2280
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x2823
movq (%rsp), %r12
testq %r12, %r12
je 0x27db
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl 0x4(%r12), %edi
movl 0x8(%r12), %esi
movl 0xc(%r12), %edx
callq 0x2490
cmpl $-0x1, %eax
je 0x27d1
movl %eax, %r15d
movq %rbx, %rdi
movl %eax, %esi
xorl %edx, %edx
callq 0x28c9
testl %eax, %eax
jne 0x281a
movq 0x18(%r12), %rsi
movl 0x10(%r12), %edx
movl %r15d, %edi
callq 0x23f0
cmpl $-0x1, %eax
jne 0x2856
callq 0x2080
movl (%rax), %eax
cmpl $0x71, %eax
jne 0x2837
movl %r15d, %edi
callq 0x21e0
movq 0x28(%r12), %r12
testq %r12, %r12
jne 0x2776
callq 0x2080
movl (%rax), %edi
callq 0x2430
leaq 0x485a(%rip), %rdx      # 0x7048
leaq 0x40(%rsp), %r14
movl $0x80, %esi
movq %r14, %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0x2180
movq %rbx, %rdi
movl $0x2, %esi
movq %r14, %rdx
callq 0x2280
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq (%rsp), %rdi
callq 0x2480
movl %ebp, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl $0x73, %eax
movl %r13d, %ecx
andl $0x1, %ecx
orl %eax, %ecx
je 0x2856
movq %rbx, %rdi
movl %r15d, %esi
movq %r14, %rdx
callq 0x2943
testl %eax, %eax
jne 0x281a
testb $0x1, %r13b
je 0x2870
movq %rbx, %rdi
movl %r15d, %esi
movl $0x1, %edx
callq 0x28c9
testl %eax, %eax
jne 0x281a
leaq 0x40(%rsp), %rcx
movl $0x1, (%rcx)
movl %r15d, %edi
movl $0x6, %esi
movl $0x1, %edx
movl $0x4, %r8d
callq 0x20d0
cmpl $-0x1, %eax
je 0x28ad
movl %r15d, 0x84(%rbx)
orb $0x2, 0x88(%rbx)
xorl %ebp, %ebp
jmp 0x281a
leaq 0x47d9(%rip), %rsi      # 0x708d
movq %rbx, %rdi
callq 0x25f4
movl %r15d, %edi
callq 0x21e0
jmp 0x281a