// File: /workspace/github_cpp_makefile_star2_O1/wcochran[P]pano_to_cube/PPM.cpp
// Function: PPM::PPM(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
PPM::PPM(const std::string& fname) {
  FILE *f = fopen(fname.c_str(), "rb");
  if (f == nullptr) {
    std::stringstream ss;
    ss << fname << ":" << strerror(errno);
    throw BogusPPM(ss.str());
  }
  static char buf[200];
  if (fgets(buf, sizeof(buf), f) == 0 || strncmp("P6",buf,2) != 0) {
    std::stringstream ss;
    ss << fname << ": not a raw PPM image!";
    fclose(f);
    throw BogusPPM(ss.str());
  }
  while (fgets(buf, sizeof(buf), f) != 0 && buf[0] == '#')
    ;
  if (sscanf(buf, "%d %d", &W, &H) != 2 || W <= 0 || H <= 0) {
    std::stringstream ss;
    ss << fname << ": has a bogus size!";
    fclose(f);
    throw BogusPPM(ss.str());
  }
  int maxval;
  while (fgets(buf, sizeof(buf), f) != 0 && buf[0] == '#')
    ;
  if (sscanf(buf, "%d", &maxval) != 1 || maxval != 255) {
    std::stringstream ss;
    ss << fname << ": max pixel value != 255!";
    fclose(f);
    throw BogusPPM(ss.str());
  }
  const unsigned numPixels = W*H;
  pixels.resize(3*numPixels);
  if (fread(&pixels[0], 3, numPixels, f) != numPixels) {
    std::stringstream ss;
    if (ferror(f))
      ss << fname << ":" << strerror(errno);
    else if (feof(f))
      ss << fname << ": unexpected EOF!";
    else
      ss << fname << ": unable to read pixels";
    fclose(f);
    throw BogusPPM(ss.str());
  }
  fclose(f);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x8(%rdi), %r14
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rdi)
movq $0x0, 0x18(%rdi)
movq (%rsi), %rdi
leaq 0x164c(%rip), %rsi      # 0x40c8
callq 0x21c0
testq %rax, %rax
je 0x2bbd
movq %rax, %r15
leaq 0x371c(%rip), %rdi      # 0x61b0
movl $0xc8, %esi
movq %rax, %rdx
callq 0x2220
testq %rax, %rax
je 0x2c5c
movzwl 0x36ff(%rip), %eax      # 0x61b0
cmpl $0x3650, %eax           # imm = 0x3650
jne 0x2c5c
leaq 0x36ed(%rip), %r13      # 0x61b0
movq %r13, %rdi
movl $0xc8, %esi
movq %r15, %rdx
callq 0x2220
testq %rax, %rax
je 0x2ae1
cmpb $0x23, 0x36d1(%rip)     # 0x61b0
je 0x2ac3
leaq 0x4(%rbx), %rcx
leaq 0x36c4(%rip), %rdi      # 0x61b0
leaq 0x15f1(%rip), %rsi      # 0x40e4
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2160
cmpl $0x2, %eax
jne 0x2ce9
cmpl $0x0, (%rbx)
jle 0x2ce9
cmpl $0x0, 0x4(%rbx)
jle 0x2ce9
leaq 0x3690(%rip), %r13      # 0x61b0
movq %r13, %rdi
movl $0xc8, %esi
movq %r15, %rdx
callq 0x2220
testq %rax, %rax
je 0x2b3e
cmpb $0x23, 0x3674(%rip)     # 0x61b0
je 0x2b20
leaq 0x366b(%rip), %rdi      # 0x61b0
leaq 0x159b(%rip), %rsi      # 0x40e7
leaq 0x2c(%rsp), %rdx
xorl %eax, %eax
callq 0x2160
cmpl $0x1, %eax
jne 0x2d76
cmpl $0xff, 0x2c(%rsp)
jne 0x2d76
movl 0x4(%rbx), %r13d
imull (%rbx), %r13d
leal (%r13,%r13,2), %esi
movq %r14, %rdi
callq 0x33a4
movq (%r14), %rdi
movl %r13d, %r13d
movl $0x3, %esi
movq %r13, %rdx
movq %r15, %rcx
callq 0x21f0
cmpq %r13, %rax
jne 0x2e03
movq %r15, %rdi
callq 0x2180
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x30(%rsp), %rdi
callq 0x2100
leaq 0x40(%rsp), %rdi
movq (%r12), %rsi
movq 0x8(%r12), %rdx
callq 0x21b0
movq %rax, %r15
leaq 0x14e7(%rip), %rsi      # 0x40cb
movl $0x1, %edx
movq %rax, %rdi
callq 0x21b0
callq 0x2030
movl (%rax), %edi
callq 0x2070
movq %r15, %rdi
movq %rax, %rsi
callq 0x2170
movl $0x10, %edi
callq 0x20d0
movq %rax, %r12
leaq 0x48(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x2230
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x22c0
leaq 0x3155(%rip), %rax      # 0x5d90
movq %rax, (%r12)
xorl %ebp, %ebp
leaq 0x3120(%rip), %rsi      # 0x5d68
movq 0x3389(%rip), %rdx      # 0x5fd8
movq %r12, %rdi
callq 0x2260
jmp 0x2ef9
leaq 0x30(%rsp), %rdi
callq 0x2100
leaq 0x40(%rsp), %rdi
movq (%r12), %rsi
movq 0x8(%r12), %rdx
callq 0x21b0
leaq 0x144d(%rip), %rsi      # 0x40cd
movl $0x16, %edx
movq %rax, %rdi
callq 0x21b0
movq %r15, %rdi
callq 0x2180
movl $0x10, %edi
callq 0x20d0
movq %rax, %r12
leaq 0x48(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x2230
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x22c0
leaq 0x30c8(%rip), %rax      # 0x5d90
movq %rax, (%r12)
xorl %ebp, %ebp
leaq 0x3093(%rip), %rsi      # 0x5d68
movq 0x32fc(%rip), %rdx      # 0x5fd8
movq %r12, %rdi
callq 0x2260
jmp 0x2ef9
leaq 0x30(%rsp), %rdi
callq 0x2100
leaq 0x40(%rsp), %rdi
movq (%r12), %rsi
movq 0x8(%r12), %rdx
callq 0x21b0
leaq 0x13dd(%rip), %rsi      # 0x40ea
movl $0x13, %edx
movq %rax, %rdi
callq 0x21b0
movq %r15, %rdi
callq 0x2180
movl $0x10, %edi
callq 0x20d0
movq %rax, %r12
leaq 0x48(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x2230
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x22c0
leaq 0x303b(%rip), %rax      # 0x5d90
movq %rax, (%r12)
xorl %ebp, %ebp
leaq 0x3006(%rip), %rsi      # 0x5d68
movq 0x326f(%rip), %rdx      # 0x5fd8
movq %r12, %rdi
callq 0x2260
jmp 0x2ef9
leaq 0x30(%rsp), %rdi
callq 0x2100
leaq 0x40(%rsp), %rdi
movq (%r12), %rsi
movq 0x8(%r12), %rdx
callq 0x21b0
leaq 0x1364(%rip), %rsi      # 0x40fe
movl $0x19, %edx
movq %rax, %rdi
callq 0x21b0
movq %r15, %rdi
callq 0x2180
movl $0x10, %edi
callq 0x20d0
movq %rax, %r12
leaq 0x48(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x2230
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x22c0
leaq 0x2fae(%rip), %rax      # 0x5d90
movq %rax, (%r12)
xorl %ebp, %ebp
leaq 0x2f79(%rip), %rsi      # 0x5d68
movq 0x31e2(%rip), %rdx      # 0x5fd8
movq %r12, %rdi
callq 0x2260
jmp 0x2ef9
leaq 0x30(%rsp), %rdi
callq 0x2100
movq %r15, %rdi
callq 0x22a0
testl %eax, %eax
jne 0x2e46
movq %r15, %rdi
callq 0x2210
leaq 0x40(%rsp), %rdi
movq (%r12), %rsi
movq 0x8(%r12), %rdx
testl %eax, %eax
jne 0x2e89
callq 0x21b0
movl $0x17, %edx
leaq 0x12e6(%rip), %rsi      # 0x412a
jmp 0x2e9a
leaq 0x40(%rsp), %rdi
movq (%r12), %rsi
movq 0x8(%r12), %rdx
callq 0x21b0
movq %rax, %r12
leaq 0x1268(%rip), %rsi      # 0x40cb
movl $0x1, %edx
movq %rax, %rdi
callq 0x21b0
callq 0x2030
movl (%rax), %edi
callq 0x2070
movq %r12, %rdi
movq %rax, %rsi
callq 0x2170
jmp 0x2ea2
callq 0x21b0
movl $0x11, %edx
leaq 0x127e(%rip), %rsi      # 0x4118
movq %rax, %rdi
callq 0x21b0
movq %r15, %rdi
callq 0x2180
movl $0x10, %edi
callq 0x20d0
movq %rax, %r12
leaq 0x48(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x2230
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x22c0
leaq 0x2eb3(%rip), %rax      # 0x5d90
movq %rax, (%r12)
xorl %ebp, %ebp
leaq 0x2e7e(%rip), %rsi      # 0x5d68
movq 0x30e7(%rip), %rdx      # 0x5fd8
movq %r12, %rdi
callq 0x2260
jmp 0x2f09
jmp 0x2f29
jmp 0x2f09
jmp 0x2f29
jmp 0x2f09
jmp 0x2f29
jmp 0x2f09
jmp 0x2f29
movq %rax, %r15
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2f2f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21a0
jmp 0x2f2f
movq %rax, %r15
movb $0x1, %bpl
testb %bpl, %bpl
je 0x2f49
movq %r12, %rdi
callq 0x2120
jmp 0x2f49
jmp 0x2f46
jmp 0x2f46
jmp 0x2f46
jmp 0x2f46
movq %rax, %r15
movq 0x3068(%rip), %rsi      # 0x5fb8
leaq 0x30(%rsp), %rdi
callq 0x2130
leaq 0xb0(%rsp), %rdi
callq 0x2060
jmp 0x2f76
jmp 0x2f73
jmp 0x2f73
jmp 0x2f73
jmp 0x2f73
jmp 0x2f73
movq %rax, %r15
movq (%r14), %rdi
testq %rdi, %rdi
je 0x2f8a
movq 0x18(%rbx), %rsi
subq %rdi, %rsi
callq 0x21a0
movq %r15, %rdi
callq 0x2270