// File: /workspace/github_c_makefile_star2_O0/agl[P]obstcp/obstcp-redir.c
// Function: connection_out_cb
static void
connection_out_cb(int fd, short events, void *arg) {
  struct connection *conn = (struct connection *) arg;

  if (EV_READ & events) {
    int queued;
    if (ioctl(conn->outfd, SIOCINQ, &queued)) {
      perror("ioctl");
      connection_free(conn);
      return;
    }
    if (!queued) queued = 16;

    struct chunk *c = malloc(sizeof(struct chunk) + queued + CHUNK_OVERHEAD);
    if (!c) return;
    memset(c, 0, sizeof(struct chunk));
    c->done = CHUNK_PRE;

    ssize_t n;
    do {
      n = read(conn->outfd, c->data + CHUNK_PRE, queued);
    } while (n == -1 && errno == EINTR);

    if (n < 0) {
      if (errno == EAGAIN || errno == EWOULDBLOCK) return;
      perror("read");
      free(c);
      connection_free(conn);
      return;
    } else if (n == 0) {
      free(c);
      connection_free(conn);
      return;
    } else {
      c->length = n + c->done;
      const char was_empty_q = conn->obsqhead ? 0 : 1;

      connection_obs_prepare(conn, c);
      chunk_nq(c, &conn->obsqhead, &conn->obsqtail);
      conn->obsqlen += c->length;

      if (was_empty_q) connection_obs_write(conn);
    }
  }

  if (EV_WRITE & events) {
    if (!connection_out_write(conn)) return;
  }

  connection_setevents(conn);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movw %si, %ax
movl %edi, -0x4(%rbp)
movw %ax, -0x6(%rbp)
movq %rdx, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movswl -0x6(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x1e90
movq -0x18(%rbp), %rax
movl 0x1cc(%rax), %edi
movl $0x541b, %esi           # imm = 0x541B
leaq -0x1c(%rbp), %rdx
movb $0x0, %al
callq 0x10f0
cmpl $0x0, %eax
je 0x1d17
leaq 0xb461(%rip), %rdi      # 0xd165
callq 0x11f0
movq -0x18(%rbp), %rdi
callq 0x1bc0
jmp 0x1eb7
cmpl $0x0, -0x1c(%rbp)
jne 0x1d24
movl $0x10, -0x1c(%rbp)
movslq -0x1c(%rbp), %rdi
addq $0x18, %rdi
addq $0x40, %rdi
callq 0x1180
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x1d45
jmp 0x1eb7
movq -0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x10e0
movq -0x28(%rbp), %rax
movl $0x40, 0x14(%rax)
movq -0x18(%rbp), %rax
movl 0x1cc(%rax), %edi
movq -0x28(%rbp), %rsi
addq $0x18, %rsi
addq $0x40, %rsi
movslq -0x1c(%rbp), %rdx
callq 0x1110
movq %rax, -0x30(%rbp)
xorl %eax, %eax
cmpq $-0x1, -0x30(%rbp)
movb %al, -0x32(%rbp)
jne 0x1d9d
callq 0x1050
cmpl $0x4, (%rax)
sete %al
movb %al, -0x32(%rbp)
movb -0x32(%rbp), %al
testb $0x1, %al
jne 0x1d60
cmpq $0x0, -0x30(%rbp)
jge 0x1de7
callq 0x1050
cmpl $0xb, (%rax)
je 0x1dbf
callq 0x1050
cmpl $0xb, (%rax)
jne 0x1dc4
jmp 0x1eb7
leaq 0xb3a0(%rip), %rdi      # 0xd16b
callq 0x11f0
movq -0x28(%rbp), %rdi
callq 0x1030
movq -0x18(%rbp), %rdi
callq 0x1bc0
jmp 0x1eb7
cmpq $0x0, -0x30(%rbp)
jne 0x1e05
movq -0x28(%rbp), %rdi
callq 0x1030
movq -0x18(%rbp), %rdi
callq 0x1bc0
jmp 0x1eb7
movq -0x30(%rbp), %rax
movq -0x28(%rbp), %rcx
movl 0x14(%rcx), %ecx
addq %rcx, %rax
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x18(%rbp), %rax
movq 0x2e0(%rax), %rdx
movl $0x1, %eax
xorl %ecx, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movb %al, -0x31(%rbp)
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x20e0
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x2e0, %rsi            # imm = 0x2E0
movq -0x18(%rbp), %rdx
addq $0x2e8, %rdx            # imm = 0x2E8
callq 0x2190
movq -0x28(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x18(%rbp), %rax
addl 0x304(%rax), %ecx
movl %ecx, 0x304(%rax)
cmpb $0x0, -0x31(%rbp)
je 0x1e8a
movq -0x18(%rbp), %rdi
callq 0x21e0
jmp 0x1e8c
jmp 0x1e8e
jmp 0x1e90
movswl -0x6(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x1eae
movq -0x18(%rbp), %rdi
callq 0x22b0
cmpl $0x0, %eax
jne 0x1eac
jmp 0x1eb7
jmp 0x1eae
movq -0x18(%rbp), %rdi
callq 0x1a50
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)