// File: /workspace/github_c_makefile_star2_O3/johsteffens[P]beth/lib/bcore/bcore_spect_array.c
// Function: set_dyn_link_typed
static void set_dyn_link_typed( const bcore_array_s* p, vd_t o, uz_t index, sr_s src )
{
    bcore_array_dyn_link_typed_s* arr = obj_vd( p, o );
    if( arr->type == 0 ) arr->type = sr_s_type( &src );
    if( index >= arr->size ) bcore_array_p_set_size( p, o, index + 1 );
    vd_t* dst = &arr->data[ index ];

    if( src.o )
    {
        if( sr_s_type( &src ) == arr->type )
        {
           const bcore_inst_s* inst_p = sr_s_get_spect( TYPEOF_bcore_inst_s, &src );
           if( *dst ) bcore_inst_p_discard( inst_p, *dst );
           *dst = sr_s_is_strong( &src ) ? src.o : bcore_inst_p_clone( inst_p, src.o );
           src = sr_cw( src );
        }
        else
        {
            const bcore_inst_s* inst_p = bcore_inst_s_get_typed( arr->type );
            if( *dst ) bcore_inst_p_discard( inst_p, *dst );
            *dst = bcore_inst_p_create_typed( inst_p, sr_s_type( &src ), src.o );
        }
    }
    else if( arr->type )
    {
        const bcore_inst_s* inst_p = bcore_inst_s_get_typed( arr->type );
        if( *dst ) bcore_inst_p_discard( inst_p, *dst );
        *dst = NULL;
    }

    sr_down( src );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
leaq 0x40(%rsp), %r12
movq 0x20(%rdi), %r13
cmpq $0x0, 0x18(%rsi,%r13)
jne 0xf1d4a
movq 0x8(%r12), %rax
testq %rax, %rax
je 0xf1d43
movq 0x8(%rax), %rax
jmp 0xf1d45
xorl %eax, %eax
movq %rax, 0x18(%r15,%r13)
cmpq %rbx, 0x8(%r15,%r13)
ja 0xf1d5d
leaq 0x1(%rbx), %rdx
movq %r15, %rsi
callq 0xec548
movq (%r15,%r13), %rbp
movq (%r12), %r14
testq %r14, %r14
je 0xf1dac
movq 0x8(%r12), %r12
testq %r12, %r12
je 0xf1e69
movq 0x8(%r12), %rsi
movq 0x18(%r15,%r13), %r15
cmpq %r15, %rsi
jne 0xf1e77
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
cmpq %rdi, (%r12)
je 0xf1f47
callq 0xe9bc5
movq %rax, %r12
jmp 0xf1f47
movq 0x18(%r15,%r13), %r14
testq %r14, %r14
je 0xf1f8f
leaq 0xaa6a7(%rip), %rax     # 0x19c468
movl (%rax), %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x20(%rax,%rcx,8), %rdx
movq 0x18(%rax,%rcx,8), %rcx
andq %r14, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %r14, %rdx
je 0xf1e17
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r14, %rdx
je 0xf1e17
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r14, %rdx
je 0xf1e17
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r14, %rdx
jne 0xf1e20
movq (%rax,%rcx), %r15
testq %r15, %r15
jne 0xf1e47
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
movq %r14, %rsi
callq 0xe9bc5
movq %rax, %r15
leaq 0xaa62c(%rip), %rdi     # 0x19c468
movq %r14, %rsi
movq %rax, %rdx
callq 0x115fac
movq (%rbp,%rbx,8), %rsi
testq %rsi, %rsi
je 0xf1e5b
movq %r15, %rdi
callq *0xb8(%r15)
movq $0x0, (%rbp,%rbx,8)
jmp 0xf1f8f
movq 0x18(%r15,%r13), %r15
testq %r15, %r15
je 0xf1f44
leaq 0xaa5ea(%rip), %rax     # 0x19c468
movl (%rax), %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x20(%rax,%rcx,8), %rdx
movq 0x18(%rax,%rcx,8), %rcx
andq %r15, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %r15, %rdx
je 0xf1ed4
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r15, %rdx
je 0xf1ed4
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r15, %rdx
je 0xf1ed4
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r15, %rdx
jne 0xf1edd
movq (%rax,%rcx), %r14
testq %r14, %r14
jne 0xf1f04
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
movq %r15, %rsi
callq 0xe9bc5
movq %rax, %r14
leaq 0xaa56f(%rip), %rdi     # 0x19c468
movq %r15, %rsi
movq %rax, %rdx
callq 0x115fac
movq (%rbp,%rbx,8), %rsi
testq %rsi, %rsi
leaq 0x40(%rsp), %r12
je 0xf1f1d
movq %r14, %rdi
callq *0xb8(%r14)
movq 0x8(%r12), %rax
testq %rax, %rax
je 0xf1f2d
movq 0x8(%rax), %rsi
jmp 0xf1f2f
xorl %esi, %esi
movq (%r12), %rdx
movq %r14, %rdi
callq *0xb0(%r14)
movq %rax, (%rbp,%rbx,8)
jmp 0xf1f8f
xorl %r12d, %r12d
movq (%rbp,%rbx,8), %rsi
testq %rsi, %rsi
je 0xf1f5c
movq %r12, %rdi
callq *0xb8(%r12)
leaq 0x40(%rsp), %rax
movq 0x10(%rax), %r15
testb $0x2, %r15b
jne 0xf1f7c
movq %r12, %rdi
movq %r14, %rsi
callq *0xc0(%r12)
movq %rax, %r14
movq %r14, (%rbp,%rbx,8)
andq $-0x3, %r15
leaq 0x40(%rsp), %r12
movq %r15, 0x10(%r12)
testb $0x2, 0x10(%r12)
jne 0xf1fa6
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x107590