// File: /workspace/github_c_makefile_star2_O3/johsteffens[P]beth/lib/bcore/bcore_sources.c
// Function: string_parse_em_fv
static er_t string_parse_em_fv( bcore_source_string_s* o, sc_t format, va_list args )
{
    if( o->ext_supplier ) string_refill( o, o->refill_limit );
    if( !o->string ) ERR( "No string defined." );

    struct { er_t er; st_s* msg; } er_arg;
    er_arg.er = 0;
    er_arg.msg = NULL;

    bl_t success = false;
    uz_t new_index = 0;

    while( !success )
    {
        new_index = st_s_parse_efv( o->string, o->index, o->string->size, string_s_parse_em_err, &er_arg, format, args );

        /** If in buffering mode and string parsing reached the end of buffered data, we clear all possible errors,
         *  double prefetch and refill limits, refill data and try parsing again.
         *  This situation should occur rarely so that we can tolerate the extra effort and memory overhead.
         */
        if( o->ext_supplier && ( ( new_index + 1 ) >= o->string->size ) )
        {

            success = false;

            // clear parse error if any
            er_arg.er = 0;
            if( er_arg.msg ) bcore_inst_a_discard( er_arg.msg );
            er_arg.msg = NULL;

            // refill with new limits
            o->refill_limit  = o->refill_limit * 2;
            o->prefetch_size = o->prefetch_size * 2;
            string_refill( o, o->refill_limit ); // turns buffering mode off after all data has been fetched
        }
        else
        {
            success = true;
        }
    }

    if( er_arg.er )
    {
        BLM_INIT();
        st_s* msg_main    = BLM_CREATE( st_s );
        st_s* msg_prefix  = BLM_CREATE( st_s );
        st_s* msg_context = BLM_CREATE( st_s );
        if( er_arg.msg ) BLM_A_PUSH( er_arg.msg );

        if( o->parent )
        {
            if( o->parent->data[ 0 ] && ( *( aware_t* )o->parent->data[ 0 ] ) == TYPEOF_bcore_source_file_s )
            {
                bcore_source_file_s* fo = o->parent->data[ 0 ];
                s3_t index = bcore_source_chain_s_get_index( o->parent );
                uz_t line, col;
                bcore_source_file_s_get_line_col_context( fo, index, &line, &col, msg_context );
                st_s_push_fa( msg_prefix, "#<sc_t>:#<uz_t>:#<uz_t>", bcore_source_file_s_get_name( fo ), line, col );
            }
        }
        else
        {
            msg_context = BLM_A_PUSH( st_s_show_line_context( o->string, o->index ) );
            uz_t line = st_s_lineof( o->string, o->index );
            uz_t col  = st_s_colof( o->string, o->index );
            st_s_push_fa( msg_prefix, "At line #<uz_t>, col #<uz_t>", line, col );
        }

        st_s_push_fa( msg_main, "\n#<sc_t>: error: #<sc_t>", msg_prefix->sc, er_arg.msg ? er_arg.msg->sc : "" );
        st_s_push_fa( msg_main, "\n#<sc_t>\n", msg_context->sc );

        bcore_error_push_sc( er_arg.er, msg_main->sc );
        BLM_DOWN();
    }
    o->index = new_index;
    return er_arg.er;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, 0x28(%rsp)
movq %rsi, %r12
movq %rdi, %rbx
cmpq $0x0, 0x18(%rdi)
je 0xe8df1
movq 0x20(%rbx), %rsi
movq %rbx, %rdi
callq 0xe8a53
cmpq $0x0, 0x8(%rbx)
jne 0xe8e19
leaq 0x5f16b(%rip), %rdi     # 0x147f6a
leaq 0x5ece0(%rip), %rsi     # 0x147ae6
leaq 0x5f170(%rip), %rcx     # 0x147f7d
movl $0x358, %edx            # imm = 0x358
xorl %eax, %eax
callq 0xbe592
pxor %xmm0, %xmm0
leaq 0x10(%rsp), %r8
movdqa %xmm0, (%r8)
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
movq 0x10(%rdi), %rdx
movq 0x28(%rsp), %rax
movq %rax, (%rsp)
leaq 0x301(%rip), %rcx       # 0xe9144
movq %r12, %r9
callq 0x10b9e1
movq %rax, %r14
cmpq $0x0, 0x18(%rbx)
je 0xe8f77
leaq 0xb3608(%rip), %r13     # 0x19c468
leaq 0x1(%r14), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rcx), %rax
jb 0xe8f77
movq $0x0, 0x10(%rsp)
movq 0x18(%rsp), %r14
testq %r14, %r14
je 0xe8f1c
movq (%r14), %rbp
movl (%r13), %eax
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%r13,%rax,8), %rcx
movq 0x18(%r13,%rax,8), %rdx
andq %rbp, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %rbp, %rdx
je 0xe8ee3
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rbp, %rdx
je 0xe8ee3
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rbp, %rdx
je 0xe8ee3
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rbp, %rdx
jne 0xe8eec
movq (%rax,%rcx), %r15
testq %r15, %r15
jne 0xe8f0f
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
movq %rbp, %rsi
callq 0xe9bc5
movq %rax, %r15
movq %r13, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x115fac
movq %r15, %rdi
movq %r14, %rsi
callq *0xb8(%r15)
movq $0x0, 0x18(%rsp)
movdqu 0x20(%rbx), %xmm0
paddq %xmm0, %xmm0
movdqu %xmm0, 0x20(%rbx)
movq %xmm0, %rsi
movq %rbx, %rdi
callq 0xe8a53
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
movq 0x10(%rdi), %rdx
movq 0x28(%rsp), %rax
movq %rax, (%rsp)
leaq 0x1e8(%rip), %rcx       # 0xe9144
leaq 0x10(%rsp), %r8
movq %r12, %r9
callq 0x10b9e1
movq %rax, %r14
cmpq $0x0, 0x18(%rbx)
jne 0xe8e60
cmpq $0x0, 0x10(%rsp)
je 0xe907a
leaq 0xb2e46(%rip), %rax     # 0x19bdd0
movq (%rax), %rsi
leaq 0x48(%rsp), %r13
movq %r13, 0x40(%rsp)
movq %r13, %rdi
callq 0xd6675
xorl %eax, %eax
callq 0x109c82
movabsq $-0x503db0e6e1c2e704, %rbp # imm = 0xAFC24F191E3D18FC
movq %r13, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0xd67bd
movq %rax, %r15
xorl %eax, %eax
callq 0x109c82
movq %r13, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0xd67bd
movq %rax, %r12
xorl %eax, %eax
callq 0x109c82
movq %r13, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0xd67bd
movq %rax, %r13
movq 0x18(%rsp), %rsi
testq %rsi, %rsi
je 0xe9005
leaq 0x48(%rsp), %rdi
callq 0xd6a3c
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0xe9081
movq 0x8(%rdi), %rax
movq (%rax), %rbp
testq %rbp, %rbp
je 0xe90d2
movabsq $0x766eac77ec0f2a97, %rax # imm = 0x766EAC77EC0F2A97
cmpq %rax, (%rbp)
jne 0xe90d2
callq 0xe3543
leaq 0x38(%rsp), %rdx
leaq 0x30(%rsp), %rcx
movq %rbp, %rdi
movq %rax, %rsi
movq %r13, %r8
callq 0xe52c3
movq 0x8(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x38(%rsp), %rax
movq (%rax), %rcx
leaq 0x30(%rsp), %rax
movq (%rax), %r8
leaq 0x5ef22(%rip), %rsi     # 0x147f90
movq %r12, %rdi
xorl %eax, %eax
callq 0x10a8a5
jmp 0xe90d2
xorl %eax, %eax
jmp 0xe9131
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
callq 0x10b7ae
leaq 0x48(%rsp), %rdi
movq %rax, %rsi
callq 0xd6a3c
movq %rax, %r13
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
callq 0x10b4ca
movq %rax, %rbp
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
callq 0x10b501
leaq 0x5eee6(%rip), %rsi     # 0x147fa8
movq %r12, %rdi
movq %rbp, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x10a8a5
movq 0x8(%r12), %rdx
movq 0x18(%rsp), %rax
testq %rax, %rax
je 0xe90e7
movq 0x8(%rax), %rcx
jmp 0xe90ee
leaq 0x5f627(%rip), %rcx     # 0x148715
leaq 0x5eed0(%rip), %rsi     # 0x147fc5
movq %r15, %rdi
xorl %eax, %eax
callq 0x10a8a5
movq 0x8(%r13), %rdx
leaq 0x64f5d(%rip), %rsi     # 0x14e067
movq %r15, %rdi
xorl %eax, %eax
callq 0x10a8a5
movq 0x10(%rsp), %rdi
movq 0x8(%r15), %rsi
callq 0xbeb67
leaq 0x40(%rsp), %rdi
callq 0xd6d0d
movq 0x10(%rsp), %rax
movq %r14, 0x10(%rbx)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq