// File: /workspace/github_c_makefile_star2_O3/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
movq %rbx, -0x30(%rbp)
testq %rbx, %rbx
sete %al
movq %r13, -0x38(%rbp)
testq %r13, %r13
sete %cl
orb %al, %cl
jne 0x693ed
movq -0x30(%rbp), %rax
movb $0x0, (%rax)
leaq (%r15,%r14), %rbx
testq %r15, %r15
setne %al
cmpq %r14, %r12
setl %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x6944c
xorl %r14d, %r14d
movq -0x40(%rbp), %r13
testq %r14, %r14
je 0x6941f
movzbl -0x1(%r15), %eax
cmpl $0x2c, %eax
je 0x6941f
cmpl $0x20, %eax
jne 0x69438
cmpb $0x3d, (%r15,%r12)
jne 0x69438
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0xc7c0
testl %eax, %eax
je 0x69451
leaq (%r15,%r12), %rax
incq %rax
incq %r15
decq %r14
cmpq %rbx, %rax
jb 0x6940b
jmp 0x69451
testq %r15, %r15
je 0x69471
leaq (%r12,%r15), %rcx
incq %rcx
cmpq %rbx, %rcx
jae 0x69471
movzbl (%rcx), %edi
cmpl $0x27, %edi
je 0x6946a
cmpl $0x22, %edi
jne 0x69478
incq %rcx
movl %edi, %esi
jmp 0x69482
xorl %eax, %eax
jmp 0x69526
movl $0x20, %esi
movl $0x2c, %edi
movq -0x30(%rbp), %r15
movq -0x38(%rbp), %r12
xorl %eax, %eax
movl $0x0, %edx
movq %rcx, %r8
cmpq %rbx, %rcx
jae 0x694ea
movslq %r12d, %r9
xorl %edx, %edx
movl $0x5c, %r10d
movq %rcx, %r8
movb (%r8), %r11b
movsbl %r11b, %r14d
cmpl %r14d, %esi
je 0x694ea
cmpl %r14d, %edi
je 0x694ea
cmpq %r9, %rdx
jge 0x694ea
cmpl %edi, %esi
jne 0x694db
cmpb $0x5c, %r11b
jne 0x694db
leaq 0x1(%r8), %r14
movsbl 0x1(%r8), %r11d
cmpl %r11d, %edi
cmovnel %r10d, %r11d
cmoveq %r14, %r8
incq %r8
movb %r11b, (%r15,%rdx)
incq %rdx
cmpq %rbx, %r8
jb 0x694a7
cmpl %r12d, %edx
jge 0x69526
cmpl $0x20, %esi
je 0x694fc
movsbl (%r8), %edi
cmpl %edi, %esi
jne 0x69526
testl %edx, %edx
je 0x6951a
leal -0x1(%rdx), %eax
cmpb $0x2c, (%rcx,%rax)
cmovel %eax, %edx
testl %edx, %edx
jle 0x6951c
leal -0x1(%rdx), %eax
cmpb $0x3b, (%rcx,%rax)
cmovel %eax, %edx
jmp 0x6951c
xorl %edx, %edx
movslq %edx, %rax
movb $0x0, (%r15,%rax)
movl %edx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq