// File: /workspace/github_c_makefile_star2_O2/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: on_recv_data
static void on_recv_data(struct connection *conn) {
  struct iobuf *io = &conn->ns_conn->recv_iobuf;
  int n;

  if (conn->endpoint_type == EP_PROXY) {
    if (conn->endpoint.nc != NULL) do_proxy(conn);
    return;
  }

  try_parse(conn);
  DBG(("%p %d %lu %d", conn, conn->request_len, (unsigned long)io->len,
       conn->ns_conn->flags));
  if (conn->request_len < 0 ||
      (conn->request_len > 0 && !is_valid_uri(conn->mg_conn.uri))) {
    send_http_error(conn, 400, NULL);
  } else if (conn->request_len == 0 && io->len > MAX_REQUEST_SIZE) {
    send_http_error(conn, 413, NULL);
  } else if (conn->request_len > 0 &&
             strcmp(conn->mg_conn.http_version, "1.0") != 0 &&
             strcmp(conn->mg_conn.http_version, "1.1") != 0) {
    send_http_error(conn, 505, NULL);
  } else if (conn->request_len > 0 && conn->endpoint_type == EP_NONE) {
#ifndef MONGOOSE_NO_WEBSOCKET
    send_websocket_handshake_if_requested(&conn->mg_conn);
#endif
    send_continue_if_expected(conn);
    open_local_endpoint(conn, 0);
  }

#ifndef MONGOOSE_NO_CGI
  if (conn->endpoint_type == EP_CGI && conn->endpoint.nc != NULL) {
    ns_forward(conn->ns_conn, conn->endpoint.nc);
  }
#endif
  if (conn->endpoint_type == EP_USER) {
    conn->mg_conn.content = io->buf;
    conn->mg_conn.content_len = io->len;
    n = call_user(conn, MG_RECV);
    if (n < 0) {
      conn->ns_conn->flags |= NSF_FINISHED_SENDING_DATA;
    } else if ((size_t) n <= io->len) {
      iobuf_remove(io, n);
    }
    call_request_handler_if_data_is_buffered(conn);
  }
#ifndef MONGOOSE_NO_DAV
  if (conn->endpoint_type == EP_PUT && io->len > 0) {
    forward_put_data(conn);
  }
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2b8, %rsp            # imm = 0x2B8
movq %rdi, %rbx
movq (%rdi), %r13
cmpl $0x6, 0x2b8(%rdi)
jne 0x5de06
movq 0x2b0(%rbx), %rsi
testq %rsi, %rsi
je 0x5e25f
movq %r13, %rdi
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5f220
movq %rbx, %rdi
callq 0x5e4c0
cmpq $0x0, 0x2e0(%rbx)
js 0x5deb5
je 0x5debf
movq 0x10(%rbx), %r15
movzbl (%r15), %eax
cmpl $0x2f, %eax
je 0x5de79
cmpl $0x2a, %eax
jne 0x5de3b
cmpb $0x0, 0x1(%r15)
je 0x5de79
leaq 0xb64b(%rip), %rsi      # 0x6948d
pushq $0x4
popq %rdx
movq %r15, %rdi
callq 0x5a293
testl %eax, %eax
je 0x5de79
leaq 0xb63a(%rip), %rsi      # 0x69492
leaq -0x2e0(%rbp), %rdx
movq %r15, %rdi
xorl %eax, %eax
callq 0xc110
testl %eax, %eax
jle 0x5deb5
cmpq $0x0, 0x2e0(%rbx)
je 0x5debf
jle 0x5deda
movq 0x18(%rbx), %r15
leaq 0x694b(%rip), %rsi      # 0x647cf
movq %r15, %rdi
callq 0xc970
testl %eax, %eax
je 0x5df4f
leaq 0xb02f(%rip), %rsi      # 0x68eca
movq %r15, %rdi
callq 0xc970
testl %eax, %eax
je 0x5df4f
movq %rbx, %rdi
movl $0x1f9, %esi            # imm = 0x1F9
jmp 0x5ded1
movq %rbx, %rdi
movl $0x190, %esi            # imm = 0x190
jmp 0x5ded1
cmpq $0x4001, 0x48(%r13)     # imm = 0x4001
jb 0x5deda
movq %rbx, %rdi
movl $0x19d, %esi            # imm = 0x19D
xorl %edx, %edx
xorl %eax, %eax
callq 0x5bd71
movl 0x2b8(%rbx), %eax
cmpl $0x2, %eax
jne 0x5df03
movq 0x2b0(%rbx), %rsi
testq %rsi, %rsi
je 0x5e25f
movq (%rbx), %rdi
callq 0x5f220
movl 0x2b8(%rbx), %eax
cmpl $0x3, %eax
jne 0x5e1f1
movq 0x40(%r13), %rax
movq %rax, 0x270(%rbx)
movq 0x48(%r13), %rax
movq %rax, 0x278(%rbx)
pushq $0x69
popq %rsi
movq %rbx, %rdi
callq 0x5d354
testl %eax, %eax
js 0x5e04f
movl %eax, %esi
cmpq %rsi, 0x48(%r13)
jb 0x5e059
leaq 0x40(%r13), %rdi
callq 0x5777d
jmp 0x5e059
movl 0x2b8(%rbx), %eax
testl %eax, %eax
jne 0x5dee0
leaq 0x8(%rbx), %r14
leaq 0xb53a(%rip), %rsi      # 0x6949e
movq %r14, %rdi
callq 0x58dc0
movq %rax, %r15
leaq 0xb53e(%rip), %rsi      # 0x694b4
movq %r14, %rdi
callq 0x58dc0
movq %rax, %r12
testq %r15, %r15
setne %al
testq %r12, %r12
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x5e436
movl $0x1, 0x280(%rbx)
pushq $0x6b
popq %rsi
movq %rbx, %rdi
callq 0x5d354
testl %eax, %eax
jne 0x5e42b
movq %r14, -0x40(%rbp)
leaq 0xaf79(%rip), %rdx      # 0x68f39
leaq 0xb4ff(%rip), %r8       # 0x694c6
xorl %r14d, %r14d
leaq -0x2e0(%rbp), %r15
movl $0x1f4, %esi            # imm = 0x1F4
movq %r15, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x5bc9e
movaps 0xa226(%rip), %xmm0     # 0x68210
leaq -0xec(%rbp), %r12
movups %xmm0, (%r12)
movl $0xc3d2e1f0, %eax       # imm = 0xC3D2E1F0
movq %rax, 0x10(%r12)
andl $0x0, 0x18(%r12)
movq %r15, %rdi
callq 0xc470
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x5f5d2
xorl %eax, %eax
cmpq $0x8, %rax
je 0x5e271
xorl %ecx, %ecx
cmpq $0x4, %rax
setb %cl
movl -0xd8(%rbp,%rcx,4), %edx
movl %r14d, %ecx
notb %cl
andb $0x18, %cl
shrl %cl, %edx
movb %dl, -0x70(%rbp,%rax)
incq %rax
addl $0x8, %r14d
jmp 0x5e01e
movq (%rbx), %rax
orl $0x1, 0xa0(%rax)
cmpl $0x0, 0x280(%rbx)
movq %r13, -0x38(%rbp)
je 0x5e17c
pushq $0x67
popq %r15
movq (%rbx), %rax
movq 0x40(%rax), %r13
movq 0x48(%rax), %rcx
cmpq $0x2, %rcx
jb 0x5e0cc
movzbl 0x1(%r13), %eax
movl %eax, %r12d
andl $0x7f, %r12d
shrl $0x5, %eax
andl $0x4, %eax
cmpb $0x7e, %r12b
setae %dl
cmpq %rax, %rcx
setb %sil
orb %dl, %sil
je 0x5e0d6
cmpb $0x7e, %r12b
jne 0x5e0b7
leaq 0x4(%rax), %r14
cmpq %r14, %rcx
jae 0x5e16a
movq %rax, %r14
orq $0xa, %r14
cmpq %r14, %rcx
jb 0x5e0ce
movq 0x2(%r13), %r12
bswapq %r12
jmp 0x5e0dd
xorl %eax, %eax
xorl %r14d, %r14d
xorl %r12d, %r12d
jmp 0x5e0dd
movq %rax, %r14
orq $0x2, %r14
leaq (%r12,%r14), %rdx
decq %rdx
cmpq %rcx, %rdx
jae 0x5e1e7
movq %r12, 0x278(%rbx)
leaq (%r14,%r13), %rcx
movq %rcx, 0x270(%rbx)
movzbl (%r13), %edx
movl %edx, 0x288(%rbx)
testq %rax, %rax
je 0x5e12e
movq %rcx, %rdx
subq %rax, %rdx
xorl %eax, %eax
cmpq %rax, %r12
je 0x5e12e
movl %eax, %esi
andl $0x3, %esi
movb (%rdx,%rsi), %sil
xorb %sil, (%rcx,%rax)
incq %rax
jmp 0x5e117
movq %rbx, %rdi
movl %r15d, %esi
callq 0x5d354
testl %eax, %eax
je 0x5e147
movb (%r13), %al
andb $0xf, %al
cmpb $0x8, %al
jne 0x5e153
movq (%rbx), %rdi
orl $0x1, 0xa0(%rdi)
jmp 0x5e156
movq (%rbx), %rdi
addq %r14, %r12
addq $0x40, %rdi
movq %r12, %rsi
callq 0x5777d
jmp 0x5e06e
movzwl 0x2(%r13), %edx
rolw $0x8, %dx
movzwl %dx, %r12d
jmp 0x5e0dd
movq 0x2e0(%rbx), %rax
addq 0x2d8(%rbx), %rax
cmpq %rax, 0x2d0(%rbx)
jl 0x5e1e7
movq (%rbx), %rax
movq 0x40(%rax), %rax
movq %rax, 0x270(%rbx)
pushq $0x67
popq %rsi
movq %rbx, %rdi
callq 0x5d354
testl %eax, %eax
je 0x5e1dc
cmpl $0x1, %eax
jne 0x5e1e7
movq (%rbx), %rax
testb $0x20, 0xa2(%rax)
je 0x5e1d2
leaq 0x8(%rbx), %rdi
callq 0x5958b
movq %rbx, %rdi
callq 0x5d5a0
movq %rbx, %rdi
callq 0x59b05
jmp 0x5e1e7
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x5e59c
movl 0x2b8(%rbx), %eax
movq -0x38(%rbp), %r13
cmpl $0x4, %eax
jne 0x5e25f
cmpq $0x0, 0x48(%r13)
je 0x5e25f
movq (%rbx), %r14
movq 0x2d8(%rbx), %rax
movq 0x40(%r14), %rsi
movq 0x48(%r14), %rdx
cmpq %rdx, %rax
cmovlq %rax, %rdx
movl 0x2b0(%rbx), %edi
callq 0xcb80
testq %rax, %rax
je 0x5e24b
movq %rax, %r15
addq $0x40, %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x5777d
movq 0x2d8(%rbx), %rax
subq %r15, %rax
movq %rax, 0x2d8(%rbx)
jmp 0x5e252
movq 0x2d8(%rbx), %rax
testq %rax, %rax
jg 0x5e25f
movq %rbx, %rdi
callq 0x59b05
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, -0x38(%rbp)
movb $-0x80, %r14b
leaq -0x29(%rbp), %r13
pushq $0x1
popq %r15
movl $0x1f8, %r12d           # imm = 0x1F8
movb %r14b, -0x29(%rbp)
leaq -0xec(%rbp), %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x5f5d2
movl -0xd8(%rbp), %eax
andl %r12d, %eax
xorl %r14d, %r14d
cmpl $0x1c0, %eax            # imm = 0x1C0
jne 0x5e286
leaq -0xec(%rbp), %rdi
leaq -0x70(%rbp), %rsi
pushq $0x8
popq %rdx
callq 0x5f5d2
xorl %eax, %eax
movq -0x38(%rbp), %r13
cmpq $0x14, %rax
je 0x5e2f4
movl %eax, %ecx
andl $-0x4, %ecx
movl -0xec(%rbp,%rcx), %edx
movl %r14d, %ecx
notb %cl
andb $0x18, %cl
shrl %cl, %edx
movb %dl, -0x90(%rbp,%rax)
incq %rax
addl $0x8, %r14d
jmp 0x5e2c8
xorl %eax, %eax
leaq 0xb250(%rip), %rcx      # 0x6954d
xorl %edx, %edx
movq -0x40(%rbp), %r14
cmpq $0x14, %rax
jae 0x5e3b7
xorl %esi, %esi
cmpq $0x13, %rax
jne 0x5e319
xorl %edi, %edi
jmp 0x5e32f
movb -0x8f(%rbp,%rax), %dil
cmpq $0x11, %rax
ja 0x5e32f
movzbl -0x8e(%rbp,%rax), %esi
movzbl -0x90(%rbp,%rax), %r8d
movzbl %dil, %r9d
movl %r8d, %r10d
shrl $0x2, %r10d
movslq %edx, %rdi
shll $0x4, %r8d
andl $0x30, %r8d
movl %r9d, %r11d
shrl $0x4, %r11d
orl %r8d, %r11d
leaq 0x2(%rdi), %r8
movb (%r10,%rcx), %r10b
movb %r10b, -0x70(%rbp,%rdi)
movb (%r11,%rcx), %r10b
movb %r10b, -0x6f(%rbp,%rdi)
cmpq $0x13, %rax
je 0x5e3ab
andl $0xf, %r9d
movl %esi, %r10d
shrl $0x6, %r10d
leal (%r10,%r9,4), %r9d
movb (%r9,%rcx), %r9b
addq $0x3, %rdi
movb %r9b, -0x70(%rbp,%r8)
movl %edi, %r8d
cmpq $0x11, %rax
ja 0x5e3ab
andl $0x3f, %esi
movb (%rsi,%rcx), %sil
addl $0x4, %edx
movb %sil, -0x70(%rbp,%rdi)
movl %edx, %r8d
addq $0x3, %rax
movl %r8d, %edx
jmp 0x5e303
movslq %edx, %rcx
movq %rcx, %rax
shlq $0x20, %rax
movabsq $0x100000000, %rdx      # imm = 0x100000000
testb $0x3, %cl
je 0x5e3dd
movb $0x3d, -0x70(%rbp,%rcx)
incq %rcx
addq %rdx, %rax
jmp 0x5e3cb
sarq $0x20, %rax
movb $0x0, -0x70(%rbp,%rax)
leaq 0xab4a(%rip), %rdx      # 0x68f37
leaq 0xb0f7(%rip), %rcx      # 0x694eb
leaq 0x9f6d(%rip), %r9       # 0x68368
leaq -0x2e0(%rbp), %r15
leaq -0x70(%rbp), %r8
movl $0x1f4, %esi            # imm = 0x1F4
movq %r15, %rdi
xorl %eax, %eax
callq 0x5bc9e
movq %r15, %rdi
callq 0xc470
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x59168
pushq $0x6c
popq %rsi
movq %rbx, %rdi
callq 0x5d354
leaq 0xb151(%rip), %rsi      # 0x6958e
movq %r14, %rdi
callq 0x58dc0
testq %rax, %rax
je 0x5e46f
leaq 0xb144(%rip), %rsi      # 0x69595
movq %rax, %rdi
callq 0x58e28
testl %eax, %eax
jne 0x5e46f
movq (%rbx), %rdi
leaq 0x9cc9(%rip), %rsi      # 0x68130
pushq $0x19
popq %rdx
callq 0x57905
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5e59c
jmp 0x5deda