// File: /workspace/github_c_makefile_star2_O3/mrkite[P]regs/src/api.cc
// Function: API::setFunction(std::shared_ptr<TheHandle>, std::shared_ptr<symbol::Symbol>)
void API::setFunction(Handle h, std::shared_ptr<symbol::Symbol> s) {
  auto f = std::static_pointer_cast<symbol::Function>(s);
  auto numArgs = h->r32();
  for (uint32_t i = 0; i < numArgs; i++) {
    auto key = h->rs();
    auto ref = std::make_shared<symbol::Ref>();
    setRef(h, ref);
    f->arguments.push_back({key, ref});
  }
  f->returnType = std::make_shared<symbol::Ref>();
  setRef(h, f->returnType);
  auto numSig = h->r32();
  for (uint32_t i = 0; i < numSig; i++) {
    f->signature.push_back(static_cast<int32_t>(h->r32()));
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %r14
movq %rdi, 0x18(%rsp)
movq (%rdx), %r12
movq 0x8(%rdx), %rcx
testq %rcx, %rcx
je 0x10c62
movq 0x10374(%rip), %rax     # 0x20fc8
cmpb $0x0, (%rax)
je 0x10c5e
incl 0x8(%rcx)
jmp 0x10c62
lock
incl 0x8(%rcx)
movq %rcx, 0x10(%rsp)
movq (%r14), %rdi
callq 0x96e8
movl %eax, %ebp
testl %eax, %eax
je 0x10e31
leaq 0x28(%r12), %rax
movq %rax, 0xa0(%rsp)
movq 0x1033b(%rip), %r15     # 0x20fc8
movq (%r14), %rsi
leaq 0x50(%rsp), %rdi
callq 0x9790
movl $0x70, %edi
callq 0x5220
movq %rax, %r13
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r13)
leaq 0xffb4(%rip), %rax      # 0x20c70
movq %rax, (%r13)
leaq 0x10(%r13), %rbx
leaq 0x20(%r13), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%r13)
movups %xmm0, 0x40(%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)
movq (%r14), %rax
movq %rax, 0x40(%rsp)
movq 0x8(%r14), %rcx
movq %rcx, 0x48(%rsp)
movb (%r15), %al
testq %rcx, %rcx
je 0x10d32
testb %al, %al
je 0x10d2b
incl 0x8(%rcx)
movq %rbx, (%rsp)
movq %r13, 0x8(%rsp)
jmp 0x10d3f
lock
incl 0x8(%rcx)
movb (%r15), %al
movq %rbx, (%rsp)
movq %r13, 0x8(%rsp)
testb %al, %al
je 0x10d45
incl 0x8(%r13)
jmp 0x10d4a
lock
incl 0x8(%r13)
movq 0x18(%rsp), %rdi
leaq 0x40(%rsp), %rsi
movq %rsp, %rdx
callq 0x1059c
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x10d6b
callq 0x671a
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x10d7a
callq 0x671a
leaq 0x80(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
addq %rsi, %rdx
leaq 0x70(%rsp), %rdi
callq 0x688a
movq %rbx, 0x90(%rsp)
movq %r13, 0x98(%rsp)
cmpb $0x0, (%r15)
je 0x10dba
incl 0x8(%r13)
jmp 0x10dbf
lock
incl 0x8(%r13)
movq 0xa0(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x130ca
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x10de3
callq 0x671a
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x10e05
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x5230
movq %r13, %rdi
callq 0x671a
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x10e29
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x5230
decl %ebp
jne 0x10c8d
movl $0x70, %edi
callq 0x5220
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x8(%rax)
leaq 0xfe20(%rip), %rcx      # 0x20c70
movq %rcx, (%rax)
leaq 0x10(%rax), %rcx
leaq 0x20(%rax), %rdx
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x40(%rax)
movups %xmm0, 0x50(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x60(%rax)
movq %rdx, 0x10(%rax)
movq $0x0, 0x18(%rax)
movups %xmm0, 0x38(%rax)
movq %rax, %rdx
addq $0x60, %rdx
movq %rdx, 0x50(%rax)
movq %rcx, 0x40(%r12)
movq 0x48(%r12), %rdi
movq %rax, 0x48(%r12)
testq %rdi, %rdi
je 0x10ea6
callq 0x671a
movq (%r14), %rax
movq %rax, 0x30(%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x38(%rsp)
testq %rax, %rax
je 0x10ed1
movq 0x10105(%rip), %rcx     # 0x20fc8
cmpb $0x0, (%rcx)
je 0x10ecd
incl 0x8(%rax)
jmp 0x10ed1
lock
incl 0x8(%rax)
movq 0x40(%r12), %rax
movq %rax, 0x20(%rsp)
movq 0x48(%r12), %rax
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0x10eff
movq 0x100d7(%rip), %rcx     # 0x20fc8
cmpb $0x0, (%rcx)
je 0x10efb
incl 0x8(%rax)
jmp 0x10eff
lock
incl 0x8(%rax)
leaq 0x30(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movq 0x18(%rsp), %rdi
callq 0x1059c
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x10f22
callq 0x671a
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x10f31
callq 0x671a
movq (%r14), %rdi
callq 0x96e8
movl %eax, %ebx
testl %eax, %eax
je 0x10f7d
leaq 0x50(%r12), %r15
leaq 0x70(%rsp), %r13
movq (%r14), %rdi
callq 0x96e8
movl %eax, 0x70(%rsp)
movq 0x58(%r12), %rsi
cmpq 0x60(%r12), %rsi
je 0x10f6e
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x58(%r12)
jmp 0x10f79
movq %r15, %rdi
movq %r13, %rdx
callq 0x13332
decl %ebx
jne 0x10f49
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x10f8c
callq 0x671a
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1102c
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x10fb5
callq 0x671a
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x1102f
callq 0x671a
jmp 0x1102f
jmp 0x1102c
jmp 0x1102c
jmp 0x1102c
movq %rax, %rbx
jmp 0x1100e
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x10fe3
callq 0x671a
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x11006
callq 0x671a
jmp 0x11006
movq %rax, %rbx
jmp 0x11006
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x11ede
movq %r13, %rdi
callq 0x671a
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x1102f
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x5230
jmp 0x1102f
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1103e
callq 0x671a
movq %rbx, %rdi
callq 0x53e0