// File: /workspace/github_c_makefile_star2_O2/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
andl $0x0, 0x84(%rdx)
xorps %xmm0, %xmm0
movups %xmm0, (%rdx)
movups %xmm0, 0x10(%rdx)
movups %xmm0, 0x270(%rdx)
pushq $-0x1
popq %r15
testq %rsi, %rsi
je 0x5f4f2
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r12
movb $0x0, -0x1(%rdi,%rsi)
movzbl (%r12), %r13d
testq %r13, %r13
je 0x5f2b1
callq 0xc190
movq (%rax), %rax
testb $0x20, 0x1(%rax,%r13,2)
je 0x5f2b1
incq %r12
jmp 0x5f292
leaq -0x30(%rbp), %r13
movq %r12, (%r13)
leaq 0x8841(%rip), %r12      # 0x67b01
movq %r13, %rdi
movq %r12, %rsi
callq 0x5f504
movq %rax, (%r14)
movq %r13, %rdi
movq %r12, %rsi
callq 0x5f504
movq %rax, 0x8(%r14)
leaq 0x9086(%rip), %rsi      # 0x6836a
movq %r13, %rdi
callq 0x5f504
movq %rax, %r12
movq %rax, 0x10(%r14)
movq (%r14), %r13
leaq 0x5670(%rip), %rsi      # 0x6496d
movq %r13, %rdi
callq 0xc970
testl %eax, %eax
je 0x5f3f4
leaq 0x5653(%rip), %rsi      # 0x64967
movq %r13, %rdi
callq 0xc970
testl %eax, %eax
je 0x5f3f4
leaq 0x54bb(%rip), %rsi      # 0x647e6
movq %r13, %rdi
callq 0xc970
testl %eax, %eax
je 0x5f3f4
leaq 0x905d(%rip), %rsi      # 0x6839f
movq %r13, %rdi
callq 0xc970
testl %eax, %eax
je 0x5f3f4
leaq 0x5489(%rip), %rsi      # 0x647e2
movq %r13, %rdi
callq 0xc970
testl %eax, %eax
je 0x5f3f4
leaq 0xa0f9(%rip), %rsi      # 0x69469
movq %r13, %rdi
callq 0xc970
testl %eax, %eax
je 0x5f3f4
leaq 0xa0ed(%rip), %rsi      # 0x69470
movq %r13, %rdi
callq 0xc970
testl %eax, %eax
je 0x5f3f4
leaq 0xa0e2(%rip), %rsi      # 0x69478
movq %r13, %rdi
callq 0xc970
testl %eax, %eax
je 0x5f3f4
leaq 0xa0d8(%rip), %rsi      # 0x69481
movq %r13, %rdi
callq 0xc970
testl %eax, %eax
je 0x5f3f4
leaq 0xa0cb(%rip), %rsi      # 0x69487
movq %r13, %rdi
callq 0xc970
testl %eax, %eax
je 0x5f3f4
leaq 0xa094(%rip), %rsi      # 0x69463
pushq $0x5
popq %rdx
movq %r13, %rdi
callq 0xc800
testl %eax, %eax
jne 0x5f4f2
movq 0x8(%r14), %rdi
callq 0xc380
movl %eax, 0x27c(%r14)
jmp 0x5f416
leaq 0xa068(%rip), %rsi      # 0x69463
pushq $0x5
popq %rdx
movq %r12, %rdi
callq 0xc800
testl %eax, %eax
jne 0x5f4f2
addq $0x5, %r12
movq %r12, 0x10(%r14)
leaq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0x5f551
movq 0x8(%r14), %r15
pushq $0x3f
popq %rsi
movq %r15, %rdi
callq 0xc600
movq %rax, 0x18(%r14)
testq %rax, %rax
je 0x5f44b
movq %rax, %rcx
incq %rcx
movq %rcx, 0x18(%r14)
movb $0x0, (%rax)
movq 0x8(%r14), %r15
movq %r15, %rdi
callq 0xc470
movslq %eax, %rsi
leal 0x1(%rsi), %eax
movslq %eax, %rcx
movq %r15, %rdi
movq %r15, %rdx
xorl %r8d, %r8d
callq 0x58ca0
movq 0x8(%r14), %rcx
movb (%rcx), %dl
movl %edx, %eax
andb $-0x2, %al
cmpb $0x2e, %al
jne 0x5f4ef
movq %rcx, %rax
testb %dl, %dl
je 0x5f4ec
movb %dl, (%rax)
incq %rax
movzbl (%rcx), %edx
incq %rcx
cmpl $0x5c, %edx
je 0x5f494
cmpl $0x2f, %edx
jne 0x5f4e8
movq %rcx, %rsi
movq %rsi, %rcx
movzbl (%rsi), %edx
cmpl $0x2e, %edx
jne 0x5f4c9
movzbl 0x1(%rcx), %esi
movb $0x2e, %dl
cmpl $0x2e, %esi
jne 0x5f4d8
leaq 0x2(%rcx), %rsi
movzbl 0x2(%rcx), %edi
testl %edi, %edi
je 0x5f497
cmpl $0x5c, %edi
je 0x5f4c3
cmpl $0x2f, %edi
jne 0x5f47b
addq $0x3, %rcx
jmp 0x5f494
cmpl $0x5c, %edx
je 0x5f4d3
cmpl $0x2f, %edx
jne 0x5f47b
incq %rcx
jmp 0x5f494
cmpl $0x5c, %esi
je 0x5f4e2
cmpl $0x2f, %esi
jne 0x5f47b
addq $0x2, %rcx
jmp 0x5f494
movb (%rcx), %dl
jmp 0x5f47b
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