// File: /workspace/github_c_makefile_star2_O1/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, %rbx
movq %rdi, %r14
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq %rax, %r15
movq 0x108(%rax), %r12
movabsq $-0x3000000000000, %rsi # imm = 0xFFFD000000000000
testq %r12, %r12
je 0x4b1c8
cmpq 0x118(%r15), %r12
jbe 0x4b1c8
movq (%r12), %rdx
movq 0x8(%r12), %rcx
cmpb $0x4, (%rdx)
jne 0x4b07d
movslq 0x10(%r12), %r8
movl 0x10(%rdx), %edi
cmpl %edi, %r8d
jge 0x4b0bf
cmpl 0x10(%rcx), %r8d
jge 0x4b0bf
leal 0x1(%r8), %eax
movl %eax, 0x10(%r12)
movq 0x20(%rdx,%r8,8), %rax
movq %rax, (%r14)
movq 0x20(%rcx,%r8,8), %rax
jmp 0x4b0ac
cmpl $0x0, 0x14(%r12)
je 0x4b0e6
movl $0x0, 0x14(%r12)
movslq 0x10(%r12), %rax
leal 0x1(%rax), %edi
movl %edi, 0x10(%r12)
shlq $0x4, %rax
movq 0x30(%rdx,%rax), %rdx
movq %rdx, (%r14)
movq 0x30(%rcx,%rax), %rax
movq %rax, (%rbx)
movq %r12, 0x108(%r15)
xorl %ecx, %ecx
xorl %eax, %eax
jmp 0x4b171
cmpl $0x0, 0x14(%r12)
je 0x4b167
cmpl 0x10(%rcx), %edi
je 0x4b167
setg %al
movzbl %al, %eax
leal 0x1(,%rax,2), %eax
jmp 0x4b16f
movslq 0x10(%r12), %r8
movl 0x18(%rdx), %edi
cmpl %edi, %r8d
jge 0x4b125
movl $0x1, 0x14(%r12)
movq %r8, %rax
shlq $0x4, %rax
movq 0x28(%rdx,%rax), %rax
movq %rax, (%r14)
movslq 0x10(%r12), %rax
shlq $0x4, %rax
movq 0x28(%rcx,%rax), %rax
movq %rax, (%rbx)
movq %r12, 0x108(%r15)
xorl %eax, %eax
cmpl %edi, %r8d
jl 0x4b16f
movq 0x20(%rdx), %rdi
movq 0x20(%rcx), %r13
testq %rdi, %rdi
sete %cl
testq %r13, %r13
setne %dl
orb %cl, %dl
cmpb $0x1, %dl
jne 0x4b15c
testq %r13, %r13
setne %cl
testq %rdi, %rdi
sete %dl
testb %cl, %dl
je 0x4b17b
movl $0x1, %eax
jmp 0x4b161
movl $0x3, %eax
xorl %ecx, %ecx
testb %cl, %cl
je 0x4b16f
addq $-0x18, %r12
movb $0x1, %cl
jmp 0x4b171
xorl %ecx, %ecx
testb %cl, %cl
jne 0x4b02e
jmp 0x4b1d4
testq %r13, %r13
sete %dl
testq %rdi, %rdi
sete %r8b
movb $0x1, %cl
orb %dl, %r8b
jne 0x4b163
callq 0x4f9ad
movq %rax, (%r14)
movq %r13, %rdi
movabsq $-0x3000000000000, %rsi # imm = 0xFFFD000000000000
callq 0x4f9ad
movabsq $-0x3000000000000, %rsi # imm = 0xFFFD000000000000
movq %rax, (%rbx)
leaq -0x18(%r12), %rax
movq %rax, 0x108(%r15)
xorl %ecx, %ecx
xorl %eax, %eax
jmp 0x4b163
movq %r12, 0x108(%r15)
movl $0x2, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq