// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0xb0(%rbp)
movq %rdi, %rax
movq %rax, -0xa8(%rbp)
movq %rsi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl %ecx, -0x10(%rbp)
xorl %esi, %esi
movl $0x20, %edx
callq 0x10c0
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpl $0x10, -0xc(%rbp)
jae 0x4118
jmp 0x40e2
movq 0x6f0f(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x4388(%rip), %rsi      # 0x847b
leaq 0x43c5(%rip), %rdx      # 0x84bf
leaq 0x450e(%rip), %rcx      # 0x860f
movl $0xdc, %r8d
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1180
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x20(%rbp)
movl $0xffffffef, %eax       # imm = 0xFFFFFFEF
cmpl -0x20(%rbp), %eax
jb 0x4141
movl -0x20(%rbp), %eax
addl $0x10, %eax
cmpl -0xc(%rbp), %eax
jbe 0x4179
jmp 0x4143
movq 0x6eae(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x4327(%rip), %rsi      # 0x847b
leaq 0x4364(%rip), %rdx      # 0x84bf
leaq 0x44ad(%rip), %rcx      # 0x860f
movl $0xdf, %r8d
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1180
movl -0x1c(%rbp), %eax
movl %eax, -0xb4(%rbp)
subl $0x3, %eax
je 0x42a0
jmp 0x418d
movl -0xb4(%rbp), %eax
subl $0x8, %eax
je 0x4337
jmp 0x419e
movl -0xb4(%rbp), %eax
subl $0xb, %eax
je 0x41c1
jmp 0x41ab
movl -0xb4(%rbp), %eax
subl $0x2008, %eax           # imm = 0x2008
je 0x4390
jmp 0x43ad
movl $0xffffffea, %eax       # imm = 0xFFFFFFEA
cmpl -0x20(%rbp), %eax
jb 0x420e
movl -0x20(%rbp), %eax
addl $0x15, %eax
cmpl -0xc(%rbp), %eax
ja 0x420e
jmp 0x41d8
movq 0x6e19(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x4292(%rip), %rsi      # 0x847b
leaq 0x42cf(%rip), %rdx      # 0x84bf
leaq 0x4418(%rip), %rcx      # 0x860f
movl $0xe2, %r8d
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1180
movq -0x8(%rbp), %rax
addq $0x10, %rax
movq %rax, -0xc0(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0xb8(%rbp)
movl $0xffffffeb, %eax       # imm = 0xFFFFFFEB
cmpl -0x20(%rbp), %eax
jb 0x423b
movl -0x20(%rbp), %eax
addl $0x14, %eax
cmpl -0xc(%rbp), %eax
jbe 0x4248
movl $0xffff, %eax           # imm = 0xFFFF
movl %eax, -0xc4(%rbp)
jmp 0x4259
movq -0x8(%rbp), %rax
movl -0x20(%rbp), %ecx
movl 0x10(%rax,%rcx), %eax
movl %eax, -0xc4(%rbp)
movl -0xb8(%rbp), %edx
movq -0xc0(%rbp), %rsi
movl -0xc4(%rbp), %ecx
leaq -0x40(%rbp), %rdi
callq 0x5610
movq -0xb0(%rbp), %rax
movq -0x40(%rbp), %rcx
movq %rcx, (%rax)
movq -0x38(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rcx
movq %rcx, 0x18(%rax)
jmp 0x4431
movl $0xffffffeb, %eax       # imm = 0xFFFFFFEB
cmpl -0x20(%rbp), %eax
jb 0x42b5
movl -0x20(%rbp), %eax
addl $0x14, %eax
cmpl -0xc(%rbp), %eax
jbe 0x42ed
jmp 0x42b7
movq 0x6d3a(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x41b3(%rip), %rsi      # 0x847b
leaq 0x41f0(%rip), %rdx      # 0x84bf
leaq 0x4339(%rip), %rcx      # 0x860f
movl $0xe6, %r8d
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1180
movq -0x8(%rbp), %rsi
addq $0x10, %rsi
movl -0x20(%rbp), %edx
movq -0x8(%rbp), %rax
movl -0x20(%rbp), %ecx
movl 0x10(%rax,%rcx), %ecx
leaq -0x60(%rbp), %rdi
callq 0x56c0
movq -0xb0(%rbp), %rax
movq -0x60(%rbp), %rcx
movq %rcx, (%rax)
movq -0x58(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x50(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x48(%rbp), %rcx
movq %rcx, 0x18(%rax)
jmp 0x4431
movq -0x8(%rbp), %rsi
addq $0x10, %rsi
movl -0x20(%rbp), %edx
movq -0x8(%rbp), %rcx
addq $0x10, %rcx
movl -0x20(%rbp), %eax
addq %rax, %rcx
movl -0xc(%rbp), %r8d
subl -0x20(%rbp), %r8d
subl $0x10, %r8d
leaq -0x80(%rbp), %rdi
callq 0x5720
movq -0xb0(%rbp), %rax
movq -0x80(%rbp), %rcx
movq %rcx, (%rax)
movq -0x78(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x70(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x68(%rbp), %rcx
movq %rcx, 0x18(%rax)
jmp 0x4431
movq 0x6c61(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x427e(%rip), %rsi      # 0x861f
movb $0x0, %al
callq 0x1100
jmp 0x4431
movq 0x6c44(%rip), %rax      # 0xaff8
movq (%rax), %rdi
movl -0x1c(%rbp), %edx
leaq 0x429d(%rip), %rsi      # 0x865e
movb $0x0, %al
callq 0x1100
movq 0x6c29(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x42ab(%rip), %rsi      # 0x8684
movb $0x0, %al
callq 0x1100
movq -0x8(%rbp), %rdi
addq $0x10, %rdi
movl -0x20(%rbp), %esi
callq 0x5790
movl -0x20(%rbp), %eax
addl $0x10, %eax
cmpl -0xc(%rbp), %eax
jae 0x442f
movq 0x6bf6(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x4282(%rip), %rsi      # 0x868e
movb $0x0, %al
callq 0x1100
movq -0x8(%rbp), %rdi
addq $0x10, %rdi
movl -0x20(%rbp), %eax
addq %rax, %rdi
movl -0xc(%rbp), %esi
subl -0x20(%rbp), %esi
subl $0x10, %esi
callq 0x5790
jmp 0x4431
cmpl $0x0, -0x10(%rbp)
je 0x45f2
movq -0x8(%rbp), %rax
movl -0x10(%rbp), %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
movl 0x4(%rax,%rcx), %eax
movl %eax, -0x88(%rbp)
movq -0x8(%rbp), %rax
movl -0x10(%rbp), %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movl -0x88(%rbp), %ecx
movl 0x10(%rax,%rcx), %eax
movl %eax, -0x8c(%rbp)
movl $0x0, -0x84(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x8c(%rbp), %eax
jae 0x45f0
movq -0x8(%rbp), %rax
movl -0x10(%rbp), %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movl -0x88(%rbp), %ecx
addq %rcx, %rax
addq $0x10, %rax
addq $0x4, %rax
movl -0x84(%rbp), %ecx
shll %ecx
movl %ecx, %ecx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movl (%rax), %eax
cmpl -0x10(%rbp), %eax
je 0x44dd
jmp 0x45dc
movq -0x98(%rbp), %rax
movl $0x0, (%rax)
movq -0x8(%rbp), %rax
movl -0x10(%rbp), %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movl -0x88(%rbp), %ecx
addq %rcx, %rax
movl -0x84(%rbp), %ecx
shll %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movl 0x14(%rax,%rcx,4), %eax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x453c
movq -0xb0(%rbp), %rax
movb 0x10(%rax), %cl
andb $-0x2, %cl
orb $0x1, %cl
movb %cl, 0x10(%rax)
movl -0x9c(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x455d
movq -0xb0(%rbp), %rax
movb 0x10(%rax), %cl
andb $-0x3, %cl
orb $0x2, %cl
movb %cl, 0x10(%rax)
movl -0x9c(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x457e
movq -0xb0(%rbp), %rax
movb 0x10(%rax), %cl
andb $-0x5, %cl
orb $0x4, %cl
movb %cl, 0x10(%rax)
movl -0x9c(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x45a1
movq -0xb0(%rbp), %rax
movb 0x10(%rax), %cl
andb $-0x9, %cl
orb $0x8, %cl
movb %cl, 0x10(%rax)
movl -0x9c(%rbp), %eax
andl $0xffffff6c, %eax       # imm = 0xFFFFFF6C
cmpl $0x0, %eax
je 0x45da
movq -0xb0(%rbp), %rax
movq 0x6a39(%rip), %rcx      # 0xaff8
movq (%rcx), %rdi
movl -0x9c(%rbp), %edx
movq 0x8(%rax), %rcx
leaq 0x40cb(%rip), %rsi      # 0x869e
movb $0x0, %al
callq 0x1100
jmp 0x45dc
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x447e
jmp 0x45f2
movq -0xa8(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)