// File: /workspace/github_c_makefile_star2_O0/atomlang[P]atomlang/src/pk_var.c
// Function: popMarkedObjectsInternal
static void popMarkedObjectsInternal(Object* obj, PKVM* vm) {
  // TODO: trace here.

  switch (obj->type) {
    case OBJ_STRING: {
      vm->bytes_allocated += sizeof(String);
      vm->bytes_allocated += ((size_t)((String*)obj)->length + 1);
    } break;

    case OBJ_LIST: {
      List* list = (List*)obj;
      markVarBuffer(vm, &list->elements);
      vm->bytes_allocated += sizeof(List);
      vm->bytes_allocated += sizeof(Var) * list->elements.capacity;
    } break;

    case OBJ_MAP: {
      Map* map = (Map*)obj;
      for (uint32_t i = 0; i < map->capacity; i++) {
        if (IS_UNDEF(map->entries[i].key)) continue;
        markValue(vm, map->entries[i].key);
        markValue(vm, map->entries[i].value);
      }
      vm->bytes_allocated += sizeof(Map);
      vm->bytes_allocated += sizeof(MapEntry) * map->capacity;
    } break;

    case OBJ_RANGE: {
      vm->bytes_allocated += sizeof(Range);
    } break;

    case OBJ_SCRIPT:
    {
      Script* scr = (Script*)obj;
      vm->bytes_allocated += sizeof(Script);

      markObject(vm, &scr->path->_super);
      markObject(vm, &scr->module->_super);

      markVarBuffer(vm, &scr->globals);
      vm->bytes_allocated += sizeof(Var) * scr->globals.capacity;

      // Integer buffer has no gray call.
      vm->bytes_allocated += sizeof(uint32_t) * scr->global_names.capacity;

      markVarBuffer(vm, &scr->literals);
      vm->bytes_allocated += sizeof(Var) * scr->literals.capacity;

      markFunctionBuffer(vm, &scr->functions);
      vm->bytes_allocated += sizeof(Function*) * scr->functions.capacity;

      markClassBuffer(vm, &scr->classes);
      vm->bytes_allocated += sizeof(Class*) * scr->classes.count;

      markStringBuffer(vm, &scr->names);
      vm->bytes_allocated += sizeof(String*) * scr->names.capacity;

      markObject(vm, &scr->body->_super);
    } break;

    case OBJ_FUNC:
    {
      Function* func = (Function*)obj;
      vm->bytes_allocated += sizeof(Function);

      markObject(vm, &func->owner->_super);

      if (!func->is_native) {
        Fn* fn = func->fn;
        vm->bytes_allocated += sizeof(Fn);

        vm->bytes_allocated += sizeof(uint8_t)* fn->opcodes.capacity;
        vm->bytes_allocated += sizeof(uint32_t) * fn->oplines.capacity;
      }
    } break;

    case OBJ_FIBER:
    {
      Fiber* fiber = (Fiber*)obj;
      vm->bytes_allocated += sizeof(Fiber);

      markObject(vm, &fiber->func->_super);

      // Blacken the stack.
      for (Var* local = fiber->stack; local < fiber->sp; local++) {
        markValue(vm, *local);
      }
      vm->bytes_allocated += sizeof(Var) * fiber->stack_size;

      // Blacken call frames.
      for (int i = 0; i < fiber->frame_count; i++) {
        markObject(vm, (Object*)&fiber->frames[i].fn->_super);
        markObject(vm, &fiber->frames[i].fn->owner->_super);
      }
      vm->bytes_allocated += sizeof(CallFrame) * fiber->frame_capacity;

      markObject(vm, &fiber->caller->_super);
      markObject(vm, &fiber->error->_super);

    } break;

    case OBJ_CLASS:
    {
      Class* type = (Class*)obj;
      vm->bytes_allocated += sizeof(Class);
      markObject(vm, &type->owner->_super);
      markObject(vm, &type->ctor->_super);
      vm->bytes_allocated += sizeof(uint32_t) * type->field_names.capacity;
    } break;

    case OBJ_INST:
    {
      Instance* inst = (Instance*)obj;
      if (!inst->is_native) {
        Inst* ins = inst->ins;
        vm->bytes_allocated += sizeof(Inst);
        vm->bytes_allocated += sizeof(Var*) * ins->fields.capacity;
      }
    } break;
  }
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
movq 0x70(%rsp), %rax
movl (%rax), %eax
movq %rax, (%rsp)
subq $0x8, %rax
ja 0x45a1
movq (%rsp), %rax
leaq 0x25fca(%rip), %rcx     # 0x2a028
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x8(%rax)
movq 0x70(%rsp), %rax
movl 0x14(%rax), %eax
movl %eax, %ecx
addq $0x1, %rcx
movq 0x68(%rsp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
jmp 0x45a1
movq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x68(%rsp), %rdi
movq 0x60(%rsp), %rsi
addq $0x10, %rsi
callq 0x3e60
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x8(%rax)
movq 0x60(%rsp), %rax
movl 0x1c(%rax), %eax
movl %eax, %ecx
shlq $0x3, %rcx
movq 0x68(%rsp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
jmp 0x45a1
movq 0x70(%rsp), %rax
movq %rax, 0x58(%rsp)
movl $0x0, 0x54(%rsp)
movl 0x54(%rsp), %eax
movq 0x58(%rsp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x417e
movq 0x58(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x54(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movabsq $0x7ffd000000000000, %rcx # imm = 0x7FFD000000000000
cmpq %rcx, (%rax)
jne 0x412b
jmp 0x416e
movq 0x68(%rsp), %rdi
movq 0x58(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x54(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0x3e10
movq 0x68(%rsp), %rdi
movq 0x58(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x54(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
callq 0x3e10
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x40f8
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x8(%rax)
movq 0x58(%rsp), %rax
movl 0x10(%rax), %eax
movl %eax, %ecx
shlq $0x4, %rcx
movq 0x68(%rsp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
jmp 0x45a1
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x8(%rax)
jmp 0x45a1
movq 0x70(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rcx
addq $0x90, %rcx
movq %rcx, 0x8(%rax)
movq 0x68(%rsp), %rdi
movq 0x48(%rsp), %rax
movq 0x18(%rax), %rsi
callq 0x3d50
movq 0x68(%rsp), %rdi
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rsi
callq 0x3d50
movq 0x68(%rsp), %rdi
movq 0x48(%rsp), %rsi
addq $0x20, %rsi
callq 0x3e60
movq 0x48(%rsp), %rax
movl 0x2c(%rax), %eax
movl %eax, %ecx
shlq $0x3, %rcx
movq 0x68(%rsp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x48(%rsp), %rax
movl 0x3c(%rax), %eax
movl %eax, %ecx
shlq $0x2, %rcx
movq 0x68(%rsp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x68(%rsp), %rdi
movq 0x48(%rsp), %rsi
addq $0x70, %rsi
callq 0x3e60
movq 0x48(%rsp), %rax
movl 0x7c(%rax), %eax
movl %eax, %ecx
shlq $0x3, %rcx
movq 0x68(%rsp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x68(%rsp), %rdi
movq 0x48(%rsp), %rsi
addq $0x40, %rsi
callq 0x3f20
movq 0x48(%rsp), %rax
movl 0x4c(%rax), %eax
movl %eax, %ecx
shlq $0x3, %rcx
movq 0x68(%rsp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x68(%rsp), %rdi
movq 0x48(%rsp), %rsi
addq $0x50, %rsi
callq 0x3f80
movq 0x48(%rsp), %rax
movl 0x58(%rax), %eax
movl %eax, %ecx
shlq $0x3, %rcx
movq 0x68(%rsp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x68(%rsp), %rdi
movq 0x48(%rsp), %rsi
addq $0x60, %rsi
callq 0x3ec0
movq 0x48(%rsp), %rax
movl 0x6c(%rax), %eax
movl %eax, %ecx
shlq $0x3, %rcx
movq 0x68(%rsp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x68(%rsp), %rdi
movq 0x48(%rsp), %rax
movq 0x80(%rax), %rsi
callq 0x3d50
jmp 0x45a1
movq 0x70(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rcx
addq $0x40, %rcx
movq %rcx, 0x8(%rax)
movq 0x68(%rsp), %rdi
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rsi
callq 0x3d50
movq 0x40(%rsp), %rax
testb $0x1, 0x30(%rax)
jne 0x43b3
movq 0x40(%rsp), %rax
movq 0x38(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rcx
addq $0x28, %rcx
movq %rcx, 0x8(%rax)
movq 0x38(%rsp), %rax
movl 0xc(%rax), %eax
movl %eax, %ecx
shlq $0x0, %rcx
movq 0x68(%rsp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x38(%rsp), %rax
movl 0x1c(%rax), %eax
movl %eax, %ecx
shlq $0x2, %rcx
movq 0x68(%rsp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
jmp 0x45a1
movq 0x70(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rcx
addq $0x60, %rcx
movq %rcx, 0x8(%rax)
movq 0x68(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rsi
callq 0x3d50
movq 0x30(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
cmpq 0x30(%rcx), %rax
jae 0x4426
movq 0x68(%rsp), %rdi
movq 0x28(%rsp), %rax
movq (%rax), %rsi
callq 0x3e10
movq 0x28(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x28(%rsp)
jmp 0x43f4
movq 0x30(%rsp), %rax
movslq 0x28(%rax), %rcx
shlq $0x3, %rcx
movq 0x68(%rsp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
movq 0x30(%rsp), %rcx
cmpl 0x4c(%rcx), %eax
jge 0x44ad
movq 0x68(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x40(%rax), %rax
movslq 0x24(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
callq 0x3d50
movq 0x68(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x40(%rax), %rax
movslq 0x24(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rsi
callq 0x3d50
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x4448
movq 0x30(%rsp), %rax
movslq 0x48(%rax), %rax
imulq $0x18, %rax, %rcx
movq 0x68(%rsp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x68(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x50(%rax), %rsi
callq 0x3d50
movq 0x68(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x58(%rax), %rsi
callq 0x3d50
jmp 0x45a1
movq 0x70(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rcx
addq $0x38, %rcx
movq %rcx, 0x8(%rax)
movq 0x68(%rsp), %rdi
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rsi
callq 0x3d50
movq 0x68(%rsp), %rdi
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rsi
callq 0x3d50
movq 0x18(%rsp), %rax
movl 0x34(%rax), %eax
movl %eax, %ecx
shlq $0x2, %rcx
movq 0x68(%rsp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
jmp 0x45a1
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
testb $0x1, 0x18(%rax)
jne 0x459f
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rcx
addq $0x18, %rcx
movq %rcx, 0x8(%rax)
movq 0x8(%rsp), %rax
movl 0x14(%rax), %eax
movl %eax, %ecx
shlq $0x3, %rcx
movq 0x68(%rsp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
jmp 0x45a1
addq $0x78, %rsp
retq
nopw %cs:(%rax,%rax)