// File: /workspace/github_c_makefile_star2_O1/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: parse_header
static int parse_header(const char *str, size_t str_len, const char *var_name,
                        char *buf, size_t buf_size) {
  int ch = ' ', ch1 = ',', len = 0;
  size_t n = strlen(var_name);
  const char *p, *end = str + str_len, *s = NULL;

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

  // Find where variable starts
  for (s = str; s != NULL && s + n < end; s++) {
    if ((s == str || s[-1] == ch || s[-1] == ch1) && s[n] == '=' &&
        !memcmp(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 == ch1 && 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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %r13
movq %rcx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq %rdx, -0x40(%rbp)
movq %rdx, %rdi
callq 0xc460
movq %rax, %r12
testq %rbx, %rbx
sete %al
movq %r13, -0x38(%rbp)
testq %r13, %r13
sete %cl
orb %al, %cl
jne 0x6afdb
movb $0x0, (%rbx)
movq %rbx, -0x30(%rbp)
leaq (%r15,%r14), %rbx
testq %r15, %r15
setne %r13b
cmpq %r14, %r12
setl %al
andb %r13b, %al
cmpb $0x1, %al
jne 0x6b03d
xorl %r14d, %r14d
testq %r14, %r14
je 0x6b00e
movzbl -0x1(%r15), %eax
cmpl $0x2c, %eax
je 0x6b00e
cmpl $0x20, %eax
jne 0x6b028
cmpb $0x3d, (%r15,%r12)
jne 0x6b028
movq %r15, %rdi
movq -0x40(%rbp), %rsi
movq %r12, %rdx
callq 0xc7c0
testl %eax, %eax
je 0x6b03d
leaq (%r15,%r12), %rax
incq %rax
incq %r15
decq %r14
movb $0x1, %r13b
cmpq %rbx, %rax
jb 0x6affa
xorl %eax, %eax
testb $0x1, %r13b
je 0x6b116
leaq (%r12,%r15), %rcx
incq %rcx
cmpq %rbx, %rcx
jae 0x6b116
movzbl (%rcx), %eax
cmpl $0x27, %eax
je 0x6b066
cmpl $0x22, %eax
jne 0x6b072
movsbl %al, %r8d
incq %rcx
movl %r8d, %esi
jmp 0x6b07d
movl $0x20, %esi
movl $0x2c, %r8d
movq -0x30(%rbp), %r14
movq -0x38(%rbp), %r15
xorl %eax, %eax
movl $0x0, %edx
movq %rcx, %rdi
cmpq %rbx, %rcx
jae 0x6b0dc
movslq %r15d, %r9
xorl %edx, %edx
movq %rcx, %rdi
movb (%rdi), %r10b
movsbl %r10b, %r11d
cmpl %r11d, %esi
je 0x6b0dc
cmpl %r11d, %r8d
je 0x6b0dc
cmpq %r9, %rdx
jge 0x6b0dc
cmpl %r8d, %esi
jne 0x6b0ca
cmpb $0x5c, %r10b
jne 0x6b0ca
movsbl 0x1(%rdi), %r10d
cmpl %r10d, %esi
jne 0x6b0ca
incq %rdi
movb (%rdi), %r10b
incq %rdi
movb %r10b, (%r14,%rdx)
incq %rdx
cmpq %rbx, %rdi
jb 0x6b09c
cmpl %r15d, %edx
jge 0x6b116
cmpl $0x20, %esi
je 0x6b0ed
movsbl (%rdi), %edi
cmpl %edi, %esi
jne 0x6b116
testl %edx, %edx
je 0x6b0fb
leal -0x1(%rdx), %eax
cmpb $0x2c, (%rcx,%rax)
cmovel %eax, %edx
movq -0x30(%rbp), %rsi
testl %edx, %edx
jle 0x6b10d
leal -0x1(%rdx), %eax
cmpb $0x3b, (%rcx,%rax)
cmovel %eax, %edx
movslq %edx, %rax
movb $0x0, (%rsi,%rax)
movl %edx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq