// File: /workspace/github_c_makefile_star2_O2/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 $0x68, %rsp
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
cmpq $0x0, 0x18(%rdi)
je 0x7939f
movq 0x20(%rbx), %rsi
movq %rbx, %rdi
callq 0x790eb
cmpq $0x0, 0x8(%rbx)
jne 0x793c7
leaq 0x4ca5f(%rip), %rdi     # 0xc5e0c
leaq 0x4c5b1(%rip), %rsi     # 0xc5965
leaq 0x4ca64(%rip), %rcx     # 0xc5e1f
movl $0x358, %edx            # imm = 0x358
xorl %eax, %eax
callq 0x60031
pxor %xmm0, %xmm0
leaq 0x10(%rsp), %r13
movdqa %xmm0, (%r13)
xorl %r14d, %r14d
leaq 0x245(%rip), %rbp       # 0x79625
xorl %eax, %eax
testb $0x1, %al
jne 0x79458
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
movq 0x10(%rdi), %rdx
movq %r15, (%rsp)
movq %rbp, %rcx
movq %r13, %r8
movq %r12, %r9
callq 0x9039a
movq %rax, %r14
movb $0x1, %al
cmpq $0x0, 0x18(%rbx)
je 0x793e2
movq %r14, %rcx
incq %rcx
movq 0x8(%rbx), %rdx
cmpq 0x10(%rdx), %rcx
jb 0x793e2
andq $0x0, 0x10(%rsp)
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x79435
callq 0x791e5
andq $0x0, 0x18(%rsp)
movdqu 0x20(%rbx), %xmm0
paddq %xmm0, %xmm0
movdqu %xmm0, 0x20(%rbx)
movq %xmm0, %rsi
movq %rbx, %rdi
callq 0x790eb
jmp 0x793e0
cmpq $0x0, 0x10(%rsp)
je 0x7955b
leaq 0x9e965(%rip), %rax     # 0x117dd0
movq (%rax), %rsi
leaq 0x38(%rsp), %r13
movq %r13, 0x30(%rsp)
movq %r13, %rdi
callq 0x717f5
xorl %eax, %eax
callq 0x8eb65
movabsq $-0x503db0e6e1c2e704, %rbp # imm = 0xAFC24F191E3D18FC
movq %r13, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x71917
movq %rax, %r15
xorl %eax, %eax
callq 0x8eb65
movq %r13, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x71917
movq %rax, %r12
xorl %eax, %eax
callq 0x8eb65
movq %r13, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x71917
movq %rax, %r13
movq 0x18(%rsp), %rsi
testq %rsi, %rsi
je 0x794e6
leaq 0x38(%rsp), %rdi
callq 0x71a4d
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x79562
movq 0x8(%rdi), %rax
movq (%rax), %rbp
testq %rbp, %rbp
je 0x795b3
movabsq $0x766eac77ec0f2a97, %rax # imm = 0x766EAC77EC0F2A97
cmpq %rax, (%rbp)
jne 0x795b3
callq 0x76820
leaq 0x28(%rsp), %rdx
leaq 0x20(%rsp), %rcx
movq %rbp, %rdi
movq %rax, %rsi
movq %r13, %r8
callq 0x77329
movq 0x8(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x28(%rsp), %rax
movq (%rax), %rcx
leaq 0x20(%rsp), %rax
movq (%rax), %r8
leaq 0x4c8e3(%rip), %rsi     # 0xc5e32
movq %r12, %rdi
xorl %eax, %eax
callq 0x8f4ef
jmp 0x795b3
xorl %eax, %eax
jmp 0x79612
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
callq 0x9022f
leaq 0x38(%rsp), %rdi
movq %rax, %rsi
callq 0x71a4d
movq %rax, %r13
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
callq 0x8fff4
movq %rax, %rbp
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
callq 0x90007
leaq 0x4c8a7(%rip), %rsi     # 0xc5e4a
movq %r12, %rdi
movq %rbp, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x8f4ef
movq 0x8(%r12), %rdx
movq 0x18(%rsp), %rax
testq %rax, %rax
je 0x795c8
movq 0x8(%rax), %rcx
jmp 0x795cf
leaq 0x4cffd(%rip), %rcx     # 0xc65cc
leaq 0x4c891(%rip), %rsi     # 0xc5e67
movq %r15, %rdi
xorl %eax, %eax
callq 0x8f4ef
movq 0x8(%r13), %rdx
leaq 0x52abc(%rip), %rsi     # 0xcc0a7
movq %r15, %rdi
xorl %eax, %eax
callq 0x8f4ef
movq 0x10(%rsp), %rdi
movq 0x8(%r15), %rsi
callq 0x60533
leaq 0x30(%rsp), %rdi
callq 0x71b48
movq 0x10(%rsp), %rax
movq %r14, 0x10(%rbx)
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq