// File: /workspace/github_c_makefile_star2_O3/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), %rax
testq %r13, %r13
setne %cl
cmpq %rax, %r13
seta %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x4a5a9
movq (%r13), %rdx
movq 0x8(%r13), %rcx
cmpb $0x4, (%rdx)
jne 0x4a545
movslq 0x10(%r13), %rsi
movl 0x10(%rdx), %edi
cmpl %edi, %esi
jge 0x4a534
cmpl 0x10(%rcx), %esi
jl 0x4a650
cmpl $0x0, 0x14(%r13)
je 0x4a59c
cmpl 0x10(%rcx), %edi
je 0x4a59c
jmp 0x4a641
cmpl $0x0, 0x14(%r13)
jne 0x4a5ba
movslq 0x10(%r13), %rsi
cmpl 0x18(%rdx), %esi
jl 0x4a5e3
movq 0x20(%rdx), %rdi
movq 0x20(%rcx), %r12
testq %rdi, %rdi
sete %cl
testq %r12, %r12
setne %dl
orb %cl, %dl
cmpb $0x1, %dl
jne 0x4a606
testq %r12, %r12
setne %cl
testq %rdi, %rdi
sete %dl
testb %cl, %dl
jne 0x4a60d
testq %r12, %r12
sete %cl
testq %rdi, %rdi
sete %dl
orb %cl, %dl
je 0x4a614
addq $-0x18, %r13
cmpq %rax, %r13
ja 0x4a513
movq %r13, 0x108(%rbx)
movl $0x2, %eax
jmp 0x4a670
movl $0x0, 0x14(%r13)
movslq 0x10(%r13), %rax
leal 0x1(%rax), %esi
movl %esi, 0x10(%r13)
shlq $0x4, %rax
movq 0x30(%rdx,%rax), %rdx
movq %rdx, (%r15)
movq 0x30(%rcx,%rax), %rax
jmp 0x4a664
movl $0x1, 0x14(%r13)
shlq $0x4, %rsi
movq 0x28(%rdx,%rsi), %rax
movq %rax, (%r15)
movslq 0x10(%r13), %rax
shlq $0x4, %rax
movq 0x28(%rcx,%rax), %rax
jmp 0x4a664
movl $0x3, %eax
jmp 0x4a670
movl $0x1, %eax
jmp 0x4a670
movabsq $-0x3000000000000, %rsi # imm = 0xFFFD000000000000
callq 0x4ed39
movq %rax, (%r15)
movq %r12, %rdi
movabsq $-0x3000000000000, %rsi # imm = 0xFFFD000000000000
callq 0x4ed39
movq %rax, (%r14)
addq $-0x18, %r13
jmp 0x4a667
setg %al
movzbl %al, %eax
leal 0x1(,%rax,2), %eax
jmp 0x4a670
leal 0x1(%rsi), %eax
movl %eax, 0x10(%r13)
movq 0x20(%rdx,%rsi,8), %rax
movq %rax, (%r15)
movq 0x20(%rcx,%rsi,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