// File: /workspace/github_c_makefile_star2_O1/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, 0x8(%rsp)
movq (%rdx), %r12
movq 0x8(%rdx), %rcx
testq %rcx, %rcx
je 0x10f38
movq 0x1009e(%rip), %rax     # 0x20fc8
cmpb $0x0, (%rax)
je 0x10f34
incl 0x8(%rcx)
jmp 0x10f38
lock
incl 0x8(%rcx)
movq %rcx, (%rsp)
movq (%r14), %rdi
callq 0x9904
movl %eax, %ebp
testl %eax, %eax
je 0x11114
leaq 0x28(%r12), %rax
movq %rax, 0xa0(%rsp)
xorl %r13d, %r13d
movq (%r14), %rsi
leaq 0x50(%rsp), %rdi
callq 0x99ac
movl $0x70, %edi
callq 0x5220
movq %rax, %r15
movq %rax, %rbx
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r15)
leaq 0xfce0(%rip), %rax      # 0x20c70
movq %rax, (%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r15)
movups %xmm0, 0x20(%r15)
movups %xmm0, 0x30(%r15)
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x50(%r15)
movups %xmm0, 0x60(%r15)
leaq 0x20(%r15), %rax
movq %rax, 0x10(%r15)
movq %r13, 0x18(%r15)
movb %r13b, 0x20(%r15)
movups %xmm0, 0x38(%r15)
leaq 0x60(%r15), %rax
movq %rax, 0x50(%r15)
movq %r13, 0x58(%r15)
movb %r13b, 0x60(%r15)
movq (%r14), %rax
movq %rax, 0x40(%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x48(%rsp)
testq %rax, %rax
je 0x11004
movq 0xffd2(%rip), %rcx      # 0x20fc8
cmpb $0x0, (%rcx)
je 0x11000
incl 0x8(%rax)
jmp 0x11004
lock
incl 0x8(%rax)
addq $0x10, %r15
movq %r15, 0x30(%rsp)
movq %rbx, 0x38(%rsp)
movq 0xffaf(%rip), %rax      # 0x20fc8
cmpb $0x0, (%rax)
je 0x11023
incl 0x8(%rbx)
jmp 0x11027
lock
incl 0x8(%rbx)
movq 0x8(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0x10848
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x1104a
callq 0x6752
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x11059
callq 0x6752
leaq 0x80(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
addq %rsi, %rdx
leaq 0x70(%rsp), %rdi
callq 0x68c2
movq %r15, 0x90(%rsp)
movq %rbx, 0x98(%rsp)
movq 0xff34(%rip), %rax      # 0x20fc8
cmpb $0x0, (%rax)
je 0x1109e
incl 0x8(%rbx)
jmp 0x110a2
lock
incl 0x8(%rbx)
movq 0xa0(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x13336
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x110c6
callq 0x6752
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x110e8
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x5230
movq %rbx, %rdi
callq 0x6752
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x1110c
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x5230
decl %ebp
jne 0x10f5e
movl $0x70, %edi
callq 0x5220
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x8(%rax)
leaq 0xfb3d(%rip), %rcx      # 0x20c70
movq %rcx, (%rax)
leaq 0x10(%rax), %rcx
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x40(%rax)
movups %xmm0, 0x50(%rax)
movups %xmm0, 0x60(%rax)
leaq 0x20(%rax), %rdx
movq %rdx, 0x10(%rax)
xorl %edx, %edx
movq %rdx, 0x18(%rax)
movb %dl, 0x20(%rax)
movups %xmm0, 0x38(%rax)
movq %rax, %rsi
addq $0x60, %rsi
movq %rsi, 0x50(%rax)
movq %rdx, 0x58(%rax)
movb %dl, 0x60(%rax)
movq %rcx, 0x40(%r12)
movq 0x48(%r12), %rdi
movq %rax, 0x48(%r12)
testq %rdi, %rdi
je 0x11195
callq 0x6752
movq (%r14), %rax
movq %rax, 0x20(%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0x111c0
movq 0xfe16(%rip), %rcx      # 0x20fc8
cmpb $0x0, (%rcx)
je 0x111bc
incl 0x8(%rax)
jmp 0x111c0
lock
incl 0x8(%rax)
movq 0x40(%r12), %rax
movq %rax, 0x10(%rsp)
movq 0x48(%r12), %rax
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x111ee
movq 0xfde8(%rip), %rcx      # 0x20fc8
cmpb $0x0, (%rcx)
je 0x111ea
incl 0x8(%rax)
jmp 0x111ee
lock
incl 0x8(%rax)
leaq 0x20(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq 0x8(%rsp), %rdi
callq 0x10848
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x11211
callq 0x6752
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x11220
callq 0x6752
movq (%r14), %rdi
callq 0x9904
movl %eax, %ebx
testl %eax, %eax
je 0x1126c
leaq 0x50(%r12), %r15
leaq 0x70(%rsp), %r13
movq (%r14), %rdi
callq 0x9904
movl %eax, 0x70(%rsp)
movq 0x58(%r12), %rsi
cmpq 0x60(%r12), %rsi
je 0x1125d
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x58(%r12)
jmp 0x11268
movq %r15, %rdi
movq %r13, %rdx
callq 0x1359e
decl %ebx
jne 0x11238
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x1127a
callq 0x6752
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1131a
movq %rax, %r14
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x112a3
callq 0x6752
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x1131d
callq 0x6752
jmp 0x1131d
jmp 0x1131a
jmp 0x1131a
jmp 0x1131a
movq %rax, %r14
jmp 0x112fc
movq %rax, %r14
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x112d1
callq 0x6752
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x112f4
callq 0x6752
jmp 0x112f4
movq %rax, %r14
jmp 0x112f4
movq %rax, %r14
leaq 0x70(%rsp), %rdi
callq 0x1211a
movq %rbx, %rdi
callq 0x6752
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x1131d
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x5230
jmp 0x1131d
movq %rax, %r14
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x1132b
callq 0x6752
movq %r14, %rdi
callq 0x53e0
nop