// File: /workspace/github_c_makefile_star2_O2/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 $0xd8, %rsp
movq %rsi, %r15
movq %rdi, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
movq %rdx, %rsi
callq 0xec68
movq (%r15), %rdi
callq 0x88ce
movl %eax, %ebp
leaq 0xb8(%rsp), %r13
leaq 0x88(%rsp), %rbx
subl $0x1, %ebp
jb 0xdda5
movq (%r15), %rsi
movq %r13, %rdi
callq 0x8976
movq (%r15), %rdi
callq 0x8966
movl %eax, %r12d
movq %r15, %r14
movq (%r15), %rdi
callq 0x88ce
movl %eax, %r15d
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
cmpb $0x3, %r12b
je 0xdcb6
movzbl %r12b, %eax
cmpl $0x4, %eax
je 0xdc4b
cmpl $0x5, %eax
jne 0xdd39
movq %rbx, %rdi
callq 0xeaf6
movq %rsp, %rdi
movq %rbx, %rsi
callq 0xf8ce
leaq 0x90(%rsp), %rdi
callq 0x61e4
movq (%rsp), %rax
movl $0x5, 0x24(%rax)
movl %r15d, 0x20(%rax)
leaq 0x78(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x67fc
leaq 0x68(%rsp), %r12
movq %r12, %rdi
movq %rsp, %rsi
callq 0x61a4
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xda64
leaq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %r15
jmp 0xdd2a
movq %rbx, %rdi
callq 0xeb11
movq %rsp, %rdi
movq %rbx, %rsi
callq 0xfae2
leaq 0x90(%rsp), %rdi
callq 0x61e4
movq (%rsp), %rax
movl $0x4, 0x24(%rax)
movl %r15d, 0x20(%rax)
leaq 0x38(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x67fc
leaq 0x28(%rsp), %r12
movq %r12, %rdi
movq %rsp, %rsi
callq 0x61a4
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xdb4a
leaq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %r15
jmp 0xdd2a
movq %rbx, %rdi
callq 0xeb11
movq %rsp, %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0xfae2
leaq 0x90(%rsp), %rdi
callq 0x61e4
movq (%rsp), %rax
movl $0x3, 0x24(%rax)
movl %r15d, 0x20(%rax)
leaq 0x58(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x67fc
leaq 0x48(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x61a4
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xdb4a
leaq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %r15
leaq 0xb8(%rsp), %r13
callq 0x61e4
movq %r15, %rdi
callq 0x61e4
jmp 0xdd54
movq 0x122a8(%rip), %rdi     # 0x1ffe8
leaq 0x6e70(%rip), %rsi      # 0x14bb7
callq 0x5200
movq %rax, %rdi
callq 0x5150
movq 0x18(%rsp), %r15
movq %rbx, %rdi
movq %r13, %rsi
callq 0x52c0
addq $0x28, %r15
leaq 0xa8(%rsp), %rdi
movq %rsp, %rsi
callq 0x61a4
movq %r15, %rdi
movq %rbx, %rsi
callq 0x104fe
movq %rbx, %rdi
callq 0xec84
leaq 0x8(%rsp), %rdi
callq 0x61e4
movq %r13, %rdi
callq 0x5140
movq %r14, %r15
jmp 0xdb8a
leaq 0x20(%rsp), %rdi
callq 0x61e4
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xde30
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x61e4
leaq 0x80(%rsp), %rdi
jmp 0xde04
jmp 0xde0f
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x61e4
leaq 0x60(%rsp), %rdi
jmp 0xde04
jmp 0xde0f
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x61e4
leaq 0x40(%rsp), %rdi
callq 0x61e4
jmp 0xde24
jmp 0xde0f
jmp 0xde0f
movq %rax, %rbx
jmp 0xde24
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0xec84
leaq 0x8(%rsp), %rdi
callq 0x61e4
jmp 0xde3a
movq %rax, %rbx
jmp 0xde47
jmp 0xde37
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x5140
leaq 0x20(%rsp), %rdi
callq 0x61e4
movq %rbx, %rdi
callq 0x53c0
nop