// File: /workspace/github_c_makefile_star2_O0/andyfighting[P]hiredis_timer_cmpt/net.c
// Function: redisContextWaitReady
static int redisContextWaitReady(redisContext *c, const struct timeval *timeout) {
    struct pollfd   wfd[1];
    long msec;

    msec          = -1;
    wfd[0].fd     = c->fd;
    wfd[0].events = POLLOUT;

    /* 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;
        }
    }

    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;
    }

    __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, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl 0x84(%rax), %eax
movl %eax, -0x20(%rbp)
movw $0x4, -0x1c(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x448e
movq -0x18(%rbp), %rax
cmpq $0xf4240, 0x8(%rax)     # imm = 0xF4240
jg 0x4417
movq -0x18(%rbp), %rax
movabsq $0x20c49ba5e353f6, %rcx # imm = 0x20C49BA5E353F6
cmpq %rcx, (%rax)
jle 0x443e
movq -0x10(%rbp), %rdi
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x38c0
movq -0x10(%rbp), %rdi
callq 0x4570
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4558
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, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jl 0x4484
cmpq $0x7fffffff, -0x28(%rbp) # imm = 0x7FFFFFFF
jle 0x448c
movq $0x7fffffff, -0x28(%rbp) # imm = 0x7FFFFFFF
jmp 0x448e
callq 0x3070
cmpl $0x73, (%rax)
jne 0x4536
leaq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rax
movl %eax, %edx
movl $0x1, %esi
callq 0x33d0
movl %eax, -0x2c(%rbp)
cmpl $-0x1, %eax
jne 0x44df
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq 0x8bfc(%rip), %rdx      # 0xd0c4
callq 0x38c0
movq -0x10(%rbp), %rdi
callq 0x4570
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4558
cmpl $0x0, -0x2c(%rbp)
jne 0x4514
callq 0x3070
movl $0x6e, (%rax)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x38c0
movq -0x10(%rbp), %rdi
callq 0x4570
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4558
jmp 0x4516
movq -0x10(%rbp), %rdi
callq 0x3160
cmpl $0x0, %eax
je 0x452d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4558
movl $0x0, -0x4(%rbp)
jmp 0x4558
movq -0x10(%rbp), %rdi
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x38c0
movq -0x10(%rbp), %rdi
callq 0x4570
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)