// File: /workspace/github_c_makefile_star2_O1/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 0xf3176
movq 0x20(%rbx), %rsi
movq %rbx, %rdi
callq 0xf2dce
cmpq $0x0, 0x8(%rbx)
jne 0xf319e
leaq 0x5fdc0(%rip), %rdi     # 0x152f44
leaq 0x5f935(%rip), %rsi     # 0x152ac0
leaq 0x5fdc5(%rip), %rcx     # 0x152f57
movl $0x358, %edx            # imm = 0x358
xorl %eax, %eax
callq 0xc80f6
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %r8
movaps %xmm0, (%r8)
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
movq 0x10(%rdi), %rdx
movq 0x28(%rsp), %rax
movq %rax, (%rsp)
leaq 0x302(%rip), %rcx       # 0xf34c8
movq %r12, %r9
callq 0x1168ee
movq %rax, %r14
cmpq $0x0, 0x18(%rbx)
je 0xf3304
leaq 0xb6285(%rip), %r13     # 0x1a9468
leaq 0x1(%r14), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rcx), %rax
jb 0xf3304
movq $0x0, 0x10(%rsp)
movq 0x18(%rsp), %r14
testq %r14, %r14
je 0xf32a3
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 0xf326a
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rbp, %rdx
je 0xf326a
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rbp, %rdx
je 0xf326a
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rbp, %rdx
jne 0xf32fc
movq (%rax,%rcx), %r15
testq %r15, %r15
jne 0xf3296
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
movq %rbp, %rsi
callq 0xf3f85
movq %rax, %r15
movq %r13, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x12128c
movq %r15, %rdi
movq %r14, %rsi
callq *0xb8(%r15)
movq $0x0, 0x18(%rsp)
movq 0x20(%rbx), %rsi
addq %rsi, %rsi
movq %rsi, 0x20(%rbx)
shlq 0x28(%rbx)
movq %rbx, %rdi
callq 0xf2dce
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
movq 0x10(%rdi), %rdx
movq 0x28(%rsp), %rax
movq %rax, (%rsp)
leaq 0x1e9(%rip), %rcx       # 0xf34c8
leaq 0x10(%rsp), %r8
movq %r12, %r9
callq 0x1168ee
movq %rax, %r14
cmpq $0x0, 0x18(%rbx)
jne 0xf31e3
jmp 0xf3304
xorl %r15d, %r15d
jmp 0xf326e
cmpq $0x0, 0x10(%rsp)
je 0xf34b0
leaq 0xb5ab9(%rip), %rax     # 0x1a8dd0
movq (%rax), %rsi
leaq 0x48(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0xe0431
movq 0x30(%rsp), %rbp
xorl %eax, %eax
callq 0x114bbb
movabsq $-0x503db0e6e1c2e704, %r13 # imm = 0xAFC24F191E3D18FC
movq %rbp, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0xe0582
movq %rax, %r15
xorl %eax, %eax
callq 0x114bbb
movq %rbp, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0xe0582
movq %rax, %r12
xorl %eax, %eax
callq 0x114bbb
movq %rbp, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0xe0582
movq %rax, %r13
movq 0x18(%rsp), %rsi
testq %rsi, %rsi
je 0xf3392
movq %rbp, %rdi
callq 0xe081c
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0xf3407
movq 0x8(%rdi), %rax
movq (%rax), %rbp
testq %rbp, %rbp
je 0xf3456
movabsq $0x766eac77ec0f2a97, %rax # imm = 0x766EAC77EC0F2A97
cmpq %rax, (%rbp)
jne 0xf3456
callq 0xed664
leaq 0x40(%rsp), %rdx
leaq 0x38(%rsp), %rcx
movq %rbp, %rdi
movq %rax, %rsi
movq %r13, %r8
callq 0xef47f
movq 0x8(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x40(%rsp), %rax
movq (%rax), %rcx
leaq 0x38(%rsp), %rax
movq (%rax), %r8
leaq 0x5fb6f(%rip), %rsi     # 0x152f6a
movq %r12, %rdi
xorl %eax, %eax
callq 0x1157cb
jmp 0xf3456
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
callq 0x1166ad
movq %rbp, %rdi
movq %rax, %rsi
callq 0xe081c
movq %rax, %r13
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
callq 0x1163c9
movq %rax, %rbp
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
callq 0x116400
leaq 0x5fb3c(%rip), %rsi     # 0x152f82
movq %r12, %rdi
movq %rbp, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1157cb
movq 0x8(%r12), %rdx
movq 0x18(%rsp), %rax
testq %rax, %rax
je 0xf346b
movq 0x8(%rax), %rcx
jmp 0xf3472
leaq 0x6027d(%rip), %rcx     # 0x1536ef
leaq 0x5fb26(%rip), %rsi     # 0x152f9f
movq %r15, %rdi
xorl %eax, %eax
callq 0x1157cb
movq 0x8(%r13), %rdx
leaq 0x65b79(%rip), %rsi     # 0x159007
movq %r15, %rdi
xorl %eax, %eax
callq 0x1157cb
movq 0x10(%rsp), %rdi
movq 0x8(%r15), %rsi
callq 0xc86db
leaq 0x30(%rsp), %rdi
callq 0xe0b11
movq %r14, 0x10(%rbx)
movq 0x10(%rsp), %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq