// File: /workspace/github_c_makefile_star2_O3/janet-lang[P]janet/src/core/value.c
// Function: janet_put
void janet_put(Janet ds, Janet key, Janet value) {
    JanetType type = janet_type(ds);
    switch (type) {
        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);
            int32_t index = getter_checkint(type, key, INT32_MAX - 1);
            if (index >= array->count) {
                janet_array_setcount(array, index + 1);
            }
            array->data[index] = value;
            break;
        }
        case JANET_BUFFER: {
            JanetBuffer *buffer = janet_unwrap_buffer(ds);
            int32_t index = getter_checkint(type, key, INT32_MAX - 1);
            if (!janet_checkint(value))
                janet_panicf("can only put integers in buffers, got %v", value);
            if (index >= buffer->count) {
                janet_buffer_setcount(buffer, index + 1);
            }
            buffer->data[index] = (uint8_t)(janet_unwrap_integer(value) & 0xFF);
            break;
        }
        case JANET_TABLE:
            janet_table_put(janet_unwrap_table(ds), key, value);
            break;
        case JANET_ABSTRACT: {
            JanetAbstractType *type = (JanetAbstractType *)janet_abstract_type(janet_unwrap_abstract(ds));
            if (type->put) {
                (type->put)(janet_unwrap_abstract(ds), key, 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 0x4b4b5
movq %rdx, %rbx
movq %rsi, %r14
leaq 0x204d1(%rip), %rcx     # 0x6b88c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r15, %rdi
callq 0x4ebc4
movq %rax, %r15
movl $0x7, %edi
movq %r14, %rsi
movl $0x7ffffffe, %edx       # imm = 0x7FFFFFFE
callq 0x4abdc
movl %eax, %r14d
cmpl 0x10(%r15), %eax
jl 0x4b3f6
leal 0x1(%r14), %esi
movq %r15, %rdi
callq 0x1482c
movq 0x18(%r15), %rax
movl %r14d, %ecx
movq %rbx, (%rax,%rcx,8)
jmp 0x4b458
movq %r15, %rdi
callq 0x4ebc4
movq %rax, %r15
movl $0xb, %edi
movq %r14, %rsi
movl $0x7ffffffe, %edx       # imm = 0x7FFFFFFE
callq 0x4abdc
movl %eax, %r14d
movq %rbx, %rdi
callq 0x49912
testl %eax, %eax
je 0x4b4cb
cmpl 0x10(%r15), %r14d
jl 0x4b445
leal 0x1(%r14), %esi
movq %r15, %rdi
callq 0x17793
movq %rbx, %xmm0
cvttsd2si %xmm0, %eax
movq 0x18(%r15), %rcx
movl %r14d, %edx
movb %al, (%rcx,%rdx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x4ebc4
movq -0x10(%rax), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x4b4d7
movq %rax, %r12
movq %r15, %rdi
callq 0x4ebc4
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r12, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq %r15, %rdi
callq 0x4ebc4
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, %rdx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x476f0
leaq 0x8c2b(%rip), %rdi      # 0x540e7
movl $0xa80, %esi            # imm = 0xA80
movq %r15, %rdx
xorl %eax, %eax
callq 0x190bb
leaq 0x204d2(%rip), %rdi     # 0x6b9a4
movq %rbx, %rsi
jmp 0x4b4e1
leaq 0x204ef(%rip), %rdi     # 0x6b9cd
movq %r15, %rsi
xorl %eax, %eax
callq 0x190bb