// File: /workspace/github_cpp_makefile_star2_O3/nilnilnil[P]autocomplete/deps/mongoose/mongoose.c
// Function: forward_body_data
static int forward_body_data(struct mg_connection *conn, FILE *fp,
                             SOCKET sock, SSL *ssl) {
  const char *expect, *buffered;
  char buf[BUFSIZ];
  int to_read, nread, buffered_len, success = 0;

  expect = mg_get_header(conn, "Expect");
  assert(fp != NULL);

  if (conn->content_len == -1) {
    send_http_error(conn, 411, "Length Required", "");
  } else if (expect != NULL && mg_strcasecmp(expect, "100-continue")) {
    send_http_error(conn, 417, "Expectation Failed", "");
  } else {
    if (expect != NULL) {
      (void) mg_printf(conn, "%s", "HTTP/1.1 100 Continue\r\n\r\n");
    }

    buffered = conn->buf + conn->request_len;
    buffered_len = conn->data_len - conn->request_len;
    assert(buffered_len >= 0);
    assert(conn->consumed_content == 0);

    if (buffered_len > 0) {
      if ((int64_t) buffered_len > conn->content_len) {
        buffered_len = (int) conn->content_len;
      }
      push(fp, sock, ssl, buffered, (int64_t) buffered_len);
      conn->consumed_content += buffered_len;
    }

    while (conn->consumed_content < conn->content_len) {
      to_read = sizeof(buf);
      if ((int64_t) to_read > conn->content_len - conn->consumed_content) {
        to_read = (int) (conn->content_len - conn->consumed_content);
      }
      nread = pull(NULL, conn->client.sock, conn->ssl, buf, to_read);
      if (nread <= 0 || push(fp, sock, ssl, buf, nread) != nread) {
        break;
      }
      conn->consumed_content += nread;
    }

    if (conn->consumed_content == conn->content_len) {
      success = 1;
    }

    // Each error code path in this function must send an error
    if (!success) {
      send_http_error(conn, 577, http_500_error, "");
    }
  }

  return success;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2018, %rsp           # imm = 0x2018
movq %rcx, 0x8(%rsp)
movl %edx, 0x4(%rsp)
movq %rsi, %r15
movq %rdi, %rbx
addq $0x8, %rdi
leaq 0x387c(%rip), %rsi      # 0x1603e
callq 0xe5cf
cmpq $-0x1, 0x4b8(%rbx)
je 0x12878
movq %rax, %r12
testq %rax, %rax
je 0x1282a
callq 0x50e0
movq (%rax), %rax
xorl %ecx, %ecx
leaq 0x3867(%rip), %rdx      # 0x16055
movzbl (%r12,%rcx), %r8d
movl (%rax,%r8,4), %esi
movzbl (%rcx,%rdx), %edi
movl (%rax,%rdi,4), %edi
testl %r8d, %r8d
je 0x1280a
incq %rcx
cmpl %edi, %esi
je 0x127ee
cmpl %edi, %esi
jne 0x12895
leaq 0x3f54(%rip), %rsi      # 0x1676d
leaq 0x3855(%rip), %rdx      # 0x16075
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe860
movslq 0x4d4(%rbx), %rcx
movl 0x4d8(%rbx), %eax
subl %ecx, %eax
jle 0x128b2
addq 0x4c8(%rbx), %rcx
movl %eax, %edx
movq 0x4b8(%rbx), %rsi
cmpq %rdx, %rsi
cmovgel %eax, %esi
movslq %esi, %r13
movq %r15, %rdi
movl 0x4(%rsp), %esi
movq 0x8(%rsp), %rdx
movq %r13, %r8
callq 0xe799
addq 0x4c0(%rbx), %r13
movq %r13, 0x4c0(%rbx)
jmp 0x128b9
leaq 0x37c6(%rip), %rdx      # 0x16045
leaq 0x39b9(%rip), %rcx      # 0x1623f
xorl %ebp, %ebp
movq %rbx, %rdi
movl $0x19b, %esi            # imm = 0x19B
jmp 0x12979
leaq 0x37c6(%rip), %rdx      # 0x16062
leaq 0x399c(%rip), %rcx      # 0x1623f
xorl %ebp, %ebp
movq %rbx, %rdi
movl $0x1a1, %esi            # imm = 0x1A1
jmp 0x12979
movq 0x4c0(%rbx), %r13
movq 0x4b8(%rbx), %rdx
cmpq %rdx, %r13
jge 0x12957
movl $0x2000, %ebp           # imm = 0x2000
leaq 0x10(%rsp), %r12
subq %r13, %rdx
cmpq %rbp, %rdx
cmovgeq %rbp, %rdx
movq 0x460(%rbx), %rdi
testq %rdi, %rdi
je 0x128f4
movq %r12, %rsi
callq *0x9f26(%rip)           # 0x1c818
jmp 0x12907
movl 0x470(%rbx), %edi
movslq %edx, %rdx
movq %r12, %rsi
xorl %ecx, %ecx
callq 0x5180
testl %eax, %eax
jle 0x12949
movl %eax, %r14d
movq %r15, %rdi
movl 0x4(%rsp), %esi
movq 0x8(%rsp), %rdx
movq %r12, %rcx
movq %r14, %r8
callq 0xe799
movq 0x4c0(%rbx), %r13
cmpq %r14, %rax
jne 0x12950
addq %r14, %r13
movq %r13, 0x4c0(%rbx)
movq 0x4b8(%rbx), %rdx
cmpq %rdx, %r13
jl 0x128d3
jmp 0x12950
movq 0x4c0(%rbx), %r13
movq 0x4b8(%rbx), %rdx
movl $0x1, %ebp
cmpq %rdx, %r13
je 0x12980
leaq 0x3727(%rip), %rdx      # 0x1608f
leaq 0x38d0(%rip), %rcx      # 0x1623f
xorl %ebp, %ebp
movq %rbx, %rdi
movl $0x241, %esi            # imm = 0x241
xorl %eax, %eax
callq 0x12224
movl %ebp, %eax
addq $0x2018, %rsp           # imm = 0x2018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq