// File: /workspace/github_c_makefile_star2_O3/johsteffens[P]beth/xoico/src/xoico.xo.c
// Function: xoico_target_s_expand_phase2
er_t xoico_target_s_expand_phase2( xoico_target_s* o, bl_t* p_modified )
{
    // xoico_target.x:583:1
    BLM_INIT_LEVEL(0);
    if( !o->modified )
    {
        if( (p_modified) ) (*(p_modified)) = false;
        BLM_RETURNV(er_t, 0)
    }
    
    ASSERT( o->target_h );
    ASSERT( o->target_c );
    
    st_s* file_h = ((st_s*)BLM_LEVEL_T_PUSH(0,st_s,st_s_create_fa("#<sc_t>.h", o->output_path.sc )));
    st_s* file_c = ((st_s*)BLM_LEVEL_T_PUSH(0,st_s,st_s_create_fa("#<sc_t>.c", o->output_path.sc )));
    st_s* file_state = ((st_s*)BLM_LEVEL_T_PUSH(0,st_s,st_s_create_fa("#<sc_t>.state", o->output_path.sc )));
    
    if( o->readonly )
    {
    //        bcore_msg_fa( "Affected: #<sc_t>\n", file_h.sc );
    //        bcore_msg_fa( "Affected: #<sc_t>\n", file_c.sc );
        if( (p_modified) ) (*(p_modified)) = false;
    }
    else
    {
        {
            bl_t clear_to_overwrite = false;
            tp_t body_signature = o->update_target_on_body_signature ? o->body_signature_h : 0;
            BLM_TRY(xoico_compiler_s_check_overwrite(o->compiler,file_h->sc, body_signature, (&(clear_to_overwrite)) ))
            if( clear_to_overwrite )
            {
                bcore_msg_fa( "Writing: #<sc_t>\n", file_h->sc );
                BLM_TRY(xoico_target_write_with_signature(file_h->sc, o->target_h ))
                if( (p_modified) ) (*(p_modified)) = true;
            }
        }
    
        {
            bl_t clear_to_overwrite = false;
            tp_t body_signature = o->update_target_on_body_signature ? o->body_signature_c : 0;
            BLM_TRY(xoico_compiler_s_check_overwrite(o->compiler,file_c->sc, body_signature, (&(clear_to_overwrite)) ))
            if( clear_to_overwrite )
            {
                bcore_msg_fa( "Writing: #<sc_t>\n", file_c->sc );
                BLM_TRY(xoico_target_write_with_signature(file_c->sc, o->target_c ))
                if( (p_modified) ) (*(p_modified)) = true;
            }
        }
    
        {
            bl_t clear_to_overwrite = false;
            BLM_TRY(xoico_compiler_s_check_overwrite(o->compiler,file_state->sc, 0, (&(clear_to_overwrite)) ))
            if( clear_to_overwrite )
            {
                bcore_msg_fa( "Writing: #<sc_t>\n", file_state->sc );
                BLM_TRY(xoico_target_write_with_signature(file_state->sc, o->target_state ))
                if( (p_modified) ) (*(p_modified)) = true;
            }
        }
    
    }
    BLM_RETURNV(er_t, 0)
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x16c724(%rip), %rax    # 0x19bdd0
movq (%rax), %rsi
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0xd6675
movq $0x0, 0x10(%r15)
cmpb $0x0, 0xf9(%r14)
je 0x2f7c6
cmpq $0x0, 0x100(%r14)
jne 0x2f705
leaq 0xfdf64(%rip), %rdi     # 0x12d647
leaq 0x10064e(%rip), %rsi    # 0x12fd38
leaq 0x100653(%rip), %rdx    # 0x12fd44
leaq 0xfdb98(%rip), %rcx     # 0x12d290
movl $0x1641, %r8d           # imm = 0x1641
xorl %eax, %eax
callq 0xbe4ef
cmpq $0x0, 0x108(%r14)
jne 0x2f738
leaq 0xfdf31(%rip), %rdi     # 0x12d647
leaq 0x100644(%rip), %rsi    # 0x12fd61
leaq 0x100620(%rip), %rdx    # 0x12fd44
leaq 0xfdb65(%rip), %rcx     # 0x12d290
movl $0x1642, %r8d           # imm = 0x1642
xorl %eax, %eax
callq 0xbe4ef
movq 0x80(%r14), %rsi
leaq 0x100627(%rip), %rdi    # 0x12fd6d
xorl %eax, %eax
callq 0x109dca
leaq 0x8(%rsp), %rbp
movabsq $-0x503db0e6e1c2e704, %r15 # imm = 0xAFC24F191E3D18FC
movq %rbp, %rdi
xorl %esi, %esi
movq %r15, %rdx
movq %rax, %rcx
callq 0xd68a8
movq %rax, %r13
movq 0x80(%r14), %rsi
leaq 0x1005fa(%rip), %rdi    # 0x12fd77
xorl %eax, %eax
callq 0x109dca
movq %rbp, %rdi
xorl %esi, %esi
movq %r15, %rdx
movq %rax, %rcx
callq 0xd68a8
movq %rax, %r12
movq 0x80(%r14), %rsi
leaq 0x100570(%rip), %rdi    # 0x12fd15
xorl %eax, %eax
callq 0x109dca
movq %rbp, %rdi
xorl %esi, %esi
movq %r15, %rdx
movq %rax, %rcx
callq 0xd68a8
cmpb $0x1, 0xfa(%r14)
jne 0x2f7df
testq %rbx, %rbx
je 0x2f7ce
movb $0x0, (%rbx)
leaq 0x8(%rsp), %rdi
callq 0xd6d2c
xorl %ebp, %ebp
jmp 0x2f8d9
movq %rax, %r15
movb $0x0, 0x7(%rsp)
cmpb $0x1, 0x50(%r14)
jne 0x2f7f7
movq 0x118(%r14), %rdx
jmp 0x2f7f9
xorl %edx, %edx
movq 0x138(%r14), %rdi
movq 0x8(%r13), %rsi
leaq 0x7(%rsp), %rcx
callq 0x2f929
testq %rax, %rax
jne 0x2f8cc
cmpb $0x1, 0x7(%rsp)
jne 0x2f848
movq 0x8(%r13), %rsi
leaq 0x100558(%rip), %rdi    # 0x12fd81
xorl %eax, %eax
callq 0xbe364
movq 0x8(%r13), %rdi
movq 0x100(%r14), %rsi
callq 0x2fcd0
testq %rbx, %rbx
je 0x2f848
movb $0x1, (%rbx)
movb $0x0, 0x7(%rsp)
cmpb $0x1, 0x50(%r14)
jne 0x2f85d
movq 0x120(%r14), %rdx
jmp 0x2f85f
xorl %edx, %edx
movq 0x138(%r14), %rdi
movq 0x8(%r12), %rsi
leaq 0x7(%rsp), %rcx
callq 0x2f929
testq %rax, %rax
jne 0x2f8cc
cmpb $0x1, 0x7(%rsp)
jne 0x2f8ad
movq 0x8(%r12), %rsi
leaq 0x1004f4(%rip), %rdi    # 0x12fd81
xorl %eax, %eax
callq 0xbe364
movq 0x8(%r12), %rdi
movq 0x108(%r14), %rsi
callq 0x2fcd0
testq %rbx, %rbx
je 0x2f8ad
movb $0x1, (%rbx)
leaq 0x7(%rsp), %rcx
movb $0x0, (%rcx)
movq 0x138(%r14), %rdi
movq 0x8(%r15), %rsi
xorl %edx, %edx
callq 0x2f929
testq %rax, %rax
je 0x2f8eb
movq %rax, %rbp
leaq 0x8(%rsp), %rdi
callq 0xd6d2c
movq %rbp, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x1, 0x7(%rsp)
jne 0x2f7ce
movq 0x8(%r15), %rsi
leaq 0x100480(%rip), %rdi    # 0x12fd81
xorl %eax, %eax
callq 0xbe364
movq 0x8(%r15), %rdi
movq 0x110(%r14), %rsi
callq 0x2fcd0
testq %rbx, %rbx
je 0x2f7ce
movb $0x1, (%rbx)
jmp 0x2f7ce