// File: /workspace/github_c_makefile_star2_O1/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
movq %rdi, -0x30(%rbp)
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 0x70314
movq %rdx, %r14
movq %rsi, %rbx
movb $0x0, -0x1(%rdi,%rsi)
movq -0x30(%rbp), %r13
movb (%r13), %r12b
testb %r12b, %r12b
je 0x700a7
callq 0xc170
movq (%rax), %rax
movzbl %r12b, %ecx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x700a7
movb 0x1(%r13), %r12b
incq %r13
testb %r12b, %r12b
jne 0x70090
leaq -0x30(%rbp), %r12
movq %r13, (%r12)
leaq 0x9a60(%rip), %r13      # 0x79b16
movq %r12, %rdi
movq %r13, %rsi
callq 0x70326
movq %rax, (%r14)
movq %r12, %rdi
movq %r13, %rsi
callq 0x70326
movq %rax, 0x8(%r14)
leaq 0xa2b0(%rip), %rsi      # 0x7a38a
movq %r12, %rdi
callq 0x70326
movq %rax, %r12
movq %rax, 0x10(%r14)
movq (%r14), %r13
leaq 0x6892(%rip), %rsi      # 0x76985
movq %r13, %rdi
callq 0xc950
testl %eax, %eax
je 0x701b9
leaq 0x6875(%rip), %rsi      # 0x7697f
movq %r13, %rdi
callq 0xc950
testl %eax, %eax
je 0x701b9
leaq 0x66dd(%rip), %rsi      # 0x767fe
movq %r13, %rdi
callq 0xc950
testl %eax, %eax
je 0x701b9
leaq 0xa287(%rip), %rsi      # 0x7a3bf
movq %r13, %rdi
callq 0xc950
testl %eax, %eax
je 0x701b9
leaq 0x66af(%rip), %rsi      # 0x767fa
movq %r13, %rdi
callq 0xc950
testl %eax, %eax
je 0x701b9
leaq 0xb32b(%rip), %rsi      # 0x7b489
movq %r13, %rdi
callq 0xc950
testl %eax, %eax
je 0x701b9
leaq 0xb31f(%rip), %rsi      # 0x7b490
movq %r13, %rdi
callq 0xc950
testl %eax, %eax
je 0x701b9
leaq 0xb314(%rip), %rsi      # 0x7b498
movq %r13, %rdi
callq 0xc950
testl %eax, %eax
je 0x701b9
leaq 0xb30a(%rip), %rsi      # 0x7b4a1
movq %r13, %rdi
callq 0xc950
testl %eax, %eax
je 0x701b9
leaq 0xb2fd(%rip), %rsi      # 0x7b4a7
movq %r13, %rdi
callq 0xc950
testl %eax, %eax
setne %al
jmp 0x701bb
xorl %eax, %eax
testb %al, %al
je 0x701ee
movl $0x50545448, %ecx       # imm = 0x50545448
xorl (%r13), %ecx
movzbl 0x4(%r13), %edx
xorl $0x2f, %edx
orl %ecx, %edx
jne 0x70314
testb %al, %al
je 0x70208
movq 0x8(%r14), %rdi
callq 0xc370
movl %eax, 0x27c(%r14)
jmp 0x70210
movl $0x50545448, %eax       # imm = 0x50545448
xorl (%r12), %eax
movzbl 0x4(%r12), %ecx
xorl $0x2f, %ecx
orl %eax, %ecx
jne 0x70314
addq $0x5, %r12
movq %r12, 0x10(%r14)
leaq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0x70396
movq 0x8(%r14), %rdi
movl $0x3f, %esi
callq 0xc5f0
movq %rax, 0x18(%r14)
testq %rax, %rax
je 0x70240
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 0x6971e
movq 0x8(%r14), %rax
movb (%rax), %cl
movl %ecx, %edx
andb $-0x2, %dl
cmpb $0x2e, %dl
jne 0x70311
testb %cl, %cl
je 0x7030e
movq %rax, %rdx
movb %cl, (%rax)
movzbl (%rdx), %ecx
incq %rdx
cmpl $0x5c, %ecx
je 0x70294
cmpl $0x2f, %ecx
jne 0x70301
movq %rdx, %rcx
movzbl (%rdx), %edx
cmpl $0x2e, %edx
je 0x702b1
cmpl $0x5c, %edx
je 0x702a9
cmpl $0x2f, %edx
jne 0x702fe
incq %rcx
movq %rcx, %rdx
jmp 0x70294
movzbl 0x1(%rcx), %esi
cmpl $0x5c, %esi
je 0x702bf
cmpl $0x2f, %esi
jne 0x702c8
addq $0x2, %rcx
movq %rcx, %rdx
jmp 0x70294
cmpb $0x2e, %dl
jne 0x702fe
movb 0x1(%rcx), %sil
cmpb $0x2e, %sil
jne 0x702fe
leaq 0x2(%rcx), %rdx
cmpb $0x0, 0x2(%rcx)
je 0x70294
cmpb $0x2e, %sil
jne 0x702fe
movzbl 0x2(%rcx), %edx
cmpl $0x5c, %edx
je 0x702f5
cmpl $0x2f, %edx
jne 0x702fe
addq $0x3, %rcx
movq %rcx, %rdx
jmp 0x70294
movq %rcx, %rdx
incq %rax
movb (%rdx), %cl
testb %cl, %cl
jne 0x70282
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