// File: /workspace/github_c_makefile_star2_O1/janet-lang[P]janet/src/core/value.c
// Function: janet_putindex
void janet_putindex(Janet ds, int32_t index, Janet value) {
    switch (janet_type(ds)) {
        default:
            janet_panicf("expected %T, got %v",
                         JANET_TFLAG_ARRAY | JANET_TFLAG_BUFFER | JANET_TFLAG_TABLE, ds);
        case JANET_ARRAY: {
            JanetArray *array = janet_unwrap_array(ds);
            if (index >= array->count) {
                janet_array_ensure(array, index + 1, 2);
                array->count = index + 1;
            }
            array->data[index] = value;
            break;
        }
        case JANET_BUFFER: {
            JanetBuffer *buffer = janet_unwrap_buffer(ds);
            if (!janet_checkint(value))
                janet_panicf("can only put integers in buffers, got %v", value);
            if (index >= buffer->count) {
                janet_buffer_ensure(buffer, index + 1, 2);
                buffer->count = index + 1;
            }
            buffer->data[index] = (uint8_t)(janet_unwrap_integer(value) & 0xFF);
            break;
        }
        case JANET_TABLE: {
            JanetTable *table = janet_unwrap_table(ds);
            janet_table_put(table, janet_wrap_integer(index), value);
            break;
        }
        case JANET_ABSTRACT: {
            JanetAbstractType *type = (JanetAbstractType *)janet_abstract_type(janet_unwrap_abstract(ds));
            if (type->put) {
                (type->put)(janet_unwrap_abstract(ds), janet_wrap_integer(index), value);
            } else {
                janet_panicf("no setter for %v ", ds);
            }
            break;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %r15
movq %rdi, %xmm0
movq %rdi, %rcx
shrq $0x2f, %rcx
andl $0xf, %ecx
xorl %eax, %eax
ucomisd %xmm0, %xmm0
cmovpl %ecx, %eax
addl $-0x7, %eax
cmpl $0x7, %eax
ja 0x4bf15
movq %rdx, %rbx
movl %esi, %r14d
leaq 0x20a83(%rip), %rcx     # 0x6c88c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r15, %rdi
callq 0x4f838
movq %rax, %r15
cmpl %r14d, 0x10(%rax)
jg 0x4be3b
leal 0x1(%r14), %r12d
movq %r15, %rdi
movl %r12d, %esi
movl $0x2, %edx
callq 0x147bd
movl %r12d, 0x10(%r15)
movq 0x18(%r15), %rax
movslq %r14d, %rcx
movq %rbx, (%rax,%rcx,8)
jmp 0x4be94
movq %r15, %rdi
callq 0x4f838
movq %rax, %r15
movq %rbx, %rdi
callq 0x4a41f
testl %eax, %eax
je 0x4bf2b
cmpl %r14d, 0x10(%r15)
jg 0x4be81
leal 0x1(%r14), %r12d
movq %r15, %rdi
movl %r12d, %esi
movl $0x2, %edx
callq 0x1777e
movl %r12d, 0x10(%r15)
movq %rbx, %xmm0
cvttsd2si %xmm0, %eax
movq 0x18(%r15), %rcx
movslq %r14d, %rdx
movb %al, (%rcx,%rdx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x4f838
movq -0x10(%rax), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x4bf37
movq %rax, %r12
movq %r15, %rdi
callq 0x4f838
movq %rax, %r15
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
callq 0x4fab8
movq %r15, %rdi
movq %rax, %rsi
movq %rbx, %rdx
movq %r12, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq %r15, %rdi
callq 0x4f838
movq %rax, %r15
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
callq 0x4fab8
movq %r15, %rdi
movq %rax, %rsi
movq %rbx, %rdx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x481b3
leaq 0x91cb(%rip), %rdi      # 0x550e7
movl $0xa80, %esi            # imm = 0xA80
movq %r15, %rdx
xorl %eax, %eax
callq 0x1917b
leaq 0x20a92(%rip), %rdi     # 0x6c9c4
movq %rbx, %rsi
jmp 0x4bf41
leaq 0x20aaf(%rip), %rdi     # 0x6c9ed
movq %r15, %rsi
xorl %eax, %eax
callq 0x1917b