// File: /workspace/github_c_makefile_star2_O2/atomlang[P]atomlang/src/pk_core.c
// Function: varContains
bool varContains(PKVM* vm, Var elem, Var container) {
  if (!IS_OBJ(container)) {
    VM_SET_ERROR(vm, stringFormat(vm, "'$' is not iterable.",
                 varTypeName(container)));
  }
  Object* obj = AS_OBJ(container);

  switch (obj->type) {
    case OBJ_STRING: {
      if (!IS_OBJ_TYPE(elem, OBJ_STRING)) {
        VM_SET_ERROR(vm, stringFormat(vm, "Expected a string operand."));
        return false;
      }

      String* sub = (String*)AS_OBJ(elem);
      String* str = (String*)AS_OBJ(container);
      if (sub->length > str->length) return false;

      TODO;

    } break;

    case OBJ_LIST: {
      List* list = (List*)AS_OBJ(container);
      for (uint32_t i = 0; i < list->elements.count; i++) {
        if (isValuesEqual(elem, list->elements.data[i])) return true;
      }
      return false;
    } break;

    case OBJ_MAP: {
      Map* map = (Map*)AS_OBJ(container);
      return !IS_UNDEF(mapGet(map, elem));
    } break;

    case OBJ_RANGE:
    case OBJ_SCRIPT:
    case OBJ_FUNC:
    case OBJ_FIBER:
    case OBJ_CLASS:
    case OBJ_INST:
      TODO;
  }
  UNREACHABLE();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq %rdx, %rax
shrq $0x32, %rax
cmpl $0x3ffe, %eax           # imm = 0x3FFE
ja 0x1287f
movq 0x5f0(%r15), %rax
cmpq $0x0, 0x58(%rax)
jne 0x12987
movq %rbx, %rdi
callq 0x4e61
leaq 0x7696(%rip), %rsi      # 0x19efd
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3a8d
movq 0x5f0(%r15), %rcx
movq %rax, 0x58(%rcx)
movabsq $0xffffffffffff, %rax   # imm = 0xFFFFFFFFFFFF
andq %rax, %rbx
movl (%rbx), %ecx
cmpq $0x8, %rcx
ja 0x129b5
leaq 0x6fc1(%rip), %rdx      # 0x19860
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movabsq $-0x4000000000001, %rcx # imm = 0xFFFBFFFFFFFFFFFF
andq %r14, %rax
cmpq %rcx, %r14
ja 0x128bf
cmpl $0x0, (%rax)
je 0x12915
movl 0x14(%rax), %eax
cmpl 0x14(%rbx), %eax
jbe 0x129e3
xorl %ebp, %ebp
jmp 0x12945
movq %rbx, %rdi
movq %r14, %rsi
callq 0x42f9
movabsq $0x7ffd000000000000, %rcx # imm = 0x7FFD000000000000
cmpq %rcx, %rax
setne %bpl
jmp 0x12945
xorl %r15d, %r15d
movl 0x18(%rbx), %eax
cmpq %rax, %r15
setb %bpl
jae 0x12945
movq 0x10(%rbx), %rax
movq (%rax,%r15,8), %rsi
movq %r14, %rdi
callq 0x4f07
incq %r15
testb %al, %al
je 0x128f0
jmp 0x12945
movq 0x5f0(%r15), %rax
cmpq $0x0, 0x58(%rax)
jne 0x12a14
leaq 0x75e4(%rip), %rsi      # 0x19f12
xorl %ebp, %ebp
movq %r15, %rdi
xorl %eax, %eax
callq 0x3a8d
movq 0x5f0(%r15), %rcx
movq %rax, 0x58(%rcx)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x1069f(%rip), %rax     # 0x22ff8
movq (%rax), %rdi
leaq 0x578d(%rip), %rsi      # 0x180f0
leaq 0x59e5(%rip), %rdx      # 0x1834f
leaq 0x7580(%rip), %rcx      # 0x19ef1
leaq 0x6fae(%rip), %r8       # 0x19926
movl $0x5cc, %r9d            # imm = 0x5CC
xorl %eax, %eax
callq 0x2250
ud2
movq 0x1066a(%rip), %rax     # 0x22ff8
movq (%rax), %rdi
leaq 0x5758(%rip), %rsi      # 0x180f0
leaq 0x5865(%rip), %rdx      # 0x18204
leaq 0x754b(%rip), %rcx      # 0x19ef1
leaq 0x6f79(%rip), %r8       # 0x19926
movl $0x5a6, %r9d            # imm = 0x5A6
jmp 0x1297e
movq 0x1063c(%rip), %rax     # 0x22ff8
movq (%rax), %rdi
leaq 0x57b4(%rip), %rsi      # 0x1817a
leaq 0x7524(%rip), %rdx      # 0x19ef1
leaq 0x6f52(%rip), %rcx      # 0x19926
movl $0x5ce, %r8d            # imm = 0x5CE
xorl %eax, %eax
callq 0x2250
ud2
movq 0x1060e(%rip), %rax     # 0x22ff8
movq (%rax), %rdi
leaq 0x56fc(%rip), %rsi      # 0x180f0
leaq 0x5954(%rip), %rdx      # 0x1834f
leaq 0x74ef(%rip), %rcx      # 0x19ef1
leaq 0x6f1d(%rip), %r8       # 0x19926
movl $0x5b5, %r9d            # imm = 0x5B5
jmp 0x1297e
movq 0x105dd(%rip), %rax     # 0x22ff8
movq (%rax), %rdi
leaq 0x56cb(%rip), %rsi      # 0x180f0
leaq 0x57d8(%rip), %rdx      # 0x18204
leaq 0x74be(%rip), %rcx      # 0x19ef1
leaq 0x6eec(%rip), %r8       # 0x19926
movl $0x5ad, %r9d            # imm = 0x5AD
jmp 0x1297e