// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/value.c
// Function: janet_getindex
Janet janet_getindex(Janet ds, int32_t index) {
    Janet value;
    if (index < 0) janet_panic("expected non-negative index");
    switch (janet_type(ds)) {
        default:
            janet_panicf("expected %T, got %v", JANET_TFLAG_LENGTHABLE, ds);
            break;
        case JANET_STRING:
        case JANET_SYMBOL:
        case JANET_KEYWORD:
            if (index >= janet_string_length(janet_unwrap_string(ds))) {
                value = janet_wrap_nil();
            } else {
                value = janet_wrap_integer(janet_unwrap_string(ds)[index]);
            }
            break;
        case JANET_ARRAY:
            if (index >= janet_unwrap_array(ds)->count) {
                value = janet_wrap_nil();
            } else {
                value = janet_unwrap_array(ds)->data[index];
            }
            break;
        case JANET_BUFFER:
            if (index >= janet_unwrap_buffer(ds)->count) {
                value = janet_wrap_nil();
            } else {
                value = janet_wrap_integer(janet_unwrap_buffer(ds)->data[index]);
            }
            break;
        case JANET_TUPLE:
            if (index >= janet_tuple_length(janet_unwrap_tuple(ds))) {
                value = janet_wrap_nil();
            } else {
                value = janet_unwrap_tuple(ds)[index];
            }
            break;
        case JANET_TABLE:
            value = janet_table_get(janet_unwrap_table(ds), janet_wrap_integer(index));
            break;
        case JANET_STRUCT:
            value = janet_struct_get(janet_unwrap_struct(ds), janet_wrap_integer(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), janet_wrap_integer(index), &value))
                    value = janet_wrap_nil();
            } else {
                janet_panicf("no getter for %v ", ds);
            }
            break;
        }
        case JANET_FIBER: {
            if (index == 0) {
                value = janet_unwrap_fiber(ds)->last_value;
            } else {
                value = janet_wrap_nil();
            }
            break;
        }
    }
    return value;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jge 0x6fcc4
leaq 0x2903d(%rip), %rdi     # 0x98cfc
callq 0x1ad60
movsd -0x10(%rbp), %xmm0
ucomisd %xmm0, %xmm0
setp %al
testb $0x1, %al
jne 0x6fcd6
jmp 0x6fcea
movq -0x10(%rbp), %rax
shrq $0x2f, %rax
andq $0xf, %rax
movl %eax, -0x8c(%rbp)
jmp 0x6fcf4
xorl %eax, %eax
movl %eax, -0x8c(%rbp)
jmp 0x6fcf4
movl -0x8c(%rbp), %eax
addl $-0x3, %eax
movl %eax, %ecx
movq %rcx, -0x98(%rbp)
subl $0xb, %eax
ja 0x6fd22
movq -0x98(%rbp), %rax
leaq 0x28ebb(%rip), %rcx     # 0x98bd4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rdx
leaq 0x113ba(%rip), %rdi     # 0x810e7
movl $0xff0, %esi            # imm = 0xFF0
movb $0x0, %al
callq 0x1ac40
movl -0x14(%rbp), %eax
movl %eax, -0x9c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x7b260
movq %rax, %rcx
movl -0x9c(%rbp), %eax
cmpl -0x8(%rcx), %eax
jl 0x6fd76
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x6fd9c
movq -0x10(%rbp), %rdi
callq 0x7b260
movslq -0x14(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cvtsi2sd %eax, %xmm0
callq 0x7b820
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x70013
movl -0x14(%rbp), %eax
movl %eax, -0xa0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x7b260
movq %rax, %rcx
movl -0xa0(%rbp), %eax
cmpl 0x10(%rcx), %eax
jl 0x6fdde
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x6fdf7
movq -0x10(%rbp), %rdi
callq 0x7b260
movq 0x18(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x8(%rbp)
jmp 0x70013
movl -0x14(%rbp), %eax
movl %eax, -0xa4(%rbp)
movq -0x10(%rbp), %rdi
callq 0x7b260
movq %rax, %rcx
movl -0xa4(%rbp), %eax
cmpl 0x10(%rcx), %eax
jl 0x6fe39
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x6fe63
movq -0x10(%rbp), %rdi
callq 0x7b260
movq 0x18(%rax), %rax
movslq -0x14(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cvtsi2sd %eax, %xmm0
callq 0x7b820
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x70013
movl -0x14(%rbp), %eax
movl %eax, -0xa8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x7b260
movq %rax, %rcx
movl -0xa8(%rbp), %eax
cmpl -0x10(%rcx), %eax
jl 0x6fea5
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x6feba
movq -0x10(%rbp), %rdi
callq 0x7b260
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x8(%rbp)
jmp 0x70013
movq -0x10(%rbp), %rdi
callq 0x7b260
movq %rax, -0xb0(%rbp)
cvtsi2sdl -0x14(%rbp), %xmm0
callq 0x7b820
movq -0xb0(%rbp), %rdi
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rsi
callq 0x69420
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x70013
movq -0x10(%rbp), %rdi
callq 0x7b260
movq %rax, -0xb8(%rbp)
cvtsi2sdl -0x14(%rbp), %xmm0
callq 0x7b820
movq -0xb8(%rbp), %rdi
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rsi
callq 0x67ed0
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x70013
movq -0x10(%rbp), %rdi
callq 0x7b260
movq -0x10(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x6ffc3
movq -0x70(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x7b260
movq %rax, -0xc8(%rbp)
cvtsi2sdl -0x14(%rbp), %xmm0
callq 0x7b820
movq -0xc8(%rbp), %rdi
movq %rax, %rcx
movq -0xc0(%rbp), %rax
movq %rcx, -0x78(%rbp)
movq -0x78(%rbp), %rsi
leaq -0x8(%rbp), %rdx
callq *%rax
cmpl $0x0, %eax
jne 0x6ffc1
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x6ffd5
movq -0x10(%rbp), %rsi
leaq 0x28d05(%rip), %rdi     # 0x98cd3
movb $0x0, %al
callq 0x1ac40
jmp 0x70013
cmpl $0x0, -0x14(%rbp)
jne 0x6fff0
movq -0x10(%rbp), %rdi
callq 0x7b260
movq 0x40(%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0x70011
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x70013
movq -0x8(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq