// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: mg_url_decode
int mg_url_decode(const char *src, size_t src_len, char *dst,
                  size_t dst_len, int is_form_url_encoded) {
  size_t i, j = 0;
  int a, b;
#define HEXTOI(x) (isdigit(x) ? (x) - '0' : (x) - 'W')

  for (i = j = 0; i < src_len && j < dst_len - 1; i++, j++) {
    if (src[i] == '%' && i + 2 < src_len &&
        isxdigit(* (const unsigned char *) (src + i + 1)) &&
        isxdigit(* (const unsigned char *) (src + i + 2))) {
      a = tolower(* (const unsigned char *) (src + i + 1));
      b = tolower(* (const unsigned char *) (src + i + 2));
      dst[j] = (char) ((HEXTOI(a) << 4) | HEXTOI(b));
      i += 2;
    } else if (is_form_url_encoded && src[i] == '+') {
      dst[j] = ' ';
    } else {
      dst[j] = src[i];
    }
  }

  dst[j] = '\0'; // Null-terminate the destination

  return i >= src_len ? j : -1;
}

// 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)
movl %r8d, -0x24(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rcx
xorl %eax, %eax
cmpq -0x10(%rbp), %rcx
movb %al, -0x41(%rbp)
jae 0xb0e08
movq -0x38(%rbp), %rax
movq -0x20(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
setb %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
testb $0x1, %al
jne 0xb0e14
jmp 0xb0f9d
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x25, %eax
jne 0xb0f41
movq -0x30(%rbp), %rax
addq $0x2, %rax
cmpq -0x10(%rbp), %rax
jae 0xb0f41
callq 0xd1f0
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movq -0x30(%rbp), %rdx
movzbl 0x1(%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0xb0f41
callq 0xd1f0
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movq -0x30(%rbp), %rdx
movzbl 0x2(%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0xb0f41
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
movzbl 0x1(%rax,%rcx), %edi
callq 0xdf58
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
movzbl 0x2(%rax,%rcx), %edi
callq 0xdf58
movl %eax, -0x40(%rbp)
callq 0xd1f0
movq (%rax), %rax
movslq -0x3c(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0xb0ede
movl -0x3c(%rbp), %eax
subl $0x30, %eax
movl %eax, -0x48(%rbp)
jmp 0xb0ee7
movl -0x3c(%rbp), %eax
subl $0x57, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
shll $0x4, %eax
movl %eax, -0x4c(%rbp)
callq 0xd1f0
movq (%rax), %rax
movslq -0x40(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0xb0f15
movl -0x40(%rbp), %eax
subl $0x30, %eax
movl %eax, -0x50(%rbp)
jmp 0xb0f1e
movl -0x40(%rbp), %eax
subl $0x57, %eax
movl %eax, -0x50(%rbp)
movl -0x4c(%rbp), %eax
movl -0x50(%rbp), %ecx
orl %ecx, %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x30(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x30(%rbp)
jmp 0xb0f7e
cmpl $0x0, -0x24(%rbp)
je 0xb0f66
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2b, %eax
jne 0xb0f66
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movb $0x20, (%rax,%rcx)
jmp 0xb0f7c
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0xb0f7e
jmp 0xb0f80
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xb0de4
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x30(%rbp), %rax
cmpq -0x10(%rbp), %rax
jb 0xb0fbd
movq -0x38(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0xb0fca
movq $-0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0xb0fca
movq -0x58(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)