// File: /workspace/github_cpp_makefile_star2_O2/cannam[P]mini-cpp-convnet/flower.cpp
// Function: read_image(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
vector<vector<vector<float>>>
read_image(string filename)
{
    png_image image;
    memset(&image, 0, sizeof(image));
    image.version = PNG_IMAGE_VERSION;

    if (!png_image_begin_read_from_file(&image, filename.c_str())) {
        throw runtime_error
            (string("Failed to open image file: ") + image.message);
    }

    image.format = PNG_FORMAT_RGB;
    auto size = image.width * image.height * 3;
    vector<png_byte> buffer(size, 255);
    
    if (!png_image_finish_read(&image, nullptr, buffer.data(), 0, nullptr)) {
        throw runtime_error
            (string("Failed to read image file: ") + image.message);
    }

    vector<vector<vector<float>>> image_tensor;
    auto ptr = buffer.begin();
    
    for (png_uint_32 i = 0; i < image.height; ++i) {
        image_tensor.push_back(vector<vector<float>>());
        for (png_uint_32 j = 0; j < image.width; ++j) {
            image_tensor[i].push_back(vector<float>());
            for (png_uint_32 k = 0; k < 3; ++k) {
                image_tensor[i][j].push_back(*ptr++ / 255.f);
            }
        }
    }
        
    return image_tensor;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq 0x80(%rsp), %rdi
movaps %xmm0, (%rdi)
movaps %xmm0, 0x50(%rdi)
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
andq $0x0, 0x60(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movl $0x1, 0x8(%rdi)
movq (%rsi), %rsi
callq 0x2210
testl %eax, %eax
je 0x1c493
movl $0x2, 0x94(%rsp)
movl 0x8c(%rsp), %eax
imull 0x90(%rsp), %eax
leal (%rax,%rax,2), %esi
leaq 0x10(%rsp), %rdx
movb $-0x1, (%rdx)
leaq 0x48(%rsp), %rdi
leaq 0x60(%rsp), %rcx
callq 0x1cd4c
movq 0x48(%rsp), %rdx
leaq 0x80(%rsp), %rdi
xorl %esi, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x20f0
testl %eax, %eax
je 0x1c4f5
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
xorl %r15d, %r15d
movq 0x48(%rsp), %r12
leaq 0x10(%rsp), %r14
movl 0x90(%rsp), %eax
cmpq %rax, %r15
jae 0x1c474
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1d592
movq %r14, %rdi
callq 0x1cb82
movq %r15, 0x38(%rsp)
imulq $0x18, %r15, %r13
xorl %ebp, %ebp
movl 0x8c(%rsp), %eax
cmpq %rax, %rbp
jae 0x1c467
movq (%rbx), %rdi
addq %r13, %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movq %r14, %rsi
callq 0x1d75c
movq %r14, %rdi
callq 0x1cef2
movq %rbp, 0x40(%rsp)
imulq $0x18, %rbp, %rbp
xorl %r15d, %r15d
cmpl $0x3, %r15d
je 0x1c45a
movq (%rbx), %rax
movzbl (%r12,%r15), %ecx
cvtsi2ss %ecx, %xmm0
movq (%rax,%r13), %rdi
addq %rbp, %rdi
divss 0x2bbd(%rip), %xmm0     # 0x1f004
movss %xmm0, 0x10(%rsp)
movq %r14, %rsi
callq 0x1d926
incq %r15
jmp 0x1c426
movq 0x40(%rsp), %rbp
incq %rbp
addq %r15, %r12
jmp 0x1c3ea
movq 0x38(%rsp), %r15
incq %r15
jmp 0x1c3ae
leaq 0x48(%rsp), %rdi
callq 0x1d518
movq %rbx, %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x20e0
movq %rax, %rbx
leaq 0x2cd2(%rip), %rsi      # 0x1f177
leaq 0x60(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x1cd10
leaq 0xa4(%rsp), %rdx
leaq 0x10(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x1cc2d
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x2280
xorl %ebp, %ebp
movq 0x95b0c(%rip), %rsi     # 0xb1ff0
movq 0x95ac5(%rip), %rdx     # 0xb1fb0
movq %rbx, %rdi
callq 0x22c0
jmp 0x1c555
pushq $0x10
popq %rdi
callq 0x20e0
movq %rax, %rbx
leaq 0x2c8c(%rip), %rsi      # 0x1f193
leaq 0x60(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x1cd10
leaq 0xa4(%rsp), %rdx
leaq 0x10(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x1cc2d
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x2280
xorl %ebp, %ebp
movq 0x95aaa(%rip), %rsi     # 0xb1ff0
movq 0x95a63(%rip), %rdx     # 0xb1fb0
movq %rbx, %rdi
callq 0x22c0
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x20c0
jmp 0x1c56a
movq %rax, %r14
movb $0x1, %bpl
leaq 0x60(%rsp), %rdi
callq 0x20c0
testb %bpl, %bpl
jne 0x1c5a4
jmp 0x1c5ee
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x20c0
jmp 0x1c590
movq %rax, %r14
movb $0x1, %bpl
leaq 0x60(%rsp), %rdi
callq 0x20c0
testb %bpl, %bpl
jne 0x1c5b1
jmp 0x1c5f8
movq %rax, %r14
movq %rbx, %rdi
callq 0x2160
jmp 0x1c5ee
movq %rax, %r14
movq %rbx, %rdi
callq 0x2160
jmp 0x1c5f8
movq %rax, %r14
jmp 0x1c5ee
movq %rax, %r14
jmp 0x1c5f8
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x1cb82
jmp 0x1c5e6
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x1cef2
jmp 0x1c5e6
movq %rax, %r14
movq %rbx, %rdi
callq 0x1cba4
leaq 0x48(%rsp), %rdi
callq 0x1d518
movq %r14, %rdi
callq 0x22d0