// File: /workspace/github_c_makefile_star2_O1/janet-lang[P]janet/src/core/value.c
// Function: janet_next_impl
Janet janet_next_impl(Janet ds, Janet key, int is_interpreter) {
    JanetType t = janet_type(ds);
    switch (t) {
        default:
            janet_panicf("expected iterable type, got %v", ds);
        case JANET_TABLE:
        case JANET_STRUCT: {
            const JanetKV *start;
            int32_t cap;
            if (t == JANET_TABLE) {
                JanetTable *tab = janet_unwrap_table(ds);
                cap = tab->capacity;
                start = tab->data;
            } else {
                JanetStruct st = janet_unwrap_struct(ds);
                cap = janet_struct_capacity(st);
                start = st;
            }
            const JanetKV *end = start + cap;
            const JanetKV *kv = janet_checktype(key, JANET_NIL)
                                ? start
                                : janet_dict_find(start, cap, key) + 1;
            while (kv < end) {
                if (!janet_checktype(kv->key, JANET_NIL)) return kv->key;
                kv++;
            }
            break;
        }
        case JANET_STRING:
        case JANET_KEYWORD:
        case JANET_SYMBOL:
        case JANET_BUFFER:
        case JANET_ARRAY:
        case JANET_TUPLE: {
            int32_t i;
            if (janet_checktype(key, JANET_NIL)) {
                i = 0;
            } else if (janet_checkint(key)) {
                i = janet_unwrap_integer(key) + 1;
            } else {
                break;
            }
            int32_t len;
            if (t == JANET_BUFFER) {
                len = janet_unwrap_buffer(ds)->count;
            } else if (t == JANET_ARRAY) {
                len = janet_unwrap_array(ds)->count;
            } else if (t == JANET_TUPLE) {
                len = janet_tuple_length(janet_unwrap_tuple(ds));
            } else {
                len = janet_string_length(janet_unwrap_string(ds));
            }
            if (i < len && i >= 0) {
                return janet_wrap_integer(i);
            }
            break;
        }
        case JANET_ABSTRACT: {
            JanetAbstract abst = janet_unwrap_abstract(ds);
            const JanetAbstractType *at = janet_abstract_type(abst);
            if (NULL == at->next) break;
            return at->next(abst, key);
        }
        case JANET_FIBER: {
            JanetFiber *child = janet_unwrap_fiber(ds);
            Janet retreg;
            JanetFiberStatus status = janet_fiber_status(child);
            if (status == JANET_STATUS_ALIVE ||
                    status == JANET_STATUS_DEAD ||
                    status == JANET_STATUS_ERROR ||
                    status == JANET_STATUS_USER0 ||
                    status == JANET_STATUS_USER1 ||
                    status == JANET_STATUS_USER2 ||
                    status == JANET_STATUS_USER3 ||
                    status == JANET_STATUS_USER4) {
                return janet_wrap_nil();
            }
            janet_vm.fiber->child = child;
            JanetSignal sig = janet_continue(child, janet_wrap_nil(), &retreg);
            if (sig != JANET_SIGNAL_OK && !(child->flags & (1 << sig))) {
                if (is_interpreter) {
                    janet_signalv(sig, retreg);
                } else {
                    janet_vm.fiber->child = NULL;
                    janet_panicv(retreg);
                }
            }
            janet_vm.fiber->child = NULL;
            if (sig == JANET_SIGNAL_OK ||
                    sig == JANET_SIGNAL_ERROR ||
                    sig == JANET_SIGNAL_USER0 ||
                    sig == JANET_SIGNAL_USER1 ||
                    sig == JANET_SIGNAL_USER2 ||
                    sig == JANET_SIGNAL_USER3 ||
                    sig == JANET_SIGNAL_USER4) {
                /* Fiber cannot be resumed, so discard last value. */
                return janet_wrap_nil();
            } else {
                return janet_wrap_integer(0);
            }
        }
    }
    return janet_wrap_nil();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r12
movq %rdi, %xmm0
movq %rdi, %rax
shrq $0x2f, %rax
andl $0xf, %eax
xorl %r13d, %r13d
ucomisd %xmm0, %xmm0
cmovpl %eax, %r13d
leal -0x3(%r13), %eax
cmpl $0xb, %eax
ja 0x4ac97
movq %rsi, %r14
movabsq $-0x7800000000000, %rbx # imm = 0xFFF8800000000000
leaq 0x21c44(%rip), %rcx     # 0x6c6c0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movabsq $-0x800000000000, %rax  # imm = 0xFFFF800000000000
andq %r14, %rax
xorl %r15d, %r15d
cmpq %rbx, %rax
je 0x4aab3
movq %r14, %rdi
callq 0x4a41f
testl %eax, %eax
je 0x4aafc
movq %r14, %xmm0
cvttsd2si %xmm0, %r15d
incl %r15d
movq %r12, %rdi
callq 0x4f838
addl $-0x7, %r13d
movq $-0x8, %rcx
cmpl $0x4, %r13d
ja 0x4aada
movl %r13d, %ecx
leaq 0x21dfa(%rip), %rdx     # 0x6c8d0
movq (%rdx,%rcx,8), %rcx
cmpl (%rax,%rcx), %r15d
setge %al
testl %r15d, %r15d
sets %cl
orb %al, %cl
jne 0x4aafe
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
callq 0x4fab8
xorl %ecx, %ecx
jmp 0x4aafe
movb $0x1, %cl
testb %cl, %cl
je 0x4abff
jmp 0x4ac0e
movq %r12, %rdi
callq 0x4f838
movq %rax, %rdi
addq $-0x10, %rax
jmp 0x4ab8d
movl %edx, %r15d
movq %r12, %rdi
callq 0x4f838
movq %rax, %r14
movq %rax, %rdi
callq 0x29e47
cmpl $0xf, %eax
ja 0x4ac27
movl $0x81f3, %ecx           # imm = 0x81F3
btl %eax, %ecx
jae 0x4ac27
incq %rbx
movq %rbx, %rdi
callq 0x4f95a
jmp 0x4abff
movq %r12, %rdi
callq 0x4f838
movq -0x10(%rax), %rcx
movq 0x50(%rcx), %r15
testq %r15, %r15
je 0x4abfa
movq %rax, %rdi
movq %r14, %rsi
callq *%r15
jmp 0x4abfa
movq %r12, %rdi
callq 0x4f838
movq 0x20(%rax), %rdi
addq $0x14, %rax
movabsq $-0x800000000000, %r15  # imm = 0xFFFF800000000000
movslq (%rax), %rsi
movq %rsi, %r12
shlq $0x4, %r12
addq %rdi, %r12
movq %r14, %rax
andq %r15, %rax
cmpq %rbx, %rax
je 0x4abbe
movq %r14, %rdx
callq 0x49028
movq %rax, %rdi
addq $0x10, %rdi
cmpq %r12, %rdi
setb %cl
jae 0x4abf4
movq (%rdi), %rax
movq %rax, %rdx
andq %r15, %rdx
cmpq %rbx, %rdx
jne 0x4abf4
addq $0x10, %rdi
cmpq %r12, %rdi
setb %cl
jae 0x4abf4
movq (%rdi), %rax
movq %rax, %rdx
andq %r15, %rdx
addq $0x10, %rdi
cmpq %rbx, %rdx
je 0x4abd8
jmp 0x4abf4
testb %cl, %cl
jne 0x4abff
jmp 0x4ac0e
testq %r15, %r15
je 0x4ac0e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
incq %rbx
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4f95a
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq %rax, %r12
movq 0x20(%rax), %rax
movq %r14, 0x38(%rax)
incq %rbx
movq %rbx, %rdi
callq 0x4f95a
leaq -0x30(%rbp), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x4c28d
testl %eax, %eax
je 0x4ac69
movl 0x10(%r14), %ecx
btl %eax, %ecx
jae 0x4aca8
movq 0x20(%r12), %rcx
movq $0x0, 0x38(%rcx)
cmpl $0x8, %eax
ja 0x4ac89
movl $0x1f3, %ecx            # imm = 0x1F3
btl %eax, %ecx
jb 0x4ab4c
xorpd %xmm0, %xmm0
callq 0x4fab8
jmp 0x4abff
leaq 0x21c5a(%rip), %rdi     # 0x6c8f8
movq %r12, %rsi
xorl %eax, %eax
callq 0x1917b
testl %r15d, %r15d
jne 0x4acc3
movq 0x20(%r12), %rax
movq $0x0, 0x38(%rax)
movq -0x30(%rbp), %rdi
callq 0x1916a
movq -0x30(%rbp), %rsi
movl %eax, %edi
callq 0x19084