// File: /workspace/github_c_makefile_star2_O2/janet-lang[P]janet/src/core/value.c
// Function: traversal_next
static int traversal_next(Janet *x, Janet *y) {
    JanetTraversalNode *t = janet_vm.traversal;
    while (t && t > janet_vm.traversal_base) {
        JanetGCObject *self = t->self;
        JanetTupleHead *tself = (JanetTupleHead *)self;
        JanetStructHead *sself = (JanetStructHead *)self;
        JanetGCObject *other = t->other;
        JanetTupleHead *tother = (JanetTupleHead *)other;
        JanetStructHead *sother = (JanetStructHead *)other;
        if ((self->flags & JANET_MEM_TYPEBITS) == JANET_MEMORY_TUPLE) {
            /* Node is a tuple at index t->index */
            if (t->index < tself->length && t->index < tother->length) {
                int32_t index = t->index++;
                *x = tself->data[index];
                *y = tother->data[index];
                janet_vm.traversal = t;
                return 0;
            }
            if (t->index2 && tself->length != tother->length) {
                return tself->length > tother->length ? 3 : 1;
            }
        } else {
            /* Node is a struct at index t->index: if t->index2 is true, we should return the values. */
            if (t->index2) {
                t->index2 = 0;
                int32_t index = t->index++;
                *x = sself->data[index].value;
                *y = sother->data[index].value;
                janet_vm.traversal = t;
                return 0;
            }
            for (int32_t i = t->index; i < sself->capacity; i++) {
                t->index2 = 1;
                *x = sself->data[t->index].key;
                *y = sother->data[t->index].key;
                janet_vm.traversal = t;
                return 0;
            }
            /* Traverse prototype */
            JanetStruct sproto = sself->proto;
            JanetStruct oproto = sother->proto;
            if (sproto && !oproto) return 3;
            if (!sproto && oproto) return 1;
            if (oproto && sproto) {
                *x = janet_wrap_struct(sproto);
                *y = janet_wrap_struct(oproto);
                janet_vm.traversal = t - 1;
                return 0;
            }
        }
        t--;
    }
    janet_vm.traversal = t;
    return 2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %r15
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq %rax, %rbx
movq 0x108(%rax), %r13
movq 0x118(%rax), %rcx
pushq $0x3
popq %rax
pushq $0x1
popq %rdx
testq %r13, %r13
je 0x46adf
cmpq %rcx, %r13
jbe 0x46adf
movq (%r13), %rdi
movq 0x8(%r13), %rsi
cmpb $0x4, (%rdi)
jne 0x46a78
movslq 0x10(%r13), %r8
movl 0x10(%rdi), %r9d
cmpl %r9d, %r8d
jge 0x46a66
cmpl 0x10(%rsi), %r8d
jl 0x46b74
cmpl $0x0, 0x14(%r13)
je 0x46ad6
cmpl 0x10(%rsi), %r9d
je 0x46ad6
jmp 0x46b65
cmpl $0x0, 0x14(%r13)
jne 0x46aee
movslq 0x10(%r13), %r8
cmpl 0x18(%rdi), %r8d
jl 0x46b11
movq 0x20(%rdi), %rdi
movq 0x20(%rsi), %r12
testq %rdi, %rdi
sete %sil
testq %r12, %r12
setne %r8b
orb %sil, %r8b
cmpb $0x1, %r8b
jne 0x46b95
testq %r12, %r12
setne %sil
testq %rdi, %rdi
sete %r8b
testb %sil, %r8b
jne 0x46b34
testq %r12, %r12
sete %sil
testq %rdi, %rdi
sete %r8b
orb %sil, %r8b
je 0x46b38
addq $-0x18, %r13
jmp 0x46a30
movq %r13, 0x108(%rbx)
pushq $0x2
popq %rax
jmp 0x46b95
andl $0x0, 0x14(%r13)
movslq 0x10(%r13), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0x10(%r13)
shlq $0x4, %rax
movq 0x30(%rdi,%rax), %rcx
movq %rcx, (%r15)
movq 0x30(%rsi,%rax), %rax
jmp 0x46b89
movl $0x1, 0x14(%r13)
shlq $0x4, %r8
movq 0x28(%rdi,%r8), %rax
movq %rax, (%r15)
movslq 0x10(%r13), %rax
shlq $0x4, %rax
movq 0x28(%rsi,%rax), %rax
jmp 0x46b89
movl %edx, %eax
jmp 0x46b95
movabsq $-0x3000000000000, %rsi # imm = 0xFFFD000000000000
callq 0x4b366
movq %rax, (%r15)
movq %r12, %rdi
movabsq $-0x3000000000000, %rsi # imm = 0xFFFD000000000000
callq 0x4b366
movq %rax, (%r14)
addq $-0x18, %r13
jmp 0x46b8c
setg %al
movzbl %al, %eax
leal 0x1(,%rax,2), %eax
jmp 0x46b95
leal 0x1(%r8), %eax
movl %eax, 0x10(%r13)
movq 0x20(%rdi,%r8,8), %rax
movq %rax, (%r15)
movq 0x20(%rsi,%r8,8), %rax
movq %rax, (%r14)
movq %r13, 0x108(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq