// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl 0x88(%rax), %eax
andl $0x1, %eax
movl %eax, -0x7c(%rbp)
leaq -0x36(%rbp), %rdi
movl -0x1c(%rbp), %ecx
movl $0x6, %esi
leaq 0x7868(%rip), %rdx      # 0xa045
movb $0x0, %al
callq 0x2180
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x21d0
movl $0x2, -0x64(%rbp)
movl $0x1, -0x60(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x36(%rbp), %rsi
leaq -0x68(%rbp), %rdx
leaq -0x70(%rbp), %rcx
callq 0x2400
movl %eax, -0x30(%rbp)
cmpl $0x0, %eax
je 0x2852
movq -0x10(%rbp), %rax
movq %rax, -0x108(%rbp)
movl -0x30(%rbp), %edi
callq 0x2190
movq -0x108(%rbp), %rdi
movq %rax, %rdx
movl $0x2, %esi
callq 0x2270
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x29e7
movq -0x70(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0x297a
movq -0x78(%rbp), %rax
movl 0x4(%rax), %edi
movq -0x78(%rbp), %rax
movl 0x8(%rax), %esi
movq -0x78(%rbp), %rax
movl 0xc(%rax), %edx
callq 0x2470
movl %eax, -0x2c(%rbp)
cmpl $-0x1, %eax
jne 0x288c
jmp 0x2969
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %esi
xorl %edx, %edx
callq 0x2a00
cmpl $0x0, %eax
je 0x28a4
jmp 0x29d1
movl -0x2c(%rbp), %edi
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x78(%rbp), %rax
movl 0x10(%rax), %edx
callq 0x23e0
cmpl $-0x1, %eax
jne 0x2909
callq 0x2070
cmpl $0x71, (%rax)
jne 0x28d7
movl -0x2c(%rbp), %edi
callq 0x21e0
jmp 0x2969
callq 0x2070
cmpl $0x73, (%rax)
jne 0x28e9
cmpl $0x0, -0x7c(%rbp)
jne 0x28e9
jmp 0x2905
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %esi
movq -0x28(%rbp), %rdx
callq 0x2ac0
cmpl $0x0, %eax
je 0x2903
jmp 0x29d1
jmp 0x2905
jmp 0x2907
jmp 0x2909
cmpl $0x0, -0x7c(%rbp)
je 0x292a
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl $0x1, %edx
callq 0x2a00
cmpl $0x0, %eax
je 0x292a
jmp 0x29d1
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x2ca0
cmpl $0x0, %eax
je 0x2940
jmp 0x29d1
movl -0x2c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x84(%rax)
movq -0x10(%rbp), %rax
movl 0x88(%rax), %ecx
orl $0x2, %ecx
movl %ecx, 0x88(%rax)
movl $0x0, -0x30(%rbp)
jmp 0x29d8
movq -0x78(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x78(%rbp)
jmp 0x285a
cmpq $0x0, -0x78(%rbp)
jne 0x29cf
leaq -0x100(%rbp), %rax
movq %rax, -0x110(%rbp)
callq 0x2070
movl (%rax), %edi
callq 0x2420
movq -0x110(%rbp), %rdi
movq %rax, %rcx
movl $0x80, %esi
leaq 0x7697(%rip), %rdx      # 0xa048
movb $0x0, %al
callq 0x2180
movq -0x10(%rbp), %rdi
leaq -0x100(%rbp), %rdx
movl $0x2, %esi
callq 0x2270
jmp 0x29d1
jmp 0x29d1
movl $0xffffffff, -0x30(%rbp) # imm = 0xFFFFFFFF
movq -0x70(%rbp), %rdi
callq 0x2460
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nopw %cs:(%rax,%rax)