// File: /workspace/github_c_makefile_star2_O0/johsteffens[P]beth/lib/bcore/bcore_img.c
// Function: bcore_img_u2_s_pnm_from_source
bcore_img_u2_s* bcore_img_u2_s_pnm_from_source( bcore_img_u2_s* o, bcore_source* source )
{
    BLM_INIT();

    // We avoid source-parse functions so that source can stay a mere data buffer.
    // Instead we scan the first text lines into a string:
    st_s* first_three_lines = BLM_CREATE( st_s );
    sz_t count = 0;
    while( !bcore_source_a_eos( source ) )
    {
        char c = bcore_source_a_get_char( source );
        st_s_push_char( first_three_lines, c );
        if( c == '\n' )
        {
            count++;
            if( count == 3 ) break;
        }
    }

    uz_t rows = 0, cols = 0;

    bcore_source_a_parse_fa
    (
        BLM_A_PUSH( bcore_source_string_s_create_from_string( first_three_lines ) ),
        "P6 #<uz_t*> #<uz_t*> 255\n",
        &cols,
        &rows
    );

    bcore_img_u2_s_set_size( o, rows, cols );

    for( sz_t i = 0; i < o->rows; i++ )
    {
        for( sz_t j = 0; j < o->cols; j++ )
        {
            u0_t rgb[ 3 ];
            bcore_source_a_get_data( source, rgb, 3 );
            bcore_img_u2_s_set_rgb( o, i, j, rgb[ 0 ], rgb[ 1 ], rgb[ 2 ] );
        }
    }

    BLM_DOWN();
    return o;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq 0x84276(%rip), %rax     # 0x1b2330
movq (%rax), %rax
movq %rax, -0x18(%rbp)
leaq -0x48(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xbfe80
movq -0x50(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x98(%rbp)
movb $0x0, %al
callq 0xff2e0
movq -0x98(%rbp), %rdi
movq %rax, %rdx
movabsq $-0x503db0e6e1c2e704, %rsi # imm = 0xAFC24F191E3D18FC
callq 0xc00e0
movq %rax, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x10(%rbp), %rdi
callq 0x12e280
xorb $-0x1, %al
testb $0x1, %al
jne 0x12e126
jmp 0x12e161
movq -0x10(%rbp), %rdi
callq 0x12e2b0
movb %al, -0x61(%rbp)
movq -0x58(%rbp), %rdi
movsbl -0x61(%rbp), %esi
callq 0xffba0
movsbl -0x61(%rbp), %eax
cmpl $0xa, %eax
jne 0x12e15f
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
cmpq $0x3, -0x60(%rbp)
jne 0x12e15d
jmp 0x12e161
jmp 0x12e15f
jmp 0x12e115
movq $0x0, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x58(%rbp), %rdi
callq 0xcbf50
movq -0xa0(%rbp), %rdi
movq %rax, %rsi
callq 0xc0460
movq %rax, %rdi
leaq 0x2b5e1(%rip), %rsi     # 0x15977f
leaq -0x78(%rbp), %rdx
leaq -0x70(%rbp), %rcx
movb $0x0, %al
callq 0xf3450
movq -0x8(%rbp), %rdi
movq -0x70(%rbp), %rsi
movq -0x78(%rbp), %rdx
callq 0x12ddf0
movq $0x0, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x12e25f
movq $0x0, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0x12e24c
movq -0x10(%rbp), %rdi
leaq -0x8b(%rbp), %rsi
movl $0x3, %edx
callq 0x12e2e0
movq -0x8(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq -0x88(%rbp), %rdx
movb -0x8b(%rbp), %cl
movb -0x8a(%rbp), %al
movzbl %cl, %ecx
movzbl %al, %r8d
movzbl -0x89(%rbp), %r9d
callq 0x12e320
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
jmp 0x12e1e3
jmp 0x12e24e
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0x12e1c6
leaq -0x50(%rbp), %rdi
callq 0xc06e0
movq -0x8(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)