// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movq %rdx, 0x48(%rsp)
movabsq $-0x4000000000000, %rax # imm = 0xFFFC000000000000
andq 0x48(%rsp), %rax
movabsq $-0x4000000000000, %rcx # imm = 0xFFFC000000000000
cmpq %rcx, %rax
je 0x20db7
jmp 0x20d27
jmp 0x20d29
movq 0x58(%rsp), %rax
movq 0x5f0(%rax), %rax
cmpq $0x0, 0x58(%rax)
je 0x20d76
movq 0x122b5(%rip), %rax     # 0x32ff8
movq (%rax), %rdi
leaq 0x9403(%rip), %rsi      # 0x2a150
leaq 0x9510(%rip), %rdx      # 0x2a264
leaq 0xb306(%rip), %rcx      # 0x2c061
leaq 0xad34(%rip), %r8       # 0x2ba96
movl $0x5a6, %r9d            # imm = 0x5A6
movb $0x0, %al
callq 0x2240
ud2
callq 0x2040
jmp 0x20d78
movq 0x58(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x48(%rsp), %rdi
callq 0x7590
movq 0x10(%rsp), %rdi
movq %rax, %rdx
leaq 0xb2d2(%rip), %rsi      # 0x2c06d
movb $0x0, %al
callq 0x4ed0
movq %rax, %rcx
movq 0x58(%rsp), %rax
movq 0x5f0(%rax), %rax
movq %rcx, 0x58(%rax)
jmp 0x20db7
movq 0x48(%rsp), %rax
movabsq $0xffffffffffff, %rcx   # imm = 0xFFFFFFFFFFFF
andq %rcx, %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movl (%rax), %eax
movq %rax, 0x8(%rsp)
subq $0x8, %rax
ja 0x2101d
movq 0x8(%rsp), %rax
leaq 0xabe0(%rip), %rcx      # 0x2b9d0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movabsq $-0x4000000000000, %rax # imm = 0xFFFC000000000000
andq 0x50(%rsp), %rax
movabsq $-0x4000000000000, %rcx # imm = 0xFFFC000000000000
cmpq %rcx, %rax
je 0x20eb6
movabsq $0xffffffffffff, %rax   # imm = 0xFFFFFFFFFFFF
andq 0x50(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x20eb6
jmp 0x20e35
jmp 0x20e37
movq 0x58(%rsp), %rax
movq 0x5f0(%rax), %rax
cmpq $0x0, 0x58(%rax)
je 0x20e84
movq 0x121a7(%rip), %rax     # 0x32ff8
movq (%rax), %rdi
leaq 0x92f5(%rip), %rsi      # 0x2a150
leaq 0x9402(%rip), %rdx      # 0x2a264
leaq 0xb1f8(%rip), %rcx      # 0x2c061
leaq 0xac26(%rip), %r8       # 0x2ba96
movl $0x5ad, %r9d            # imm = 0x5AD
movb $0x0, %al
callq 0x2240
ud2
callq 0x2040
jmp 0x20e86
movq 0x58(%rsp), %rdi
leaq 0xb1f0(%rip), %rsi      # 0x2c082
movb $0x0, %al
callq 0x4ed0
movq %rax, %rcx
movq 0x58(%rsp), %rax
movq 0x5f0(%rax), %rax
movq %rcx, 0x58(%rax)
movb $0x0, 0x67(%rsp)
jmp 0x21052
movabsq $0xffffffffffff, %rax   # imm = 0xFFFFFFFFFFFF
andq 0x50(%rsp), %rax
movq %rax, 0x38(%rsp)
movabsq $0xffffffffffff, %rax   # imm = 0xFFFFFFFFFFFF
andq 0x48(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x38(%rsp), %rax
movl 0x14(%rax), %eax
movq 0x30(%rsp), %rcx
cmpl 0x14(%rcx), %eax
jbe 0x20efa
movb $0x0, 0x67(%rsp)
jmp 0x21052
jmp 0x20efc
movq 0x120f5(%rip), %rax     # 0x32ff8
movq (%rax), %rdi
leaq 0x9243(%rip), %rsi      # 0x2a150
leaq 0x949b(%rip), %rdx      # 0x2a3af
leaq 0xb146(%rip), %rcx      # 0x2c061
leaq 0xab74(%rip), %r8       # 0x2ba96
movl $0x5b5, %r9d            # imm = 0x5B5
movb $0x0, %al
callq 0x2240
ud2
callq 0x2040
movabsq $0xffffffffffff, %rax   # imm = 0xFFFFFFFFFFFF
andq 0x48(%rsp), %rax
movq %rax, 0x28(%rsp)
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
movq 0x28(%rsp), %rcx
cmpl 0x18(%rcx), %eax
jae 0x20f9a
movq 0x50(%rsp), %rdi
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rax
movl 0x24(%rsp), %ecx
movq (%rax,%rcx,8), %rsi
callq 0x76d0
testb $0x1, %al
jne 0x20f81
jmp 0x20f8b
movb $0x1, 0x67(%rsp)
jmp 0x21052
jmp 0x20f8d
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x20f52
movb $0x0, 0x67(%rsp)
jmp 0x21052
movabsq $0xffffffffffff, %rax   # imm = 0xFFFFFFFFFFFF
andq 0x48(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0x5f40
movabsq $0x7ffd000000000000, %rcx # imm = 0x7FFD000000000000
cmpq %rcx, %rax
sete %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, 0x67(%rsp)
jmp 0x21052
jmp 0x20fe3
movq 0x1200e(%rip), %rax     # 0x32ff8
movq (%rax), %rdi
leaq 0x915c(%rip), %rsi      # 0x2a150
leaq 0x93b4(%rip), %rdx      # 0x2a3af
leaq 0xb05f(%rip), %rcx      # 0x2c061
leaq 0xaa8d(%rip), %r8       # 0x2ba96
movl $0x5cc, %r9d            # imm = 0x5CC
movb $0x0, %al
callq 0x2240
ud2
callq 0x2040
jmp 0x2101f
movq 0x11fd2(%rip), %rax     # 0x32ff8
movq (%rax), %rdi
leaq 0x91aa(%rip), %rsi      # 0x2a1da
leaq 0xb02a(%rip), %rdx      # 0x2c061
leaq 0xaa58(%rip), %rcx      # 0x2ba96
movl $0x5ce, %r8d            # imm = 0x5CE
movb $0x0, %al
callq 0x2240
ud2
callq 0x2040
movb 0x67(%rsp), %al
andb $0x1, %al
addq $0x68, %rsp
retq
nopl (%rax)