// File: /workspace/github_c_makefile_star2_O1/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 0x1099a
movq 0x1063c(%rip), %rax     # 0x20fc8
cmpb $0x0, (%rax)
je 0x10996
incl 0x8(%rcx)
jmp 0x1099a
lock
incl 0x8(%rcx)
movq %rcx, 0x8(%rsp)
movq (%r14), %rdi
callq 0x9904
movl %eax, %ebp
testl %eax, %eax
je 0x10e10
addq $0x28, %r12
movq (%r14), %rsi
leaq 0x78(%rsp), %rdi
callq 0x99ac
movq (%r14), %rdi
callq 0x999c
movl %eax, %r15d
movq (%r14), %rdi
callq 0x9904
movl %eax, %ebx
cmpb $0x3, %r15b
je 0x10b44
movzbl %r15b, %eax
cmpl $0x4, %eax
je 0x10aa8
cmpl $0x5, %eax
jne 0x10be0
movl $0x70, %edi
callq 0x5220
movq %rax, %r15
movq %rax, %r13
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r15)
leaq 0x10254(%rip), %rax     # 0x20c70
movq %rax, (%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r15)
movups %xmm0, 0x20(%r15)
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x30(%r15)
movups %xmm0, 0x50(%r15)
movups %xmm0, 0x60(%r15)
leaq 0x20(%r15), %rax
movq %rax, 0x10(%r15)
movl $0x0, %ecx
movq %rcx, 0x18(%r15)
movb %cl, 0x20(%r15)
movups %xmm0, 0x38(%r15)
leaq 0x60(%r15), %rax
movq %rax, 0x50(%r15)
movq %rcx, 0x58(%r15)
movb %cl, 0x60(%r15)
movl $0x5, 0x34(%r15)
movl %ebx, 0x30(%r15)
movq (%r14), %rax
movq %rax, 0x68(%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x70(%rsp)
testq %rax, %rax
je 0x10ce2
movq 0x10531(%rip), %rcx     # 0x20fc8
cmpb $0x0, (%rcx)
je 0x10cde
incl 0x8(%rax)
jmp 0x10ce2
movl $0x50, %edi
callq 0x5220
movq %rax, %r15
movq %rax, %r13
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r15)
leaq 0x101f3(%rip), %rax     # 0x20cc0
movq %rax, (%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r15)
movups %xmm0, 0x20(%r15)
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x30(%r15)
leaq 0x20(%r15), %rax
movq %rax, 0x10(%r15)
movl $0x0, %eax
movq %rax, 0x18(%r15)
movb $0x0, 0x20(%r15)
movups %xmm0, 0x38(%r15)
movq %rax, 0x48(%r15)
movl $0x4, 0x34(%r15)
movl %ebx, 0x30(%r15)
movq (%r14), %rax
movq %rax, 0x28(%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x30(%rsp)
testq %rax, %rax
je 0x10c39
movq 0x10495(%rip), %rcx     # 0x20fc8
cmpb $0x0, (%rcx)
je 0x10c35
incl 0x8(%rax)
jmp 0x10c39
movl $0x50, %edi
callq 0x5220
movq %rax, %r15
movq %rax, %r13
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r15)
leaq 0x10157(%rip), %rax     # 0x20cc0
movq %rax, (%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r15)
movups %xmm0, 0x20(%r15)
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x30(%r15)
leaq 0x20(%r15), %rax
movq %rax, 0x10(%r15)
movl $0x0, %eax
movq %rax, 0x18(%r15)
movb $0x0, 0x20(%r15)
movups %xmm0, 0x38(%r15)
movq %rax, 0x48(%r15)
movl $0x3, 0x34(%r15)
movl %ebx, 0x30(%r15)
movq (%r14), %rax
movq %rax, 0x48(%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x50(%rsp)
testq %rax, %rax
je 0x10c8f
movq 0x103f9(%rip), %rcx     # 0x20fc8
cmpb $0x0, (%rcx)
je 0x10c8b
incl 0x8(%rax)
jmp 0x10c8f
movl $0x12, %edx
movq 0x10404(%rip), %rdi     # 0x20ff0
leaq 0x6fc4(%rip), %rsi      # 0x17bb7
callq 0x5260
movq 0x103f1(%rip), %rcx     # 0x20ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x5210
movsbl %al, %esi
movq 0x103d3(%rip), %rdi     # 0x20ff0
callq 0x5040
movq %rax, %rdi
callq 0x5190
xorl %r15d, %r15d
xorl %r13d, %r13d
jmp 0x10d39
lock
incl 0x8(%rax)
addq $0x10, %r15
movq %r15, 0x18(%rsp)
movq %r13, 0x20(%rsp)
movq 0x1037a(%rip), %rax     # 0x20fc8
cmpb $0x0, (%rax)
je 0x10c59
incl 0x8(%r13)
jmp 0x10c5e
lock
incl 0x8(%r13)
movq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rsi
leaq 0x18(%rsp), %rdx
callq 0x10960
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x10c81
callq 0x6752
movq 0x30(%rsp), %rdi
jmp 0x10d2f
lock
incl 0x8(%rax)
addq $0x10, %r15
movq %r15, 0x38(%rsp)
movq %r13, 0x40(%rsp)
movq 0x10324(%rip), %rax     # 0x20fc8
cmpb $0x0, (%rax)
je 0x10caf
incl 0x8(%r13)
jmp 0x10cb4
lock
incl 0x8(%r13)
movq 0x10(%rsp), %rdi
leaq 0x48(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x10960
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x10cd7
callq 0x6752
movq 0x50(%rsp), %rdi
jmp 0x10d2f
lock
incl 0x8(%rax)
addq $0x10, %r15
movq %r15, 0x58(%rsp)
movq %r13, 0x60(%rsp)
movq 0x102d1(%rip), %rax     # 0x20fc8
cmpb $0x0, (%rax)
je 0x10d02
incl 0x8(%r13)
jmp 0x10d07
lock
incl 0x8(%r13)
movq 0x10(%rsp), %rdi
leaq 0x68(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x10848
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x10d2a
callq 0x6752
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x10d39
callq 0x6752
leaq 0xa8(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x78(%rsp), %rsi
movq 0x80(%rsp), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rdi
callq 0x68c2
movq %r15, 0xb8(%rsp)
movq %r13, 0xc0(%rsp)
testq %r13, %r13
je 0x10d92
movq 0x10246(%rip), %rax     # 0x20fc8
cmpb $0x0, (%rax)
je 0x10d8d
incl 0x8(%r13)
jmp 0x10d92
lock
incl 0x8(%r13)
movq %r12, %rdi
leaq 0x98(%rsp), %rsi
callq 0x130ce
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x10db4
callq 0x6752
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x10dd9
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x5230
testq %r13, %r13
je 0x10de6
movq %r13, %rdi
callq 0x6752
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x10e08
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5230
decl %ebp
jne 0x109b5
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x10e1f
callq 0x6752
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x10e8e
movq %rax, %rbx
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x10e45
callq 0x6752
movq 0x70(%rsp), %rdi
jmp 0x10e80
jmp 0x10e9a
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x10e60
callq 0x6752
movq 0x50(%rsp), %rdi
jmp 0x10e80
jmp 0x10e9a
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x10e7b
callq 0x6752
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x10eb7
callq 0x6752
jmp 0x10eb7
jmp 0x10e9a
movq %rax, %rbx
jmp 0x10ee6
jmp 0x10e95
movq %rax, %rbx
jmp 0x10ec4
movq %rax, %rbx
xorl %r13d, %r13d
jmp 0x10eb7
movq %rax, %rbx
jmp 0x10eb7
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x120ee
testq %r13, %r13
je 0x10ec4
movq %r13, %rdi
callq 0x6752
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x10ee6
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5230
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x10ef5
callq 0x6752
movq %rbx, %rdi
callq 0x53e0
nop