// File: /workspace/github_c_makefile_star2_O3/mrkite[P]regs/src/api.cc
// Function: API::setStruct(std::shared_ptr<TheHandle>, std::shared_ptr<symbol::Symbol>)
void API::setStruct(Handle h, std::shared_ptr<symbol::Symbol> s) {
  auto str = std::static_pointer_cast<symbol::Struct>(s);
  auto numFields = h->r32();
  for (uint32_t i = 0; i < numFields; i++) {
    auto key = h->rs();
    auto kind = h->r8();
    auto size = h->r32();
    std::shared_ptr<symbol::Symbol> sym = nullptr;
    switch (kind) {
      case symbol::isRef:
        sym = std::make_shared<symbol::Ref>();
        sym->kind = symbol::isRef;
        sym->size = size;
        setRef(h, sym);
        break;
      case symbol::isStruct:
        sym = std::make_shared<symbol::Struct>();
        sym->kind = symbol::isStruct;
        sym->size = size;
        setStruct(h, sym);
        break;
      case symbol::isUnion:
        sym = std::make_shared<symbol::Struct>();
        sym->kind = symbol::isUnion;
        sym->size = size;
        setStruct(h, sym);
        break;
      default:
        std::cerr << "Unknown field type" << std::endl;
        break;
    }
    str->fields.push_back({key, sym});
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rsi, %r14
movq %rdi, 0x10(%rsp)
movq (%rdx), %r12
movq 0x8(%rdx), %rcx
testq %rcx, %rcx
je 0x106d4
movq 0x10902(%rip), %rax     # 0x20fc8
cmpb $0x0, (%rax)
je 0x106d0
incl 0x8(%rcx)
jmp 0x106d4
lock
incl 0x8(%rcx)
movq %rcx, 0x8(%rsp)
movq (%r14), %rdi
callq 0x96e8
movl %eax, %ebp
testl %eax, %eax
je 0x10b2e
addq $0x28, %r12
movq (%r14), %rsi
leaq 0x78(%rsp), %rdi
callq 0x9790
movq (%r14), %rdi
callq 0x9780
movl %eax, %r13d
movq (%r14), %rdi
callq 0x96e8
movl %eax, %r15d
cmpb $0x3, %r13b
je 0x10876
movzbl %r13b, %eax
cmpl $0x4, %eax
je 0x107e1
cmpl $0x5, %eax
jne 0x1090b
movl $0x70, %edi
callq 0x5220
movq %rax, %r13
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r13)
leaq 0x1051c(%rip), %rax     # 0x20c70
movq %rax, (%r13)
leaq 0x10(%r13), %rbx
leaq 0x20(%r13), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%r13)
movups %xmm0, 0x30(%r13)
movups %xmm0, 0x50(%r13)
movups %xmm0, 0x20(%r13)
movups %xmm0, 0x60(%r13)
movq %rax, 0x10(%r13)
movq $0x0, 0x18(%r13)
movups %xmm0, 0x38(%r13)
movq %r13, %rax
addq $0x60, %rax
movq %rax, 0x50(%r13)
movl $0x5, 0x34(%r13)
movl %r15d, 0x30(%r13)
movq (%r14), %rax
movq %rax, 0x68(%rsp)
movq 0x8(%r14), %rcx
movq %rcx, 0x70(%rsp)
movq 0x1080c(%rip), %rax     # 0x20fc8
movb (%rax), %al
testq %rcx, %rcx
je 0x109ae
testb %al, %al
je 0x109a1
incl 0x8(%rcx)
movq %rbx, 0x38(%rsp)
movq %r13, 0x40(%rsp)
jmp 0x109bc
movl $0x50, %edi
callq 0x5220
movq %rax, %r13
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r13)
leaq 0x104bd(%rip), %rax     # 0x20cc0
movq %rax, (%r13)
leaq 0x10(%r13), %rbx
movq %r13, %rax
addq $0x20, %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r13)
movq %rax, 0x10(%r13)
xorl %eax, %eax
movq %rax, 0x18(%r13)
movups %xmm0, 0x38(%r13)
movq %rax, 0x48(%r13)
movl $0x4, 0x34(%r13)
movl %r15d, 0x30(%r13)
movq (%r14), %rax
movq %rax, 0x48(%rsp)
movq 0x8(%r14), %rcx
movq %rcx, 0x50(%rsp)
movq 0x10777(%rip), %rax     # 0x20fc8
movb (%rax), %al
testq %rcx, %rcx
je 0x1096c
testb %al, %al
je 0x1095f
incl 0x8(%rcx)
movq %rbx, 0x18(%rsp)
movq %r13, 0x20(%rsp)
jmp 0x1097a
movl $0x50, %edi
callq 0x5220
movq %rax, %r13
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r13)
leaq 0x10428(%rip), %rax     # 0x20cc0
movq %rax, (%r13)
leaq 0x10(%r13), %rbx
movq %r13, %rax
addq $0x20, %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r13)
movq %rax, 0x10(%r13)
xorl %eax, %eax
movq %rax, 0x18(%r13)
movups %xmm0, 0x38(%r13)
movq %rax, 0x48(%r13)
movl $0x3, 0x34(%r13)
movl %r15d, 0x30(%r13)
movq (%r14), %rax
movq %rax, 0x58(%rsp)
movq 0x8(%r14), %rcx
movq %rcx, 0x60(%rsp)
movq 0x106e2(%rip), %rax     # 0x20fc8
movb (%rax), %al
testq %rcx, %rcx
je 0x1098d
testb %al, %al
je 0x10980
incl 0x8(%rcx)
movq %rbx, 0x28(%rsp)
movq %r13, 0x30(%rsp)
jmp 0x1099b
movl $0x12, %edx
movq 0x106d9(%rip), %rdi     # 0x20ff0
leaq 0x7299(%rip), %rsi      # 0x17bb7
callq 0x5260
movq 0x106c6(%rip), %rcx     # 0x20ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x5210
movsbl %al, %esi
movq 0x106a8(%rip), %rdi     # 0x20ff0
callq 0x5040
movq %rax, %rdi
callq 0x5190
xorl %ebx, %ebx
xorl %r13d, %r13d
jmp 0x10a57
lock
incl 0x8(%rcx)
movq 0x1065e(%rip), %rax     # 0x20fc8
movb (%rax), %al
movq %rbx, 0x18(%rsp)
movq %r13, 0x20(%rsp)
testb %al, %al
je 0x109c2
incl 0x8(%r13)
jmp 0x109c7
lock
incl 0x8(%rcx)
movq 0x1063d(%rip), %rax     # 0x20fc8
movb (%rax), %al
movq %rbx, 0x28(%rsp)
movq %r13, 0x30(%rsp)
testb %al, %al
je 0x109f1
incl 0x8(%r13)
jmp 0x109f6
lock
incl 0x8(%rcx)
movq 0x1061c(%rip), %rax     # 0x20fc8
movb (%rax), %al
movq %rbx, 0x38(%rsp)
movq %r13, 0x40(%rsp)
testb %al, %al
je 0x10a20
incl 0x8(%r13)
jmp 0x10a25
lock
incl 0x8(%r13)
movq 0x10(%rsp), %rdi
leaq 0x48(%rsp), %rsi
leaq 0x18(%rsp), %rdx
callq 0x1069a
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x109ea
callq 0x671a
movq 0x50(%rsp), %rdi
jmp 0x10a4d
lock
incl 0x8(%r13)
movq 0x10(%rsp), %rdi
leaq 0x58(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x1069a
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x10a19
callq 0x671a
movq 0x60(%rsp), %rdi
jmp 0x10a4d
lock
incl 0x8(%r13)
movq 0x10(%rsp), %rdi
leaq 0x68(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x1059c
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x10a48
callq 0x671a
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x10a57
callq 0x671a
leaq 0xa8(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x78(%rsp), %rsi
movq 0x80(%rsp), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rdi
callq 0x688a
movq %rbx, 0xb8(%rsp)
movq %r13, 0xc0(%rsp)
testq %r13, %r13
je 0x10ab0
movq 0x10528(%rip), %rax     # 0x20fc8
cmpb $0x0, (%rax)
je 0x10aab
incl 0x8(%r13)
jmp 0x10ab0
lock
incl 0x8(%r13)
movq %r12, %rdi
leaq 0x98(%rsp), %rsi
callq 0x12e62
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x10ad2
callq 0x671a
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x10af7
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x5230
testq %r13, %r13
je 0x10b04
movq %r13, %rdi
callq 0x671a
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x10b26
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5230
decl %ebp
jne 0x106ef
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x10b3d
callq 0x671a
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x10bb1
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x10b63
callq 0x671a
movq 0x70(%rsp), %rdi
jmp 0x10b9e
jmp 0x10bbf
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x10b7e
callq 0x671a
movq 0x60(%rsp), %rdi
jmp 0x10b9e
jmp 0x10bbf
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x10b99
callq 0x671a
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
movq 0x8(%rsp), %r14
je 0x10be8
callq 0x671a
jmp 0x10be8
jmp 0x10bbf
movq %rax, %rbx
movq 0x8(%rsp), %r14
jmp 0x10c12
jmp 0x10bbf
jmp 0x10bbf
movq %rax, %rbx
movq 0x8(%rsp), %r14
jmp 0x10bf0
movq %rax, %rbx
jmp 0x10bde
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x11eb2
testq %r13, %r13
movq 0x8(%rsp), %r14
je 0x10bf0
movq %r13, %rdi
callq 0x671a
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x10c12
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5230
testq %r14, %r14
je 0x10c1f
movq %r14, %rdi
callq 0x671a
movq %rbx, %rdi
callq 0x53e0
nop