// File: /workspace/github_c_makefile_star2_O0/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
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x270(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x278(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x27c(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x84(%rax)
cmpq $0x1, -0x18(%rbp)
jae 0xb9ec0
movq $-0x1, -0x8(%rbp)
jmp 0xba0af
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
subq $0x1, %rcx
movb $0x0, (%rax,%rcx)
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x29(%rbp)
je 0xb9f05
callq 0xd1f0
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movzbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
setne %al
movb %al, -0x29(%rbp)
movb -0x29(%rbp), %al
testb $0x1, %al
jne 0xb9f0e
jmp 0xb9f1c
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0xb9ed0
leaq -0x10(%rbp), %rdi
leaq 0xc0d3(%rip), %rsi      # 0xc5ffa
callq 0xba0c0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
leaq -0x10(%rbp), %rdi
leaq 0xc0b9(%rip), %rsi      # 0xc5ffa
callq 0xba0c0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
leaq -0x10(%rbp), %rdi
leaq 0xcd15(%rip), %rsi      # 0xc6c71
callq 0xba0c0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0xba160
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0xb9f9f
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0xddf3(%rip), %rsi      # 0xc7d83
movl $0x5, %edx
callq 0xddb0
cmpl $0x0, %eax
jne 0xb9fc2
cmpl $0x0, -0x24(%rbp)
jne 0xb9fcf
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq 0xddd0(%rip), %rsi      # 0xc7d83
movl $0x5, %edx
callq 0xddb0
cmpl $0x0, %eax
je 0xb9fcf
movq $-0x1, -0x18(%rbp)
jmp 0xba0a7
cmpl $0x0, -0x24(%rbp)
je 0xb9fe7
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x5, %rcx
movq %rcx, 0x10(%rax)
jmp 0xba000
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xd440
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x27c(%rax)
movq -0x20(%rbp), %rsi
leaq -0x10(%rbp), %rdi
callq 0xba2b0
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x3f, %esi
callq 0xd710
movq -0x20(%rbp), %rcx
movq %rax, 0x18(%rcx)
cmpq $0x0, %rax
je 0xba043
movq -0x20(%rbp), %rcx
movq 0x18(%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x18(%rcx)
movb $0x0, (%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xd550
movl %eax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
movslq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdx
movl -0x28(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
xorl %r8d, %r8d
callq 0xb0db0
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
je 0xba098
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
jne 0xba0a5
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xba380
jmp 0xba0a7
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)