// File: /workspace/github_c_makefile_star2_O1/redis-force[P]rpm/module/rpm.c
// Function: rpm_worker_upstream_read
static void rpm_worker_upstream_read(RedisModuleCtx *ctx, int fd, void *client_data, int mask) {
  int rd;
  rpm_context *rpm;
  redis_response_status st = REDIS_RESPONSE_OK;
  worker_pipe *pipe = client_data;
  worker_process *worker = pipe->worker;
  redis_response_reader *reader = pipe->user_data;
  char *buf = worker->buf;
  redis_response *reply = NULL;
  REDISMODULE_NOT_USED(mask);
  while ((rd = read(fd, buf, sizeof(worker->buf))) > 0) {
    redis_response_reader_feed(reader, buf, rd);
    while (st == REDIS_RESPONSE_OK && (st = redis_response_reader_next(reader, &reply)) == REDIS_RESPONSE_OK && reply != NULL) {
      st = rpm_worker_upstream_on_reply(ctx, reply);
    }
    if (st != REDIS_RESPONSE_OK) {
      /* protocol error, kill worker and restart to fix the channel */
      RedisModule_Log(ctx, "warning", "worker process respond invalid response and will be restarted to fix the state. %s",
          redis_response_reader_strerr(reader));
      rpm_worker_suicide(ctx, worker);
    }
  }
  if (rd == 0) {
    /* upstream eof, worker process must be died, restart it automatically */
    RedisModule_DeleteFileEvent(ctx, fd, REDISMODULE_READ);
    RedisModule_Log(ctx, "warning", "Upstream connection with fd %d was closed", fd);
    rpm = rpm_context_get(ctx);
    if (--worker->active_upstreams <= 0) {
      RedisModule_Log(ctx, "warning", "All upstream connections were closed, restart worker process now");
      rpm_worker_destroy(ctx, rpm, worker);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %r14
movq (%rdx), %rax
movq 0x30(%rdx), %r15
movq %rax, 0x8(%rsp)
leaq 0xa8(%rax), %r12
movq $0x0, 0x10(%rsp)
movl $0x100000, %edx         # imm = 0x100000
movl %esi, 0x4(%rsp)
movl %esi, %edi
movq %r12, %rsi
callq 0x5170
testl %eax, %eax
jle 0x6f1c
leaq 0x10(%rsp), %r13
xorl %ebx, %ebx
movq %r12, 0x28(%rsp)
movq %r15, %rdi
movq %r12, %rsi
movl %eax, %edx
callq 0x5400
testl %ebx, %ebx
jne 0x6ec2
movq %r15, %rdi
movq %r13, %rsi
callq 0x5120
movl %eax, %ebx
testl %eax, %eax
jne 0x6ec2
movq 0x10(%rsp), %rbp
testq %rbp, %rbp
je 0x6ec2
xorl %r12d, %r12d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
movq 0x6e1b(%rip), %rax      # 0xdc08
callq *(%rax)
movl $0x2, %ebx
cmpl $0x2, (%rbp)
jne 0x6eb9
cmpq $0x3, 0x18(%rbp)
jne 0x6eb6
movq 0x10(%rbp), %rdx
movq (%rdx), %rcx
cmpl $0x3, (%rcx)
jne 0x6eb6
movq 0x8(%rdx), %rdx
cmpl $0x3, (%rdx)
jne 0x6eb6
movq 0x10(%rcx), %rcx
movq %rcx, 0x20(%rsp)
movq 0x10(%rdx), %rbx
movq $0x0, 0x18(%rsp)
movq 0x10(%rax), %r12
movq 0x98(%r12), %rdi
movl $0x8, %edx
movq %rbx, %rsi
leaq 0x18(%rsp), %rcx
leaq 0x30(%rsp), %r8
callq 0x51c0
testl %eax, %eax
jne 0x6ea2
movq 0xa0(%r12), %rdi
movl $0x8, %edx
movq 0x20(%rsp), %rsi
callq 0x53f0
movq 0x98(%r12), %rdi
movl $0x8, %edx
movq %rbx, %rsi
callq 0x53f0
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
movq 0x6fd2(%rip), %rax      # 0xde70
callq *(%rax)
xorl %ebp, %ebp
xorl %ebx, %ebx
movb $0x1, %r12b
testq %rbp, %rbp
je 0x6eb9
movq %rbp, %rdi
callq 0x5250
jmp 0x6eb9
xorl %r12d, %r12d
testb %r12b, %r12b
jne 0x6db9
testl %ebx, %ebx
je 0x6efe
movq 0x6f9b(%rip), %rax      # 0xde68
movq (%rax), %r12
movq %r15, %rdi
callq 0x5300
movq %r14, %rdi
leaq 0x3ef2(%rip), %rsi      # 0xadd4
leaq 0x41b1(%rip), %rdx      # 0xb09a
movq %rax, %rcx
xorl %eax, %eax
callq *%r12
movq %r14, %rdi
movq 0x8(%rsp), %rsi
callq 0x7505
movl $0x100000, %edx         # imm = 0x100000
movl 0x4(%rsp), %edi
movq 0x28(%rsp), %r12
movq %r12, %rsi
callq 0x5170
testl %eax, %eax
jg 0x6da4
testl %eax, %eax
jne 0x6fac
movq 0x6ce5(%rip), %rax      # 0xdc10
movq %r14, %rdi
movl 0x4(%rsp), %ebx
movl %ebx, %esi
movl $0x1, %edx
callq *(%rax)
movq 0x6f26(%rip), %r15      # 0xde68
leaq 0x3e8b(%rip), %rsi      # 0xadd4
leaq 0x419d(%rip), %rdx      # 0xb0ed
movq %r14, %rdi
movl %ebx, %ecx
xorl %eax, %eax
callq *(%r15)
movq 0x6ca7(%rip), %rax      # 0xdc08
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq *(%rax)
movq %rax, %rbx
movq 0x8(%rsp), %rdx
movl 0x8c(%rdx), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x8c(%rdx)
cmpl $0x1, %eax
jg 0x6fac
leaq 0x3e47(%rip), %rsi      # 0xadd4
leaq 0x4183(%rip), %rdx      # 0xb117
movq %r14, %rdi
xorl %eax, %eax
callq *(%r15)
movq %r14, %rdi
movq %rbx, %rsi
movq 0x8(%rsp), %rdx
callq 0x7295
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq