// File: /workspace/github_c_makefile_star2_O2/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), %rbx
movq %rdi, (%rbx)
leaq -0x30(%rbp), %r15
movq %rsi, (%r15)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x118(%rax), %rcx
movq %rcx, 0x108(%rax)
pushq $0x1
popq %r14
movq -0x38(%rbp), %xmm0
movq %xmm0, %r12
movq %r12, %rax
shrq $0x2f, %rax
andl $0xf, %eax
ucomisd %xmm0, %xmm0
movl $0x0, %edx
cmovnpl %edx, %eax
movq -0x30(%rbp), %xmm1
movq %xmm1, %r13
movq %r13, %rcx
shrq $0x2f, %rcx
andl $0xf, %ecx
ucomisd %xmm1, %xmm1
cmovnpl %edx, %ecx
cmpl %ecx, %eax
jne 0x46ea3
cmpl $0xe, %eax
ja 0x46e61
movl %eax, %eax
leaq 0x20a18(%rip), %rcx     # 0x67768
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r12, %rdi
callq 0x4b1f1
movq %rax, %r12
movq %r13, %rdi
callq 0x4b1f1
movq %r12, %rdi
movq %rax, %rsi
callq 0x4116d
jmp 0x46e48
andl $0x1, %r12d
andl $0x1, %r13d
cmpq %r13, %r12
je 0x46e4c
jmp 0x46eeb
movq %r12, %rdi
callq 0x4b1f1
movq %rax, %r12
movq %r13, %rdi
callq 0x4b1f1
movl -0x20(%r12), %ecx
movl -0x20(%rax), %edx
xorl %ecx, %edx
btl $0x10, %edx
jb 0x46ece
addq $-0x20, %r12
addq $-0x20, %rax
movq %r12, %rdi
movq %rax, %rsi
movl %r14d, %edx
jmp 0x46e12
movq %r12, %rdi
callq 0x4b1f1
movq %rax, %r12
movq %r13, %rdi
callq 0x4b1f1
leaq -0x28(%r12), %rdi
leaq -0x28(%rax), %rsi
movl -0x10(%rax), %ecx
cmpl %ecx, -0x10(%r12)
jl 0x46ec4
jg 0x46ec9
movl -0x14(%rax), %eax
cmpl %eax, -0x14(%r12)
jl 0x46ec4
jg 0x46ec9
xorl %edx, %edx
callq 0x468f0
jmp 0x46e4c
ucomisd %xmm1, %xmm0
jne 0x46ed9
jnp 0x46e4c
jmp 0x46ed9
movq %r12, %rdi
callq 0x4b1f1
movq %rax, %r12
movq %r13, %rdi
callq 0x4b1f1
movq %r12, %rdi
movq %rax, %rsi
callq 0x468b6
testl %eax, %eax
jne 0x46eb1
movq %rbx, %rdi
movq %r15, %rsi
callq 0x469f5
testl %eax, %eax
je 0x46cfb
jmp 0x46eae
movq %r12, %rdi
callq 0x4b1f1
movq %r15, %r14
movq %rbx, %r15
movq %rax, %rbx
movq %r13, %rdi
callq 0x4b1f1
cmpq %rax, %rbx
movq %r15, %rbx
movq %r14, %r15
pushq $0x1
popq %r14
je 0x46e4c
movq %r12, %rdi
callq 0x4b1f1
movq %rax, %rbx
movq %r13, %rdi
callq 0x4b1f1
xorl %edx, %edx
cmpq %rbx, %rax
jmp 0x46ed4
xorl %edx, %edx
cmpl %ecx, %eax
sbbl %edx, %edx
orl $0x1, %edx
jmp 0x46eb3
addl $-0x2, %eax
movl %eax, %edx
movl %edx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $-0x1
popq %rdx
jmp 0x46eb3
movl %r14d, %edx
jmp 0x46eb3
xorl %edx, %edx
btl $0x10, %ecx
adcl $-0x1, %edx
jmp 0x46ea9
xorl %eax, %eax
ucomisd %xmm0, %xmm1
setbe %al
leal -0x1(,%rax,2), %edx
jmp 0x46eb3
subl %r13d, %r12d
movl %r12d, %edx
jmp 0x46eb3