// File: /workspace/github_c_makefile_star2_O3/pali[P]bmfdec/./bmfparse.c
// Function: parse_qualifier
static struct mof_qualifier parse_qualifier(char *buf, uint32_t size, uint32_t offset) {
  struct mof_qualifier out;
  memset(&out, 0, sizeof(out));
  uint32_t *buf2 = (uint32_t *)buf;
  if (size < 16) error("Invalid size");
  uint32_t type = buf2[1];
  uint32_t len = buf2[3];
  if (!check_sum(16, len, size)) error("Invalid size");
  switch (type) {
  case 0x0B:
    if (check_sum(16+4+1, len, size)) error("Invalid size");
    out = parse_qualifier_boolean(buf+16, len, !check_sum(16+4, len, size) ? 0xFFFF : *((uint32_t *)(buf+16+len)));
    break;
  case 0x03:
    if (!check_sum(16+4, len, size)) error("Invalid size");
    out = parse_qualifier_sint32(buf+16, len, *((int32_t *)(buf+16+len)));
    break;
  case 0x08:
    out = parse_qualifier_string(buf+16, len, buf+16+len, size-len-16);
    break;
  case 0x2008:
    fprintf(stderr, "Warning: ValueMap and Values qualifiers are not supported yet\n");
    break;
  default:
    fprintf(stderr, "Warning: Unknown qualifier type 0x%x\n", type);
    fprintf(stderr, "Hexdump:\n");
    dump_bytes(buf+16, len);
    if (len+16 < size) {
      fprintf(stderr, "...continue...\n");
      dump_bytes(buf+16+len, size-len-16);
    }
    break;
  }
  if (offset) {
    uint32_t i;
    uint32_t olen = ((uint32_t *)(buf-offset))[1];
    uint32_t count = ((uint32_t *)(buf-offset+olen+16))[0];
    for (i=0; i<count; ++i) {
      uint32_t *offset_addr = (uint32_t *)(buf-offset+olen+16+4) + 2*i;
      if (*offset_addr != offset)
        continue;
      *offset_addr = 0;
      uint32_t flavors = ((uint32_t *)(buf-offset+olen+16+4))[2*i+1];
      if (flavors & (1U << 0))
        out.toinstance = 1;
      if (flavors & (1U << 1))
        out.tosubclass = 1;
      if (flavors & (1U << 4))
        out.disableoverride = 1;
      if (flavors & (1U << 7))
        out.amended = 1;
      if (flavors & ~((1U << 0) | (1U << 1) | (1U << 4) | (1U << 7)))
        fprintf(stderr, "Warning: Unknown qualifier flavors 0x%x in second part for %s\n", flavors, out.name);
    }
  }
  return out;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rdi)
movq %rdi, 0x8(%rsp)
movups %xmm0, (%rdi)
cmpl $0xf, %edx
jbe 0x5afe
movq %rsi, %r14
movl 0xc(%rsi), %r13d
movl %r13d, %eax
shrl $0x4, %eax
cmpl $0xffffffe, %eax        # imm = 0xFFFFFFE
ja 0x5af9
movl %edx, %ebp
leal 0x10(%r13), %r12d
cmpl %edx, %r12d
ja 0x5af9
movl %ecx, %ebx
movl 0x4(%r14), %edx
cmpl $0xa, %edx
jg 0x58d4
cmpl $0x3, %edx
je 0x5922
cmpl $0x8, %edx
jne 0x5a9d
leaq 0x10(%r14), %rdi
leaq (%r14,%r13), %r12
addq $0x10, %r12
subl %r13d, %ebp
addl $-0x10, %ebp
movl %r13d, %esi
callq 0x5d8b
movq %rax, %r13
movq %r12, %rdi
movl %ebp, %esi
callq 0x5d8b
movq %r13, %r8
movq 0x8(%rsp), %rcx
movq $0x3, (%rcx)
movq %r13, 0x8(%rcx)
movq $0x0, 0x10(%rcx)
movq %rax, 0x18(%rcx)
jmp 0x59c3
cmpl $0xb, %edx
jne 0x5a8e
cmpl $-0x15, %r13d
setae %al
leal 0x15(%r13), %ecx
cmpl %ebp, %ecx
seta %cl
orb %al, %cl
je 0x5b03
leaq 0x10(%r14), %rdi
cmpl $-0x14, %r13d
setae %al
movl %r13d, %ecx
addl $0x14, %ecx
cmpl %ebp, %ecx
seta %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x5970
xorl %eax, %eax
movl %eax, 0x3(%rsp)
movl %eax, (%rsp)
movl $0xffff, %ebp           # imm = 0xFFFF
jmp 0x598d
cmpl $-0x15, %r13d
ja 0x5b08
leal 0x14(%r13), %eax
cmpl %ebp, %eax
ja 0x5b08
leaq 0x10(%r14), %rdi
movl 0x10(%r14,%r13), %ebp
movl %r13d, %esi
callq 0x5d8b
movq %rax, %r8
movq 0x8(%rsp), %rax
movq $0x2, (%rax)
movq %r8, 0x8(%rax)
movq $0x0, 0x10(%rax)
movl %ebp, 0x18(%rax)
movl $0x0, 0x1c(%rax)
jmp 0x59c3
movl (%rdi,%r13), %ebp
xorl %eax, %eax
movl %eax, 0x3(%rsp)
movl %eax, (%rsp)
testl %ebp, %ebp
je 0x598d
cmpl $0xffff, %ebp           # imm = 0xFFFF
jne 0x5b0d
movl %r13d, %esi
callq 0x5d8b
movq %rax, %r8
testl %ebp, %ebp
movq 0x8(%rsp), %rdx
movq $0x1, (%rdx)
movq %rax, 0x8(%rdx)
movq $0x0, 0x10(%rdx)
setne 0x18(%rdx)
movl (%rsp), %eax
movl 0x3(%rsp), %ecx
movl %eax, 0x19(%rdx)
movl %ecx, 0x1c(%rdx)
testl %ebx, %ebx
je 0x5a7f
movl %ebx, %eax
subq %rax, %r14
movl 0x4(%r14), %eax
movl 0x10(%r14,%rax), %r12d
testq %r12, %r12
je 0x5a7f
addq %rax, %r14
addq $0x14, %r14
addq %r12, %r12
xorl %ebp, %ebp
movq 0x5603(%rip), %rcx      # 0xaff8
leaq 0x1b1f(%rip), %r15      # 0x751b
xorl %r13d, %r13d
movl %r13d, %eax
cmpl %ebx, (%r14,%rax,4)
jne 0x5a51
movl $0x0, (%r14,%rax,4)
leal 0x1(%r13), %eax
movl (%r14,%rax,4), %edx
testb $0x1, %dl
je 0x5a21
orb $0x1, %bpl
testb $0x2, %dl
je 0x5a2a
orb $0x2, %bpl
testb $0x10, %dl
je 0x5a33
orb $0x4, %bpl
testb %dl, %dl
jns 0x5a3b
orb $0x8, %bpl
testb $-0x6d, %dl
je 0x5a49
movq 0x8(%rsp), %rax
movb %bpl, 0x10(%rax)
testl $0xffffff6c, %edx       # imm = 0xFFFFFF6C
jne 0x5a5c
addq $0x2, %r13
cmpq %r13, %r12
jne 0x59ff
jmp 0x5a7f
movq (%rcx), %rdi
movq %r15, %rsi
movq %r8, %rcx
xorl %eax, %eax
movq %r8, 0x10(%rsp)
callq 0x1100
movq 0x5580(%rip), %rcx      # 0xaff8
movq 0x10(%rsp), %r8
jmp 0x5a51
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x2008, %edx           # imm = 0x2008
jne 0x5a9d
callq 0x259a
jmp 0x5ae2
movq 0x5554(%rip), %r15      # 0xaff8
movq (%r15), %rdi
leaq 0x1a2d(%rip), %rsi      # 0x74db
xorl %eax, %eax
callq 0x1100
movq (%r15), %rcx
leaq 0x1a42(%rip), %rdi      # 0x7501
movl $0x9, %esi
movl $0x1, %edx
callq 0x1180
leaq 0x10(%r14), %r15
movq %r15, %rdi
movl %r13d, %esi
callq 0x5cb3
cmpl %ebp, %r12d
jb 0x5aea
xorl %r8d, %r8d
jmp 0x59c3
movl %r13d, %edi
movq %r15, %rsi
movl %ebp, %edx
callq 0x2655
jmp 0x5ae2
callq 0x2691
callq 0x26c6
callq 0x25eb
callq 0x25b6
callq 0x2620