// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_http_parse_header
int mg_http_parse_header(struct mg_str *hdr, const char *var_name, char *buf,
                         size_t buf_size) {
  int ch = ' ', ch1 = ',', len = 0, n = strlen(var_name);
  const char *p, *end = hdr ? hdr->p + hdr->len : NULL, *s = NULL;

  if (buf != NULL && buf_size > 0) buf[0] = '\0';
  if (hdr == NULL) return 0;

  /* Find where variable starts */
  for (s = hdr->p; s != NULL && s + n < end; s++) {
    if ((s == hdr->p || s[-1] == ch || s[-1] == ch1 || s[-1] == ';') &&
        s[n] == '=' && !strncmp(s, var_name, n))
      break;
  }

  if (s != NULL && &s[n + 1] < end) {
    s += n + 1;
    if (*s == '"' || *s == '\'') {
      ch = ch1 = *s++;
    }
    p = s;
    while (p < end && p[0] != ch && p[0] != ch1 && len < (int) buf_size) {
      if (ch != ' ' && p[0] == '\\' && p[1] == ch) p++;
      buf[len++] = *p++;
    }
    if (len >= (int) buf_size || (ch != ' ' && *p != ch)) {
      len = 0;
    } else {
      if (len > 0 && s[len - 1] == ',') len--;
      if (len > 0 && s[len - 1] == ';') len--;
      buf[len] = '\0';
    }
  }

  return len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x20, -0x2c(%rbp)
movl $0x2c, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3180
movl %eax, -0x38(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x12c55
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
addq 0x8(%rcx), %rax
movq %rax, -0x58(%rbp)
jmp 0x12c5d
xorl %eax, %eax
movq %rax, -0x58(%rbp)
jmp 0x12c5d
movq -0x58(%rbp), %rax
movq %rax, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x12c82
cmpq $0x0, -0x28(%rbp)
jbe 0x12c82
movq -0x20(%rbp), %rax
movb $0x0, (%rax)
cmpq $0x0, -0x10(%rbp)
jne 0x12c95
movl $0x0, -0x4(%rbp)
jmp 0x12ece
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x50(%rbp)
movb %al, -0x59(%rbp)
je 0x12cc1
movq -0x50(%rbp), %rax
movslq -0x38(%rbp), %rcx
addq %rcx, %rax
cmpq -0x48(%rbp), %rax
setb %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
testb $0x1, %al
jne 0x12cca
jmp 0x12d3a
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
je 0x12cfe
movq -0x50(%rbp), %rax
movsbl -0x1(%rax), %eax
cmpl -0x2c(%rbp), %eax
je 0x12cfe
movq -0x50(%rbp), %rax
movsbl -0x1(%rax), %eax
cmpl -0x30(%rbp), %eax
je 0x12cfe
movq -0x50(%rbp), %rax
movsbl -0x1(%rax), %eax
cmpl $0x3b, %eax
jne 0x12d27
movq -0x50(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3d, %eax
jne 0x12d27
movq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rsi
movslq -0x38(%rbp), %rdx
callq 0x30b0
cmpl $0x0, %eax
jne 0x12d27
jmp 0x12d3a
jmp 0x12d29
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x12ca0
cmpq $0x0, -0x50(%rbp)
je 0x12ec8
movq -0x50(%rbp), %rax
movl -0x38(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
cmpq -0x48(%rbp), %rax
jae 0x12ec8
movl -0x38(%rbp), %ecx
addl $0x1, %ecx
movq -0x50(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x22, %eax
je 0x12d8b
movq -0x50(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x27, %eax
jne 0x12da3
movq -0x50(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x50(%rbp)
movsbl (%rax), %eax
movl %eax, -0x30(%rbp)
movl %eax, -0x2c(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rcx
xorl %eax, %eax
cmpq -0x48(%rbp), %rcx
movb %al, -0x5a(%rbp)
jae 0x12deb
movq -0x40(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl -0x2c(%rbp), %ecx
movb %al, -0x5a(%rbp)
je 0x12deb
movq -0x40(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl -0x30(%rbp), %ecx
movb %al, -0x5a(%rbp)
je 0x12deb
movl -0x34(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl %ecx, %eax
setl %al
movb %al, -0x5a(%rbp)
movb -0x5a(%rbp), %al
testb $0x1, %al
jne 0x12df4
jmp 0x12e4a
cmpl $0x20, -0x2c(%rbp)
je 0x12e1f
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5c, %eax
jne 0x12e1f
movq -0x40(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl -0x2c(%rbp), %eax
jne 0x12e1f
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movb (%rax), %dl
movq -0x20(%rbp), %rax
movl -0x34(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x34(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
jmp 0x12dab
movl -0x34(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl %ecx, %eax
jge 0x12e67
cmpl $0x20, -0x2c(%rbp)
je 0x12e70
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl -0x2c(%rbp), %eax
je 0x12e70
movl $0x0, -0x34(%rbp)
jmp 0x12ec6
cmpl $0x0, -0x34(%rbp)
jle 0x12e95
movq -0x50(%rbp), %rax
movl -0x34(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2c, %eax
jne 0x12e95
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jle 0x12eba
movq -0x50(%rbp), %rax
movl -0x34(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3b, %eax
jne 0x12eba
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb $0x0, (%rax,%rcx)
jmp 0x12ec8
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)