// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_parse_dns_resource_record
static unsigned char *mg_parse_dns_resource_record(
    unsigned char *data, unsigned char *end, struct mg_dns_resource_record *rr,
    int reply) {
  unsigned char *name = data;
  int chunk_len, data_len;

  while (data < end && (chunk_len = *data)) {
    if (((unsigned char *) data)[0] & 0xc0) {
      data += 1;
      break;
    }
    data += chunk_len + 1;
  }

  if (data > end - 5) {
    return NULL;
  }

  rr->name.p = (char *) name;
  rr->name.len = data - name + 1;
  data++;

  rr->rtype = data[0] << 8 | data[1];
  data += 2;

  rr->rclass = data[0] << 8 | data[1];
  data += 2;

  rr->kind = reply ? MG_DNS_ANSWER : MG_DNS_QUESTION;
  if (reply) {
    if (data >= end - 6) {
      return NULL;
    }

    rr->ttl = (uint32_t) data[0] << 24 | (uint32_t) data[1] << 16 |
              data[2] << 8 | data[3];
    data += 4;

    data_len = *data << 8 | *(data + 1);
    data += 2;

    rr->rdata.p = (char *) data;
    rr->rdata.len = data_len;
    data += data_len;
  }
  return data;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rcx
xorl %eax, %eax
cmpq -0x18(%rbp), %rcx
movb %al, -0x39(%rbp)
jae 0x1899d
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, %eax
setne %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
testb $0x1, %al
jne 0x189a6
jmp 0x189db
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x0, %eax
je 0x189c5
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x189db
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
jmp 0x1897b
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
addq $-0x5, %rcx
cmpq %rcx, %rax
jbe 0x189f9
movq $0x0, -0x8(%rbp)
jmp 0x18b4c
movq -0x30(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rcx
movq -0x30(%rbp), %rax
subq %rax, %rcx
addq $0x1, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %ecx
shll $0x8, %ecx
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %eax
orl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %ecx
shll $0x8, %ecx
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %eax
orl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x10(%rbp)
movl -0x24(%rbp), %edx
movl $0x1, %ecx
movl $0x2, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x1c(%rax)
cmpl $0x0, -0x24(%rbp)
je 0x18b44
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
addq $-0x6, %rcx
cmpq %rcx, %rax
jb 0x18ab7
movq $0x0, -0x8(%rbp)
jmp 0x18b4c
movq -0x10(%rbp), %rax
movzbl (%rax), %ecx
shll $0x18, %ecx
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %eax
shll $0x10, %eax
orl %eax, %ecx
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %eax
shll $0x8, %eax
orl %eax, %ecx
movq -0x10(%rbp), %rax
movzbl 0x3(%rax), %eax
orl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
shll $0x8, %eax
movq -0x10(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
orl %ecx, %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x20(%rax)
movslq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x28(%rax)
movl -0x38(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
popq %rbp
retq
nopw %cs:(%rax,%rax)