// File: /workspace/github_c_makefile_star2_O0/winton[P]redis_parse/hiredis/net.c
// Function: redisContextWaitReady
static int redisContextWaitReady(redisContext *c, int fd, const struct timeval *timeout) {
    struct timeval to;
    struct timeval *toptr = NULL;
    fd_set wfd;

    /* Only use timeout when not NULL. */
    if (timeout != NULL) {
        to = *timeout;
        toptr = &to;
    }

    if (errno == EINPROGRESS) {
        FD_ZERO(&wfd);
        FD_SET(fd, &wfd);

        if (select(FD_SETSIZE, NULL, &wfd, NULL, toptr) == -1) {
            __redisSetErrorFromErrno(c,REDIS_ERR_IO,"select(2)");
            close(fd);
            return REDIS_ERR;
        }

        if (!FD_ISSET(fd, &wfd)) {
            errno = ETIMEDOUT;
            __redisSetErrorFromErrno(c,REDIS_ERR_IO,NULL);
            close(fd);
            return REDIS_ERR;
        }

        if (redisCheckSocketError(c, fd) != REDIS_OK)
            return REDIS_ERR;

        return REDIS_OK;
    }

    __redisSetErrorFromErrno(c,REDIS_ERR_IO,NULL);
    close(fd);
    return REDIS_ERR;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x38(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x2b00
movq -0x20(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x30(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
leaq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
callq 0x2070
cmpl $0x73, (%rax)
jne 0x2c72
jmp 0x2b10
leaq -0xb8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movl $0x0, -0xbc(%rbp)
movl -0xbc(%rbp), %eax
cmpq $0x10, %rax
jae 0x2b5a
movq -0xc8(%rbp), %rax
movl -0xbc(%rbp), %ecx
movq $0x0, (%rax,%rcx,8)
movl -0xbc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xbc(%rbp)
jmp 0x2b28
jmp 0x2b5c
movl -0x14(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
movl -0x14(%rbp), %eax
movl $0x40, %esi
cltd
idivl %esi
cltq
orq -0xb8(%rbp,%rax,8), %rcx
movq %rcx, -0xb8(%rbp,%rax,8)
movq -0x38(%rbp), %r8
movl $0x400, %edi            # imm = 0x400
xorl %eax, %eax
movl %eax, %ecx
leaq -0xb8(%rbp), %rdx
movq %rcx, %rsi
callq 0x22c0
cmpl $-0x1, %eax
jne 0x2bdd
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq 0x74bf(%rip), %rdx      # 0xa083
callq 0x2650
movl -0x14(%rbp), %edi
callq 0x21e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2c93
movl -0x14(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
cltq
movq -0xb8(%rbp,%rax,8), %rax
movq %rax, -0xd0(%rbp)
movl -0x14(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0xd0(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
jne 0x2c4f
callq 0x2070
movl $0x6e, (%rax)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x2650
movl -0x14(%rbp), %edi
callq 0x21e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2c93
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x2150
cmpl $0x0, %eax
je 0x2c69
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2c93
movl $0x0, -0x4(%rbp)
jmp 0x2c93
movq -0x10(%rbp), %rdi
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x2650
movl -0x14(%rbp), %edi
callq 0x21e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nop