// File: /workspace/github_c_makefile_star2_O3/janet-lang[P]janet/src/core/value.c
// Function: janet_get
Janet janet_get(Janet ds, Janet key) {
    JanetType t = janet_type(ds);
    switch (t) {
        default:
            return janet_wrap_nil();
        case JANET_STRING:
        case JANET_SYMBOL:
        case JANET_KEYWORD: {
            if (!janet_checkint(key)) return janet_wrap_nil();
            int32_t index = janet_unwrap_integer(key);
            if (index < 0) return janet_wrap_nil();
            const uint8_t *str = janet_unwrap_string(ds);
            if (index >= janet_string_length(str)) return janet_wrap_nil();
            return janet_wrap_integer(str[index]);
        }
        case JANET_ABSTRACT: {
            Janet value;
            void *abst = janet_unwrap_abstract(ds);
            JanetAbstractType *type = (JanetAbstractType *)janet_abstract_type(abst);
            if (!type->get) return janet_wrap_nil();
            if ((type->get)(abst, key, &value))
                return value;
            return janet_wrap_nil();
        }
        case JANET_ARRAY:
        case JANET_TUPLE:
        case JANET_BUFFER: {
            if (!janet_checkint(key)) return janet_wrap_nil();
            int32_t index = janet_unwrap_integer(key);
            if (index < 0) return janet_wrap_nil();
            if (t == JANET_ARRAY) {
                JanetArray *a = janet_unwrap_array(ds);
                if (index >= a->count) return janet_wrap_nil();
                return a->data[index];
            } else if (t == JANET_BUFFER) {
                JanetBuffer *b = janet_unwrap_buffer(ds);
                if (index >= b->count) return janet_wrap_nil();
                return janet_wrap_integer(b->data[index]);
            } else {
                const Janet *t = janet_unwrap_tuple(ds);
                if (index >= janet_tuple_length(t)) return janet_wrap_nil();
                return t[index];
            }
        }
        case JANET_TABLE: {
            return janet_table_get(janet_unwrap_table(ds), key);
        }
        case JANET_STRUCT: {
            const JanetKV *st = janet_unwrap_struct(ds);
            return janet_struct_get(st, key);
        }
        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 {
                return janet_wrap_nil();
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
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 0x4ade5
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x20b3c(%rip), %rcx     # 0x6b7b4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
callq 0x49912
testl %eax, %eax
je 0x4ade5
movq %rbx, %xmm0
cvttsd2si %xmm0, %ebx
testl %ebx, %ebx
js 0x4ade5
movq %r14, %rdi
callq 0x4ebc4
cmpl %ebx, -0x8(%rax)
jg 0x4adb3
jmp 0x4ade5
movq %rbx, %rdi
callq 0x49912
testl %eax, %eax
je 0x4ade5
movq %rbx, %xmm0
cvttsd2si %xmm0, %ebx
testl %ebx, %ebx
js 0x4ade5
movq %r14, %rdi
callq 0x4ebc4
cmpl $0xb, %r15d
je 0x4adaa
cmpl $0x7, %r15d
jne 0x4adcf
cmpl %ebx, 0x10(%rax)
jle 0x4ade5
movq 0x18(%rax), %rax
jmp 0x4add4
movq %r14, %rdi
callq 0x4ebc4
movq %rax, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x474e0
xorpd %xmm0, %xmm0
callq 0x4ee44
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4a1bd
testl %eax, %eax
je 0x4ade5
movq %r14, %rdi
callq 0x4ebc4
movq 0x40(%rax), %rax
jmp 0x4adda
movq %r14, %rdi
callq 0x4ebc4
movq -0x10(%rax), %rcx
movq 0x18(%rcx), %rcx
testq %rcx, %rcx
je 0x4ad99
leaq -0x20(%rbp), %rdx
movq %rax, %rdi
movq %rbx, %rsi
callq *%rcx
testl %eax, %eax
je 0x4ad99
movq -0x20(%rbp), %rax
jmp 0x4adda
movq %r14, %rdi
callq 0x4ebc4
movq %rax, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x46988
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x4ece6
jmp 0x4adda
cmpl %ebx, 0x10(%rax)
jle 0x4ade5
movq 0x18(%rax), %rax
movl %ebx, %ecx
movzbl (%rax,%rcx), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x4ee44
cmpl %ebx, -0x10(%rax)
jle 0x4ade5
movl %ebx, %ecx
movq (%rax,%rcx,8), %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x4ece6