// File: /workspace/github_c_makefile_star2_O0/Genymobile[P]hiredis/net.c
// Function: redisContextWaitReady
static int redisContextWaitReady(redisContext *c, const struct timeval *timeout) {
    long msec          = -1;
    /* Only use timeout when not NULL. */
    if (timeout != NULL) {
        if (timeout->tv_usec > 1000000 || timeout->tv_sec > __MAX_MSEC) {
            __redisSetErrorFromErrno(c, REDIS_ERR_IO, NULL);
            redisContextCloseFd(c);
            return REDIS_ERR;
        }

        msec = (timeout->tv_sec * 1000) + ((timeout->tv_usec + 999) / 1000);

        if (msec < 0 || msec > INT_MAX) {
            msec = INT_MAX;
        }
    }
#ifdef _WIN32
    fd_set wfd;
    struct timeval toptr = {5, 0};
    if (timeout != NULL) {
        toptr.tv_sec = timeout->tv_sec;
        toptr.tv_usec = timeout->tv_usec;
    }
    if (errno == EINPROGRESS || errno == WSAEWOULDBLOCK) {
        FD_ZERO(&wfd);
        FD_SET(c->fd, &wfd);
        if (select(FD_SETSIZE, NULL, &wfd, NULL, &toptr) == -1) {
            SETERRNO;
            __redisSetErrorFromErrno(c,REDIS_ERR_IO,"select(2)");
            redisContextCloseFd(c);
            return REDIS_ERR;
        }
        if (!FD_ISSET(c->fd, &wfd)) {
            errno = WSAETIMEDOUT;
            __redisSetErrorFromErrno(c,REDIS_ERR_IO,NULL);
            closesocket(c->fd);
            return REDIS_ERR;
        }
        if (redisCheckSocketError(c) != REDIS_OK)
            return REDIS_ERR;

        return REDIS_OK;
    }
#else
    struct pollfd   wfd[1];
    wfd[0].fd     = c->fd;
    wfd[0].events = POLLOUT;

    if (errno == EINPROGRESS) {
        int res;

        if ((res = poll(wfd, 1, msec)) == -1) {
            __redisSetErrorFromErrno(c, REDIS_ERR_IO, "poll(2)");
            redisContextCloseFd(c);
            return REDIS_ERR;
        } else if (res == 0) {
            errno = ETIMEDOUT;
            __redisSetErrorFromErrno(c,REDIS_ERR_IO,NULL);
            redisContextCloseFd(c);
            return REDIS_ERR;
        }

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

        return REDIS_OK;
    }
#endif
    __redisSetErrorFromErrno(c,REDIS_ERR_IO,NULL);
    redisContextCloseFd(c);
    return REDIS_ERR;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $-0x1, -0x20(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0xc4db
movq -0x18(%rbp), %rax
cmpq $0xf4240, 0x8(%rax)     # imm = 0xF4240
jg 0xc464
movq -0x18(%rbp), %rax
movabsq $0x20c49ba5e353f6, %rcx # imm = 0x20C49BA5E353F6
cmpq %rcx, (%rax)
jle 0xc48b
movq -0x10(%rbp), %rdi
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0xb900
movq -0x10(%rbp), %rdi
callq 0xc5d0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xc5b8
movq -0x18(%rbp), %rax
imulq $0x3e8, (%rax), %rax    # imm = 0x3E8
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x3e7, %rax            # imm = 0x3E7
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
movq %rax, %rcx
movq -0x38(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jl 0xc4d1
cmpq $0x7fffffff, -0x20(%rbp) # imm = 0x7FFFFFFF
jle 0xc4d9
movq $0x7fffffff, -0x20(%rbp) # imm = 0x7FFFFFFF
jmp 0xc4db
movq -0x10(%rbp), %rax
movl 0x84(%rax), %eax
movl %eax, -0x28(%rbp)
movw $0x4, -0x24(%rbp)
callq 0x2050
cmpl $0x73, (%rax)
jne 0xc596
leaq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %edx
movl $0x1, %esi
callq 0x2220
movl %eax, -0x2c(%rbp)
cmpl $-0x1, %eax
jne 0xc53f
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq 0x25f5(%rip), %rdx      # 0xeb1d
callq 0xb900
movq -0x10(%rbp), %rdi
callq 0xc5d0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xc5b8
cmpl $0x0, -0x2c(%rbp)
jne 0xc574
callq 0x2050
movl $0x6e, (%rax)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0xb900
movq -0x10(%rbp), %rdi
callq 0xc5d0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xc5b8
jmp 0xc576
movq -0x10(%rbp), %rdi
callq 0xb860
cmpl $0x0, %eax
je 0xc58d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xc5b8
movl $0x0, -0x4(%rbp)
jmp 0xc5b8
movq -0x10(%rbp), %rdi
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0xb900
movq -0x10(%rbp), %rdi
callq 0xc5d0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)