// File: 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
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movq %rsi, -0x1a8(%rbp)
movq %rdi, -0x1b8(%rbp)
movq %rdi, %rax
movq %rax, -0x1b0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x78(%rbp), %rdi
xorl %esi, %esi
movl $0x68, %edx
callq 0x3150
movq -0x1a8(%rbp), %rdi
movl $0x1, -0x70(%rbp)
callq 0x30f0
movq %rax, %rsi
leaq -0x78(%rbp), %rdi
callq 0x32f0
cmpl $0x0, %eax
jne 0x498a8
movb $0x1, -0xcd(%rbp)
movl $0x10, %edi
callq 0x3120
movq %rax, -0x1c8(%rbp)
leaq -0xb9(%rbp), %rdi
movq %rdi, -0x1c0(%rbp)
callq 0x33c0
movq -0x1c0(%rbp), %rdx
leaq 0x99a3(%rip), %rsi      # 0x5316f
leaq -0xb8(%rbp), %rdi
callq 0x4b000
jmp 0x497da
leaq -0x54(%rbp), %rdx
leaq -0x98(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x4ad40
jmp 0x497f3
movq -0x1c8(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x3350
jmp 0x49808
movq -0x1c8(%rbp), %rdi
movb $0x0, -0xcd(%rbp)
movq 0x9f7d3(%rip), %rsi     # 0xe8ff0
movq 0x9f78c(%rip), %rdx     # 0xe8fb0
callq 0x3390
jmp 0x49d2c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x49880
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x49874
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x3180
leaq -0xb8(%rbp), %rdi
callq 0x3180
leaq -0xb9(%rbp), %rdi
callq 0x32b0
testb $0x1, -0xcd(%rbp)
jne 0x49897
jmp 0x498a3
movq -0x1c8(%rbp), %rdi
callq 0x31d0
jmp 0x49d20
movl $0x2, -0x64(%rbp)
movl -0x6c(%rbp), %ecx
movl -0x68(%rbp), %eax
imull %eax, %ecx
movl %ecx, %eax
leal (%rax,%rax,2), %eax
movl %eax, -0xd4(%rbp)
movl -0xd4(%rbp), %eax
movq %rax, -0x1d8(%rbp)
movb $-0x1, -0xf1(%rbp)
leaq -0xf2(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x4b0e0
movq -0x1d8(%rbp), %rsi
movq -0x1d0(%rbp), %rcx
leaq -0xf0(%rbp), %rdi
leaq -0xf1(%rbp), %rdx
callq 0x4b100
jmp 0x4990d
leaq -0xf2(%rbp), %rdi
callq 0x4b180
leaq -0xf0(%rbp), %rdi
callq 0x4b1a0
movq %rax, %rdx
xorl %ecx, %ecx
movl %ecx, %r8d
leaq -0x78(%rbp), %rdi
movq %r8, %rsi
callq 0x3130
movl %eax, -0x1dc(%rbp)
jmp 0x49941
movl -0x1dc(%rbp), %eax
cmpl $0x0, %eax
jne 0x49a9f
movb $0x1, -0x13a(%rbp)
movl $0x10, %edi
callq 0x3120
movq %rax, -0x1f0(%rbp)
leaq -0x139(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x33c0
movq -0x1e8(%rbp), %rdx
leaq 0x9802(%rip), %rsi      # 0x5318b
leaq -0x138(%rbp), %rdi
callq 0x4b000
jmp 0x49997
leaq -0x54(%rbp), %rdx
leaq -0x118(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x4ad40
jmp 0x499b0
movq -0x1f0(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x3350
jmp 0x499c5
movq -0x1f0(%rbp), %rdi
movb $0x0, -0x13a(%rbp)
movq 0x9f616(%rip), %rsi     # 0xe8ff0
movq 0x9f5cf(%rip), %rdx     # 0xe8fb0
callq 0x3390
jmp 0x49d2c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0xf2(%rbp), %rdi
callq 0x4b180
jmp 0x49d20
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x49d14
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x49a77
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x49a6b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x3180
leaq -0x138(%rbp), %rdi
callq 0x3180
leaq -0x139(%rbp), %rdi
callq 0x32b0
testb $0x1, -0x13a(%rbp)
jne 0x49a8e
jmp 0x49a9a
movq -0x1f0(%rbp), %rdi
callq 0x31d0
jmp 0x49d14
movq -0x1b8(%rbp), %rdi
movb $0x0, -0x13b(%rbp)
callq 0x4afb0
leaq -0xf0(%rbp), %rdi
callq 0x4b1c0
movq %rax, -0x148(%rbp)
movl $0x0, -0x14c(%rbp)
movl -0x14c(%rbp), %eax
cmpl -0x68(%rbp), %eax
jae 0x49cd0
xorps %xmm0, %xmm0
movaps %xmm0, -0x170(%rbp)
movq $0x0, -0x160(%rbp)
leaq -0x170(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
callq 0x4b220
movq -0x1b8(%rbp), %rdi
movq -0x1f8(%rbp), %rsi
callq 0x4b1f0
jmp 0x49b1b
leaq -0x170(%rbp), %rdi
callq 0x4aa00
movl $0x0, -0x174(%rbp)
movl -0x174(%rbp), %eax
cmpl -0x6c(%rbp), %eax
jae 0x49cba
movq -0x1b8(%rbp), %rdi
movl -0x14c(%rbp), %eax
movl %eax, %esi
callq 0x4ab20
movq %rax, -0x208(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x190(%rbp)
movq $0x0, -0x180(%rbp)
leaq -0x190(%rbp), %rdi
movq %rdi, -0x200(%rbp)
callq 0x4b270
movq -0x208(%rbp), %rdi
movq -0x200(%rbp), %rsi
callq 0x4b240
jmp 0x49b98
leaq -0x190(%rbp), %rdi
callq 0x4aa80
movl $0x0, -0x194(%rbp)
cmpl $0x3, -0x194(%rbp)
jae 0x49ca4
movq -0x1b8(%rbp), %rdi
movl -0x14c(%rbp), %eax
movl %eax, %esi
callq 0x4ab20
movq %rax, %rdi
movl -0x174(%rbp), %eax
movl %eax, %esi
callq 0x4ab40
movq %rax, -0x210(%rbp)
leaq -0x148(%rbp), %rdi
xorl %esi, %esi
callq 0x4b2c0
movq %rax, -0x1a0(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x4b300
movq -0x210(%rbp), %rdi
movzbl (%rax), %eax
cvtsi2ss %eax, %xmm0
movss 0x93e7(%rip), %xmm1     # 0x53004
divss %xmm1, %xmm0
movss %xmm0, -0x198(%rbp)
leaq -0x198(%rbp), %rsi
callq 0x4b290
jmp 0x49c37
jmp 0x49c39
movl -0x194(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x194(%rbp)
jmp 0x49bae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x4aa00
jmp 0x49d08
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x4aa80
jmp 0x49d08
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x49d08
jmp 0x49ca6
movl -0x174(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x174(%rbp)
jmp 0x49b31
jmp 0x49cbc
movl -0x14c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14c(%rbp)
jmp 0x49acf
movb $0x1, -0x13b(%rbp)
testb $0x1, -0x13b(%rbp)
jne 0x49cec
movq -0x1b8(%rbp), %rdi
callq 0x4ab80
leaq -0xf0(%rbp), %rdi
callq 0x4b320
movq -0x1b0(%rbp), %rax
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
movq -0x1b8(%rbp), %rdi
callq 0x4ab80
leaq -0xf0(%rbp), %rdi
callq 0x4b320
movq -0xc8(%rbp), %rdi
callq 0x33b0
nopl (%rax)