// File: /workspace/github_c_makefile_star2_O3/janet-lang[P]janet/src/core/value.c
// Function: janet_compare
int janet_compare(Janet x, Janet y) {
    janet_vm.traversal = janet_vm.traversal_base;
    int status;
    do {
        JanetType tx = janet_type(x);
        JanetType ty = janet_type(y);
        if (tx != ty) return tx < ty ? -1 : 1;
        switch (tx) {
            case JANET_NIL:
                break;
            case JANET_BOOLEAN: {
                int diff = janet_unwrap_boolean(x) - janet_unwrap_boolean(y);
                if (diff) return diff;
                break;
            }
            case JANET_NUMBER: {
                double xx = janet_unwrap_number(x);
                double yy = janet_unwrap_number(y);
                if (xx == yy) {
                    break;
                } else {
                    return (xx < yy) ? -1 : 1;
                }
            }
            case JANET_STRING:
            case JANET_SYMBOL:
            case JANET_KEYWORD: {
                int diff = janet_string_compare(janet_unwrap_string(x), janet_unwrap_string(y));
                if (diff) return diff;
                break;
            }
            case JANET_ABSTRACT: {
                int diff = janet_compare_abstract(janet_unwrap_abstract(x), janet_unwrap_abstract(y));
                if (diff) return diff;
                break;
            }
            default: {
                if (janet_unwrap_pointer(x) == janet_unwrap_pointer(y)) {
                    break;
                } else {
                    return janet_unwrap_pointer(x) > janet_unwrap_pointer(y) ? 1 : -1;
                }
            }
            case JANET_TUPLE: {
                const Janet *lhs = janet_unwrap_tuple(x);
                const Janet *rhs = janet_unwrap_tuple(y);
                if (JANET_TUPLE_FLAG_BRACKETCTOR & (janet_tuple_flag(lhs) ^ janet_tuple_flag(rhs))) {
                    return (janet_tuple_flag(lhs) & JANET_TUPLE_FLAG_BRACKETCTOR) ? 1 : -1;
                }
                push_traversal_node(janet_tuple_head(lhs), janet_tuple_head(rhs), 1);
                break;
            }
            case JANET_STRUCT: {
                const JanetKV *lhs = janet_unwrap_struct(x);
                const JanetKV *rhs = janet_unwrap_struct(y);
                int32_t llen = janet_struct_capacity(lhs);
                int32_t rlen = janet_struct_capacity(rhs);
                int32_t lhash = janet_struct_hash(lhs);
                int32_t rhash = janet_struct_hash(rhs);
                if (llen < rlen) return -1;
                if (llen > rlen) return 1;
                if (lhash < rhash) return -1;
                if (lhash > rhash) return 1;
                push_traversal_node(janet_struct_head(lhs), janet_struct_head(rhs), 0);
                break;
            }
        }
    } while (!(status = traversal_next(&x, &y)));
    return status - 2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq -0x38(%rbp), %rax
movq %rdi, (%rax)
leaq -0x30(%rbp), %rax
movq %rsi, (%rax)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x118(%rax), %rcx
movq %rcx, 0x108(%rax)
xorl %ebx, %ebx
leaq 0x20f6d(%rip), %r14     # 0x6b748
movq -0x38(%rbp), %xmm0
movq %xmm0, %r15
movq %r15, %rax
shrq $0x2f, %rax
andl $0xf, %eax
ucomisd %xmm0, %xmm0
cmovnpl %ebx, %eax
movq -0x30(%rbp), %xmm1
movq %xmm1, %r12
movq %r12, %rcx
shrq $0x2f, %rcx
andl $0xf, %ecx
ucomisd %xmm1, %xmm1
cmovnpl %ebx, %ecx
cmpl %ecx, %eax
jne 0x4a989
cmpl $0xe, %eax
ja 0x4a953
movl %eax, %eax
movslq (%r14,%rax,4), %rax
addq %r14, %rax
jmpq *%rax
movq %r15, %rdi
callq 0x4ebc4
movq %rax, %r15
movq %r12, %rdi
callq 0x4ebc4
movq %r15, %rdi
movq %rax, %rsi
callq 0x447ad
testl %eax, %eax
je 0x4a96b
jmp 0x4a993
andl $0x1, %r15d
andl $0x1, %r12d
cmpq %r12, %r15
je 0x4a96b
jmp 0x4a9b4
movq %r15, %rdi
callq 0x4ebc4
movq %rax, %r15
movq %r12, %rdi
callq 0x4ebc4
movl -0x20(%r15), %ecx
movl -0x20(%rax), %edx
xorl %ecx, %edx
btl $0x10, %edx
jb 0x4a998
addq $-0x20, %r15
addq $-0x20, %rax
movq %r15, %rdi
movq %rax, %rsi
movl $0x1, %edx
jmp 0x4a8f8
movq %r15, %rdi
callq 0x4ebc4
movq %rax, %r13
movq %r12, %rdi
callq 0x4ebc4
leaq -0x28(%r13), %rdi
leaq -0x28(%rax), %rsi
movl -0x10(%rax), %ecx
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpl %ecx, -0x10(%r13)
jl 0x4a9f2
jg 0x4a9d4
movl -0x14(%rax), %eax
cmpl %eax, -0x14(%r13)
jl 0x4a9f2
movl $0x1, %r15d
jg 0x4a9f2
xorl %edx, %edx
callq 0x4a3ce
jmp 0x4a96b
ucomisd %xmm1, %xmm0
jne 0x4a9a1
jnp 0x4a96b
jmp 0x4a9a1
movq %r15, %rdi
callq 0x4ebc4
movq %rax, %r13
movq %r12, %rdi
callq 0x4ebc4
cmpq %rax, %r13
je 0x4a96b
movq -0x10(%r13), %rcx
movq -0x10(%rax), %rdx
cmpq %rdx, %rcx
jne 0x4a9dc
movq 0x40(%rcx), %rcx
testq %rcx, %rcx
je 0x4a9e4
movq %r13, %rdi
movq %rax, %rsi
callq *%rcx
jmp 0x4a84b
movq %r15, %rdi
callq 0x4ebc4
movq %rax, %r13
movq %r12, %rdi
callq 0x4ebc4
cmpq %rax, %r13
jne 0x4a9b9
leaq -0x38(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x4a4c7
testl %eax, %eax
je 0x4a7db
movl %eax, %r15d
addl $-0x2, %r15d
jmp 0x4a9f2
xorl %r15d, %r15d
cmpl %ecx, %eax
sbbl %r15d, %r15d
jmp 0x4a9ee
movl %eax, %r15d
jmp 0x4a9f2
xorl %r15d, %r15d
btl $0x10, %ecx
jmp 0x4a9ea
xorl %eax, %eax
ucomisd %xmm0, %xmm1
setbe %al
leal -0x1(,%rax,2), %r15d
jmp 0x4a9f2
subl %r12d, %r15d
jmp 0x4a9f2
movq %r15, %rdi
callq 0x4ebc4
movq %rax, %rbx
movq %r12, %rdi
callq 0x4ebc4
xorl %r15d, %r15d
cmpq %rbx, %rax
jmp 0x4a9ea
movl $0x1, %r15d
jmp 0x4a9f2
xorl %r15d, %r15d
cmpq %rcx, %rdx
jmp 0x4a9ea
xorl %r15d, %r15d
cmpq %r13, %rax
adcl $-0x1, %r15d
orl $0x1, %r15d
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq