// File: /workspace/github_c_makefile_star2_O2/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 0x472c8
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x20676(%rip), %rcx     # 0x677d4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
callq 0x45e2b
testl %eax, %eax
je 0x472c8
movq %rbx, %xmm0
cvttsd2si %xmm0, %ebx
testl %ebx, %ebx
js 0x472c8
movq %r14, %rdi
callq 0x4b1f1
cmpl %ebx, -0x8(%rax)
jg 0x47299
jmp 0x472c8
movq %rbx, %rdi
callq 0x45e2b
testl %eax, %eax
je 0x472c8
movq %rbx, %xmm0
cvttsd2si %xmm0, %ebx
testl %ebx, %ebx
js 0x472c8
movq %r14, %rdi
callq 0x4b1f1
cmpl $0xb, %r15d
je 0x47290
cmpl $0x7, %r15d
jne 0x472b2
cmpl %ebx, 0x10(%rax)
jle 0x472c8
movq 0x18(%rax), %rax
jmp 0x472b7
movq %r14, %rdi
callq 0x4b1f1
movq %rax, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x43c35
xorpd %xmm0, %xmm0
callq 0x4b471
movq %rbx, %rdi
movq %rax, %rsi
callq 0x466c8
testl %eax, %eax
je 0x472c8
movq %r14, %rdi
callq 0x4b1f1
movq 0x40(%rax), %rax
jmp 0x472bd
movq %r14, %rdi
callq 0x4b1f1
movq -0x10(%rax), %rcx
movq 0x18(%rcx), %rcx
testq %rcx, %rcx
je 0x4727f
leaq -0x20(%rbp), %rdx
movq %rax, %rdi
movq %rbx, %rsi
callq *%rcx
testl %eax, %eax
je 0x4727f
movq -0x20(%rbp), %rax
jmp 0x472bd
movq %r14, %rdi
callq 0x4b1f1
movq %rax, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x430d3
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x4b313
jmp 0x472bd
cmpl %ebx, 0x10(%rax)
jle 0x472c8
movq 0x18(%rax), %rax
movl %ebx, %ecx
movzbl (%rax,%rcx), %eax
cvtsi2sd %eax, %xmm0
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x4b471
cmpl %ebx, -0x10(%rax)
jle 0x472c8
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 0x4b313