// File: /workspace/github_c_makefile_star2_O0/atomlang[P]atomlang/src/pk_var.c
// Function: isValuesEqual
bool isValuesEqual(Var v1, Var v2) {
  if (isValuesSame(v1, v2)) return true;

  // If we reach here only heap allocated objects could be compared.
  if (!IS_OBJ(v1) || !IS_OBJ(v2)) return false;

  Object* o1 = AS_OBJ(v1), *o2 = AS_OBJ(v2);
  if (o1->type != o2->type) return false;

  switch (o1->type) {
    case OBJ_RANGE:
      return ((Range*)o1)->from == ((Range*)o2)->from &&
             ((Range*)o1)->to   == ((Range*)o2)->to;

    case OBJ_STRING: {
      String* s1 = (String*)o1, *s2 = (String*)o2;
      return s1->hash == s2->hash &&
             s1->length == s2->length &&
             memcmp(s1->data, s2->data, s1->length) == 0;
    }

    case OBJ_LIST: {
      /*
      * l1 = []; list_append(l1, l1) # [[...]]
      * l2 = []; list_append(l2, l2) # [[...]]
      * l1 == l2 ## This will cause a stack overflow but not handling that
      *          ## (in python too).
      */
      List *l1 = (List*)o1, *l2 = (List*)o2;
      if (l1->elements.count != l2->elements.count) return false;
      Var* _v1 = l1->elements.data;
      Var* _v2 = l2->elements.data;
      for (uint32_t i = 0; i < l1->elements.count; i++) {
        if (!isValuesEqual(*_v1, *_v2)) return false;
        _v1++, _v2++;
      }
      return true;
    }

    default:
      return false;
  }
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movq 0x58(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0x76b0
testb $0x1, %al
jne 0x76f3
jmp 0x76fd
movb $0x1, 0x67(%rsp)
jmp 0x7936
movabsq $-0x4000000000000, %rax # imm = 0xFFFC000000000000
andq 0x58(%rsp), %rax
movabsq $-0x4000000000000, %rcx # imm = 0xFFFC000000000000
cmpq %rcx, %rax
jne 0x7739
movabsq $-0x4000000000000, %rax # imm = 0xFFFC000000000000
andq 0x50(%rsp), %rax
movabsq $-0x4000000000000, %rcx # imm = 0xFFFC000000000000
cmpq %rcx, %rax
je 0x7743
movb $0x0, 0x67(%rsp)
jmp 0x7936
movabsq $0xffffffffffff, %rax   # imm = 0xFFFFFFFFFFFF
andq 0x58(%rsp), %rax
movq %rax, 0x48(%rsp)
movabsq $0xffffffffffff, %rax   # imm = 0xFFFFFFFFFFFF
andq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x48(%rsp), %rax
movl (%rax), %eax
movq 0x40(%rsp), %rcx
cmpl (%rcx), %eax
je 0x7785
movb $0x0, 0x67(%rsp)
jmp 0x7936
movq 0x48(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x8(%rsp)
testl %eax, %eax
je 0x7801
jmp 0x7796
movl 0x8(%rsp), %eax
subl $0x1, %eax
je 0x787f
jmp 0x77a5
movl 0x8(%rsp), %eax
subl $0x3, %eax
jne 0x7931
jmp 0x77b4
movq 0x48(%rsp), %rax
movsd 0x10(%rax), %xmm0
movq 0x40(%rsp), %rcx
xorl %eax, %eax
ucomisd 0x10(%rcx), %xmm0
movb %al, 0x7(%rsp)
jne 0x77f2
jp 0x77f2
movq 0x48(%rsp), %rax
movsd 0x18(%rax), %xmm0
movq 0x40(%rsp), %rax
ucomisd 0x18(%rax), %xmm0
sete %al
setnp %cl
andb %cl, %al
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
andb $0x1, %al
movb %al, 0x67(%rsp)
jmp 0x7936
movq 0x48(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x38(%rsp), %rax
movl 0x10(%rax), %ecx
movq 0x30(%rsp), %rdx
xorl %eax, %eax
cmpl 0x10(%rdx), %ecx
movb %al, 0x6(%rsp)
jne 0x7870
movq 0x38(%rsp), %rax
movl 0x14(%rax), %ecx
movq 0x30(%rsp), %rdx
xorl %eax, %eax
cmpl 0x14(%rdx), %ecx
movb %al, 0x6(%rsp)
jne 0x7870
movq 0x38(%rsp), %rdi
addq $0x1c, %rdi
movq 0x30(%rsp), %rsi
addq $0x1c, %rsi
movq 0x38(%rsp), %rax
movl 0x14(%rax), %eax
movl %eax, %edx
callq 0x2200
cmpl $0x0, %eax
sete %al
movb %al, 0x6(%rsp)
movb 0x6(%rsp), %al
andb $0x1, %al
movb %al, 0x67(%rsp)
jmp 0x7936
movq 0x48(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x28(%rsp), %rax
movl 0x18(%rax), %eax
movq 0x20(%rsp), %rcx
cmpl 0x18(%rcx), %eax
je 0x78af
movb $0x0, 0x67(%rsp)
jmp 0x7936
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
movq 0x28(%rsp), %rcx
cmpl 0x18(%rcx), %eax
jae 0x792a
movq 0x18(%rsp), %rax
movq (%rax), %rdi
movq 0x10(%rsp), %rax
movq (%rax), %rsi
callq 0x76d0
testb $0x1, %al
jne 0x7901
movb $0x0, 0x67(%rsp)
jmp 0x7936
movq 0x18(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x18(%rsp)
movq 0x10(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x10(%rsp)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x78d3
movb $0x1, 0x67(%rsp)
jmp 0x7936
movb $0x0, 0x67(%rsp)
movb 0x67(%rsp), %al
andb $0x1, %al
addq $0x68, %rsp
retq
nopw %cs:(%rax,%rax)