// File: /workspace/github_c_makefile_star2_O1/janet-lang[P]janet/src/core/value.c
// Function: janet_in
Janet janet_in(Janet ds, Janet key) {
    Janet value;
    JanetType type = janet_type(ds);
    switch (type) {
        default:
            janet_panicf("expected %T, got %v", JANET_TFLAG_LENGTHABLE, ds);
            break;
        case JANET_STRUCT:
            value = janet_struct_get(janet_unwrap_struct(ds), key);
            break;
        case JANET_TABLE:
            value = janet_table_get(janet_unwrap_table(ds), key);
            break;
        case JANET_ARRAY: {
            JanetArray *array = janet_unwrap_array(ds);
            int32_t index = getter_checkint(type, key, array->count);
            value = array->data[index];
            break;
        }
        case JANET_TUPLE: {
            const Janet *tuple = janet_unwrap_tuple(ds);
            int32_t len = janet_tuple_length(tuple);
            value = tuple[getter_checkint(type, key, len)];
            break;
        }
        case JANET_BUFFER: {
            JanetBuffer *buffer = janet_unwrap_buffer(ds);
            int32_t index = getter_checkint(type, key, buffer->count);
            value = janet_wrap_integer(buffer->data[index]);
            break;
        }
        case JANET_STRING:
        case JANET_SYMBOL:
        case JANET_KEYWORD: {
            const uint8_t *str = janet_unwrap_string(ds);
            int32_t index = getter_checkint(type, key, janet_string_length(str));
            value = janet_wrap_integer(str[index]);
            break;
        }
        case JANET_ABSTRACT: {
            JanetAbstractType *type = (JanetAbstractType *)janet_abstract_type(janet_unwrap_abstract(ds));
            if (type->get) {
                if (!(type->get)(janet_unwrap_abstract(ds), key, &value))
                    janet_panicf("key %v not found in %v ", key, ds);
            } else {
                janet_panicf("no getter for %v ", ds);
            }
            break;
        }
        case JANET_FIBER: {
            /* Bit of a hack to allow iterating over fibers. */
            if (janet_equals(key, janet_wrap_integer(0))) {
                return janet_unwrap_fiber(ds)->last_value;
            } else {
                janet_panicf("expected key 0, got %v", key);
            }
        }
    }
    return value;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %r14
movq %rdi, %xmm0
movq %rdi, %rax
shrq $0x2f, %rax
andl $0xf, %eax
xorl %r15d, %r15d
ucomisd %xmm0, %xmm0
cmovpl %eax, %r15d
leal -0x3(%r15), %eax
cmpl $0xb, %eax
ja 0x4b7a1
movq %rsi, %rbx
leaq 0x21165(%rip), %rcx     # 0x6c7a4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r14, %rdi
callq 0x4f838
movq %rax, %r14
movl -0x8(%rax), %edx
movl %r15d, %edi
movq %rbx, %rsi
callq 0x4b7d4
movl %eax, %eax
movzbl (%r14,%rax), %eax
jmp 0x4b739
movq %r14, %rdi
callq 0x4f838
movq %rax, %rdi
movq %rbx, %rsi
callq 0x47388
jmp 0x4b745
movq %r14, %rdi
callq 0x4f838
movq %rax, %r14
movl 0x10(%rax), %edx
movl $0x7, %edi
movq %rbx, %rsi
callq 0x4b7d4
movq 0x18(%r14), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rax
jmp 0x4b745
xorpd %xmm0, %xmm0
callq 0x4fab8
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4acce
testl %eax, %eax
je 0x4b7b7
movq %r14, %rdi
callq 0x4f838
movq %rax, %r15
addq $0x40, %r15
jmp 0x4b74c
movq %r14, %rdi
callq 0x4f838
movq %rax, %rdi
movq %rbx, %rsi
callq 0x47f51
jmp 0x4b745
movq %r14, %rdi
callq 0x4f838
movq %rax, %r14
movl -0x10(%rax), %edx
movl $0x8, %edi
movq %rbx, %rsi
callq 0x4b7d4
movl %eax, %eax
movq (%r14,%rax,8), %rax
jmp 0x4b745
movq %r14, %rdi
callq 0x4f838
movq %rax, %r14
movl 0x10(%rax), %edx
movl $0xb, %edi
movq %rbx, %rsi
callq 0x4b7d4
movq 0x18(%r14), %rcx
movl %eax, %eax
movzbl (%rcx,%rax), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
callq 0x4fab8
leaq -0x28(%rbp), %r15
movq %rax, (%r15)
movq (%r15), %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
callq 0x4f838
movq -0x10(%rax), %rax
movq 0x18(%rax), %r12
testq %r12, %r12
je 0x4b7c3
movq %r14, %rdi
callq 0x4f838
leaq -0x28(%rbp), %r15
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq *%r12
testl %eax, %eax
jne 0x4b74c
leaq 0x21183(%rip), %rdi     # 0x6c917
movq %rbx, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1917b
leaq 0x993f(%rip), %rdi      # 0x550e7
movl $0xff0, %esi            # imm = 0xFF0
movq %r14, %rdx
xorl %eax, %eax
callq 0x1917b
leaq 0x21183(%rip), %rdi     # 0x6c941
movq %rbx, %rsi
jmp 0x4b7cd
leaq 0x21165(%rip), %rdi     # 0x6c92f
movq %r14, %rsi
xorl %eax, %eax
callq 0x1917b