// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: get_var
static int get_var(const char *data, size_t data_len, const char *name,
                   char *dst, size_t dst_len, int n) {
  const char *p, *e = data + data_len, *s;
  size_t name_len;
  int i = 0, len = -1;

  if (dst == NULL || dst_len == 0) {
    len = -2;
  } else if (data == NULL || name == NULL || data_len == 0) {
    dst[0] = '\0';
  } else {
    name_len = strlen(name);
    dst[0] = '\0';

    // data is "var1=val1&var2=val2...". Find variable first
    for (p = data; p + name_len < e; p++) {
      if ((p == data || p[-1] == '&') && p[name_len] == '=' &&
          !mg_strncasecmp(name, p, name_len)) {

        if (n != i++) continue;

        // Point p to variable value
        p += name_len + 1;

        // Point s to the end of the value
        s = (const char *) memchr(p, '&', (size_t)(e - p));
        if (s == NULL) {
          s = e;
        }
        assert(s >= p);

        // Decode variable into destination buffer
        len = mg_url_decode(p, (size_t)(s - p), dst, dst_len, 1);

        // Redirect error code from -1 to -2 (destination buffer too small).
        if (len == -1) {
          len = -2;
        }
        break;
      }
    }
  }

  return len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movq -0x8(%rbp), %rax
addq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x54(%rbp)
movl $0xffffffff, -0x58(%rbp) # imm = 0xFFFFFFFF
cmpq $0x0, -0x20(%rbp)
je 0xb5008
cmpq $0x0, -0x28(%rbp)
jne 0xb5014
movl $0xfffffffe, -0x58(%rbp) # imm = 0xFFFFFFFE
jmp 0xb5176
cmpq $0x0, -0x8(%rbp)
je 0xb5029
cmpq $0x0, -0x18(%rbp)
je 0xb5029
cmpq $0x0, -0x10(%rbp)
jne 0xb5035
movq -0x20(%rbp), %rax
movb $0x0, (%rax)
jmp 0xb5174
movq -0x18(%rbp), %rdi
callq 0xd550
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rax
movb $0x0, (%rax)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
addq -0x50(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0xb5172
movq -0x38(%rbp), %rax
cmpq -0x8(%rbp), %rax
je 0xb507e
movq -0x38(%rbp), %rax
movsbl -0x1(%rax), %eax
cmpl $0x26, %eax
jne 0xb515f
movq -0x38(%rbp), %rax
movq -0x50(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3d, %eax
jne 0xb515f
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0xb2e40
cmpl $0x0, %eax
jne 0xb515f
movl -0x2c(%rbp), %eax
movl -0x54(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x54(%rbp)
cmpl %ecx, %eax
je 0xb50c4
jmp 0xb5161
movq -0x50(%rbp), %rax
addq $0x1, %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rax
subq %rax, %rdx
movl $0x26, %esi
callq 0xd5c0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xb5100
movq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x38(%rbp), %rax
jb 0xb510c
jmp 0xb512b
leaq 0x1300c(%rip), %rdi     # 0xc811f
leaq 0x11a41(%rip), %rsi     # 0xc6b5b
movl $0x13c4, %edx           # imm = 0x13C4
leaq 0x13000(%rip), %rcx     # 0xc8126
callq 0xd280
movq -0x38(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x38(%rbp), %rax
subq %rax, %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl $0x1, %r8d
callq 0xb0db0
movl %eax, -0x58(%rbp)
cmpl $-0x1, -0x58(%rbp)
jne 0xb515d
movl $0xfffffffe, -0x58(%rbp) # imm = 0xFFFFFFFE
jmp 0xb5172
jmp 0xb5161
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xb5051
jmp 0xb5174
jmp 0xb5176
movl -0x58(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nop