// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: parse_http_message
static size_t parse_http_message(char *buf, size_t len,
                                 struct mg_connection *ri) {
  int is_request, n;

  // Reset the connection. Make sure that we don't touch fields that are
  // set elsewhere: remote_ip, remote_port, server_param
  ri->request_method = ri->uri = ri->http_version = ri->query_string = NULL;
  ri->num_headers = ri->status_code = ri->is_websocket = ri->content_len = 0;

  if (len < 1) return ~0;

  buf[len - 1] = '\0';

  // RFC says that all initial whitespaces should be ignored
  while (*buf != '\0' && isspace(* (unsigned char *) buf)) {
    buf++;
  }
  ri->request_method = skip(&buf, " ");
  ri->uri = skip(&buf, " ");
  ri->http_version = skip(&buf, "\r\n");

  // HTTP message could be either HTTP request or HTTP response, e.g.
  // "GET / HTTP/1.0 ...." or  "HTTP/1.0 200 OK ..."
  is_request = is_valid_http_method(ri->request_method);
  if ((is_request && memcmp(ri->http_version, "HTTP/", 5) != 0) ||
      (!is_request && memcmp(ri->request_method, "HTTP/", 5) != 0)) {
    len = ~0;
  } else {
    if (is_request) {
      ri->http_version += 5;
    } else {
      ri->status_code = atoi(ri->uri);
    }
    parse_http_headers(&buf, ri);

    if ((ri->query_string = strchr(ri->uri, '?')) != NULL) {
      *(char *) ri->query_string++ = '\0';
    }
    n = (int) strlen(ri->uri);
    mg_url_decode(ri->uri, n, (char *) ri->uri, n + 1, 0);
    if (*ri->uri == '/' || *ri->uri == '.') {
      remove_double_dots_and_double_slashes((char *) ri->uri);
    }
  }

  return len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl $0x0, 0x84(%rdx)
xorps %xmm0, %xmm0
movups %xmm0, (%rdx)
movups %xmm0, 0x10(%rdx)
movups %xmm0, 0x270(%rdx)
movq $-0x1, %r15
testq %rsi, %rsi
je 0x6e677
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r12
movb $0x0, -0x1(%rdi,%rsi)
movb (%rdi), %r13b
testb %r13b, %r13b
je 0x6e435
callq 0xc170
movq (%rax), %rax
movzbl %r13b, %ecx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x6e435
movb 0x1(%r12), %r13b
incq %r12
testb %r13b, %r13b
jne 0x6e41d
leaq -0x30(%rbp), %r13
movq %r12, (%r13)
leaq 0x96dd(%rip), %r12      # 0x77b21
movq %r13, %rdi
movq %r12, %rsi
callq 0x6e689
movq %rax, (%r14)
movq %r13, %rdi
movq %r12, %rsi
callq 0x6e689
movq %rax, 0x8(%r14)
leaq 0x9f22(%rip), %rsi      # 0x7838a
movq %r13, %rdi
callq 0x6e689
movq %rax, %r12
movq %rax, 0x10(%r14)
movq (%r14), %r13
leaq 0x650c(%rip), %rsi      # 0x7498d
movq %r13, %rdi
callq 0xc950
testl %eax, %eax
je 0x6e577
leaq 0x64ef(%rip), %rsi      # 0x74987
movq %r13, %rdi
callq 0xc950
testl %eax, %eax
je 0x6e577
leaq 0x6357(%rip), %rsi      # 0x74806
movq %r13, %rdi
callq 0xc950
testl %eax, %eax
je 0x6e577
leaq 0x9ef9(%rip), %rsi      # 0x783bf
movq %r13, %rdi
callq 0xc950
testl %eax, %eax
je 0x6e577
leaq 0x6325(%rip), %rsi      # 0x74802
movq %r13, %rdi
callq 0xc950
testl %eax, %eax
je 0x6e577
leaq 0xaf95(%rip), %rsi      # 0x79489
movq %r13, %rdi
callq 0xc950
testl %eax, %eax
je 0x6e577
leaq 0xaf89(%rip), %rsi      # 0x79490
movq %r13, %rdi
callq 0xc950
testl %eax, %eax
je 0x6e577
leaq 0xaf7e(%rip), %rsi      # 0x79498
movq %r13, %rdi
callq 0xc950
testl %eax, %eax
je 0x6e577
leaq 0xaf74(%rip), %rsi      # 0x794a1
movq %r13, %rdi
callq 0xc950
testl %eax, %eax
je 0x6e577
leaq 0xaf67(%rip), %rsi      # 0x794a7
movq %r13, %rdi
callq 0xc950
testl %eax, %eax
je 0x6e577
movl $0x50545448, %eax       # imm = 0x50545448
xorl (%r13), %eax
movzbl 0x4(%r13), %ecx
xorl $0x2f, %ecx
orl %eax, %ecx
jne 0x6e677
movq 0x8(%r14), %rdi
callq 0xc370
movl %eax, 0x27c(%r14)
jmp 0x6e599
movl $0x50545448, %eax       # imm = 0x50545448
xorl (%r12), %eax
movzbl 0x4(%r12), %ecx
xorl $0x2f, %ecx
orl %eax, %ecx
jne 0x6e677
addq $0x5, %r12
movq %r12, 0x10(%r14)
leaq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0x6e6f9
movq 0x8(%r14), %r15
movq %r15, %rdi
movl $0x3f, %esi
callq 0xc5f0
movq %rax, 0x18(%r14)
testq %rax, %rax
je 0x6e5d0
movq %rax, %rcx
incq %rcx
movq %rcx, 0x18(%r14)
movb $0x0, (%rax)
movq 0x8(%r14), %r15
movq %r15, %rdi
callq 0xc460
movslq %eax, %rsi
leal 0x1(%rsi), %eax
movslq %eax, %rcx
movq %r15, %rdi
movq %r15, %rdx
xorl %r8d, %r8d
callq 0x67b2c
movq 0x8(%r14), %rax
movb (%rax), %dl
movl %edx, %ecx
andb $-0x2, %cl
cmpb $0x2e, %cl
jne 0x6e674
movq %rax, %rcx
movb %dl, (%rax)
movzbl (%rcx), %edx
incq %rcx
cmpl $0x5c, %edx
je 0x6e614
cmpl $0x2f, %edx
jne 0x6e668
movq %rcx, %rsi
movq %rsi, %rcx
movzbl (%rsi), %edx
cmpl $0x2e, %edx
jne 0x6e649
movzbl 0x1(%rcx), %esi
movb $0x2e, %dl
cmpl $0x2e, %esi
jne 0x6e658
leaq 0x2(%rcx), %rsi
movzbl 0x2(%rcx), %edi
testl %edi, %edi
je 0x6e617
cmpl $0x5c, %edi
je 0x6e643
cmpl $0x2f, %edi
jne 0x6e66a
addq $0x3, %rcx
jmp 0x6e614
cmpl $0x5c, %edx
je 0x6e653
cmpl $0x2f, %edx
jne 0x6e66a
incq %rcx
jmp 0x6e614
cmpl $0x5c, %esi
je 0x6e662
cmpl $0x2f, %esi
jne 0x6e66a
addq $0x2, %rcx
jmp 0x6e614
movb (%rcx), %dl
incq %rax
testb %dl, %dl
jne 0x6e602
movb $0x0, (%rax)
movq %rbx, %r15
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq