// File: /workspace/github_c_makefile_star2_O1/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 0xfc330
movq 0x8(%r12), %rax
testq %rax, %rax
je 0xfc329
movq 0x8(%rax), %rax
jmp 0xfc32b
xorl %eax, %eax
movq %rax, 0x18(%r15,%r13)
cmpq %rbx, 0x8(%r15,%r13)
ja 0xfc343
leaq 0x1(%rbx), %rdx
movq %r15, %rsi
callq 0xf69d8
movq (%r15,%r13), %rbp
movq (%r12), %r14
testq %r14, %r14
je 0xfc368
movq 0x8(%r12), %r12
testq %r12, %r12
je 0xfc429
movq 0x8(%r12), %rax
jmp 0xfc42b
movq 0x18(%r15,%r13), %r14
testq %r14, %r14
je 0xfc580
leaq 0xad0eb(%rip), %rax     # 0x1a9468
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 0xfc3d7
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r14, %rdx
je 0xfc3d7
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r14, %rdx
je 0xfc3d7
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r14, %rdx
jne 0xfc5b2
movq (%rax,%rcx), %r15
testq %r15, %r15
jne 0xfc407
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
movq %r14, %rsi
callq 0xf3f85
movq %rax, %r15
leaq 0xad06c(%rip), %rdi     # 0x1a9468
movq %r14, %rsi
movq %rax, %rdx
callq 0x12128c
movq (%rbp,%rbx,8), %rsi
testq %rsi, %rsi
je 0xfc41b
movq %r15, %rdi
callq *0xb8(%r15)
movq $0x0, (%rbp,%rbx,8)
jmp 0xfc580
xorl %eax, %eax
movq 0x18(%r15,%r13), %r15
cmpq %r15, %rax
jne 0xfc464
testq %r12, %r12
je 0xfc51e
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
cmpq %rdi, (%r12)
je 0xfc521
movq 0x8(%r12), %rsi
callq 0xf3f85
movq %rax, %r12
jmp 0xfc521
leaq 0xacffd(%rip), %rax     # 0x1a9468
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 0xfc4c5
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r15, %rdx
je 0xfc4c5
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r15, %rdx
je 0xfc4c5
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r15, %rdx
jne 0xfc5aa
movq (%rax,%rcx), %r14
leaq 0x40(%rsp), %r12
testq %r14, %r14
jne 0xfc4fa
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
movq %r15, %rsi
callq 0xf3f85
movq %rax, %r14
leaq 0xacf79(%rip), %rdi     # 0x1a9468
movq %r15, %rsi
movq %rax, %rdx
callq 0x12128c
movq (%rbp,%rbx,8), %rsi
testq %rsi, %rsi
je 0xfc50e
movq %r14, %rdi
callq *0xb8(%r14)
movq 0x8(%r12), %rax
testq %rax, %rax
je 0xfc56b
movq 0x8(%rax), %rsi
jmp 0xfc56d
xorl %r12d, %r12d
movq (%rbp,%rbx,8), %rsi
testq %rsi, %rsi
je 0xfc536
movq %r12, %rdi
callq *0xb8(%r12)
leaq 0x40(%rsp), %rax
movq 0x10(%rax), %r15
testb $0x2, %r15b
jne 0xfc556
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)
jmp 0xfc580
xorl %esi, %esi
movq (%r12), %rdx
movq %r14, %rdi
callq *0xb0(%r14)
movq %rax, (%rbp,%rbx,8)
testb $0x2, 0x10(%r12)
jne 0xfc597
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 0x112485
xorl %r14d, %r14d
jmp 0xfc4c9
xorl %r15d, %r15d
jmp 0xfc3db