// File: ThePhage[P]horse_tornado/fast.cpp
// Function: (anonymous namespace)::read_png(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
Image read_png(const string& path) {
  FILE* file = fopen(path.c_str(),"rb");
  if (!file)
    die("Failed to open "+path+" for reading");
  png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0);
  if (!png)
    die("Error reading png file "+path);
  png_infop info = png_create_info_struct(png);
  if (!info || setjmp(png_jmpbuf(png)))
    die("Error reading png file "+path);
  png_init_io(png,file);
  png_read_png(png,info,PNG_TRANSFORM_STRIP_16|PNG_TRANSFORM_STRIP_ALPHA
                       |PNG_TRANSFORM_PACKING|PNG_TRANSFORM_EXPAND,0);
  const int w = png_get_image_width(png,info),
            h = png_get_image_height(png,info);
  Image image(w,h);
  Pixel** rows = (Pixel**)png_get_rows(png,info);
  for (const int x : range(w))
    for (const int y : range(h))
      image(x,y) = rows[h-y-1][x];
  png_destroy_read_struct(&png,&info,0);
  fclose(file);
  return image;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x120(%rbp)
movq %rdi, %rax
movq %rax, -0x118(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x7240
movq %rax, %rdi
leaq 0x1970e(%rip), %rsi     # 0x294d5
callq 0x7730
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0xfe47
movq -0x10(%rbp), %rdx
leaq 0x196f6(%rip), %rsi     # 0x294d8
leaq -0x58(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x119c0
movq -0x128(%rbp), %rsi
leaq 0x196e8(%rip), %rdx     # 0x294e8
leaq -0x38(%rbp), %rdi
callq 0x114d0
jmp 0xfe0b
leaq -0x38(%rbp), %rdi
callq 0x87f0
jmp 0xfe16
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xfe39
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x7380
leaq -0x58(%rbp), %rdi
callq 0x7380
jmp 0x1024d
leaq 0x196a7(%rip), %rdi     # 0x294f5
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rsi
movq %rcx, %rdx
callq 0x70b0
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0xfeb1
movq -0x10(%rbp), %rdx
leaq 0x19689(%rip), %rsi     # 0x294fc
leaq -0x90(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x119c0
movq -0x130(%rbp), %rdi
callq 0x87f0
jmp 0xfe94
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x7380
jmp 0x1024d
movq -0x70(%rbp), %rdi
callq 0x79c0
movq %rax, -0x98(%rbp)
cmpq $0x0, -0x98(%rbp)
je 0xfeed
movq -0x70(%rbp), %rdi
movq 0x2b0ba(%rip), %rsi     # 0x3af90
movl $0xc8, %edx
callq 0x7690
movq %rax, %rdi
callq 0x7870
cmpl $0x0, %eax
je 0xff36
movq -0x10(%rbp), %rdx
leaq 0x19604(%rip), %rsi     # 0x294fc
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x119c0
movq -0x138(%rbp), %rdi
callq 0x87f0
jmp 0xff19
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x7380
jmp 0x1024d
movq -0x70(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x7a80
movq -0x70(%rbp), %rdi
movq -0x98(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movl $0x17, %edx
callq 0x7a50
movq -0x70(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x73d0
movl %eax, -0xbc(%rbp)
movq -0x70(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x7b20
movq -0x120(%rbp), %rdi
movl %eax, -0xc0(%rbp)
movb $0x0, -0xc1(%rbp)
movl -0xbc(%rbp), %esi
movl -0xc0(%rbp), %edx
callq 0x10950
movq -0x70(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x7480
movq %rax, -0x140(%rbp)
jmp 0xffc0
movq -0x140(%rbp), %rax
movq %rax, -0xd0(%rbp)
movl -0xbc(%rbp), %edi
callq 0xf550
movq %rax, -0x148(%rbp)
jmp 0xffe2
movq -0x148(%rbp), %rax
movq %rax, -0xe0(%rbp)
leaq -0xe0(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rdi
callq 0xf570
movl %eax, -0x14c(%rbp)
jmp 0x10012
movl -0x14c(%rbp), %eax
movl %eax, -0xe4(%rbp)
movq -0xd8(%rbp), %rdi
callq 0xf590
movl %eax, -0x150(%rbp)
jmp 0x10032
movl -0x150(%rbp), %eax
movl %eax, -0xe8(%rbp)
movl -0xe8(%rbp), %eax
movl %eax, -0xec(%rbp)
movl -0xec(%rbp), %esi
leaq -0xe4(%rbp), %rdi
callq 0xf5b0
movb %al, -0x151(%rbp)
jmp 0x10064
movb -0x151(%rbp), %al
testb $0x1, %al
jne 0x10073
jmp 0x10200
leaq -0xe4(%rbp), %rdi
callq 0xf5d0
movl %eax, -0x158(%rbp)
jmp 0x10087
movl -0x158(%rbp), %eax
movl %eax, -0xf0(%rbp)
movl -0xc0(%rbp), %edi
callq 0xf550
movq %rax, -0x160(%rbp)
jmp 0x100a7
movq -0x160(%rbp), %rax
movq %rax, -0x100(%rbp)
leaq -0x100(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rdi
callq 0xf570
movl %eax, -0x164(%rbp)
jmp 0x100d7
movl -0x164(%rbp), %eax
movl %eax, -0x104(%rbp)
movq -0xf8(%rbp), %rdi
callq 0xf590
movl %eax, -0x168(%rbp)
jmp 0x100f7
movl -0x168(%rbp), %eax
movl %eax, -0x108(%rbp)
movl -0x108(%rbp), %eax
movl %eax, -0x10c(%rbp)
movl -0x10c(%rbp), %esi
leaq -0x104(%rbp), %rdi
callq 0xf5b0
movb %al, -0x169(%rbp)
jmp 0x10129
movb -0x169(%rbp), %al
testb $0x1, %al
jne 0x10138
jmp 0x101eb
leaq -0x104(%rbp), %rdi
callq 0xf5d0
movl %eax, -0x170(%rbp)
jmp 0x1014c
movq -0x120(%rbp), %rdi
movl -0x170(%rbp), %eax
movl %eax, -0x110(%rbp)
movq -0xd0(%rbp), %rax
movl -0xc0(%rbp), %esi
movl -0x110(%rbp), %edx
movl %edx, %ecx
notl %ecx
addl %esi, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0xf0(%rbp), %rcx
movl %ecx, %esi
leaq (%rcx,%rcx,2), %rcx
addq %rcx, %rax
movq %rax, -0x180(%rbp)
callq 0xf5e0
movq %rax, -0x178(%rbp)
jmp 0x101a4
movq -0x178(%rbp), %rax
movq -0x180(%rbp), %rcx
movw (%rcx), %dx
movw %dx, (%rax)
movb 0x2(%rcx), %cl
movb %cl, 0x2(%rax)
leaq -0x104(%rbp), %rdi
callq 0xf630
jmp 0x101cc
jmp 0x10103
movq -0x120(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
callq 0xf660
jmp 0x1024d
jmp 0x101ed
leaq -0xe4(%rbp), %rdi
callq 0xf630
jmp 0x101fb
jmp 0x1003e
xorl %eax, %eax
movl %eax, %edx
leaq -0x70(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x7330
jmp 0x10216
movq -0x18(%rbp), %rdi
callq 0x7600
jmp 0x10221
movb $0x1, -0xc1(%rbp)
testb $0x1, -0xc1(%rbp)
jne 0x1023d
movq -0x120(%rbp), %rdi
callq 0xf660
movq -0x118(%rbp), %rax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x79d0
nopw %cs:(%rax,%rax)