// File: /workspace/github_cpp_makefile_star2_O1/wcochran[P]pano_to_cube/PPM.cpp
// Function: PPM::write(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void PPM::write(const std::string& fname) { // throws BogusPPM
  FILE *f = fopen(fname.c_str(), "wb");
  if (f == nullptr) {
    std::stringstream ss;
    ss << fname << ":" << strerror(errno);
    throw BogusPPM(ss.str());
  }
  fprintf(f, "P6\n%d %d\n255\n", W, H);
  if (fwrite(&pixels[0], 3, W*H, f) != W*H) {
    std::stringstream ss;
    if (ferror(f))
      ss << fname << ":" << strerror(errno);
    else if (feof(f))
      ss << fname << ": unexpected EOF!";
    else
      ss << fname << ": unable to write pixels";
    fclose(f);
    throw BogusPPM(ss.str());
  }
  fclose(f);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rsi, %r14
movq %rdi, %r15
movq (%rsi), %rdi
leaq 0x1193(%rip), %rsi      # 0x4142
callq 0x21c0
testq %rax, %rax
je 0x3019
movq %rax, %rbx
movl (%r15), %edx
movl 0x4(%r15), %ecx
leaq 0x117b(%rip), %rsi      # 0x4145
movq %rax, %rdi
xorl %eax, %eax
callq 0x21e0
movq 0x8(%r15), %rdi
movslq (%r15), %rax
movslq 0x4(%r15), %rdx
imulq %rax, %rdx
movl $0x3, %esi
movq %rbx, %rcx
callq 0x22b0
movslq (%r15), %rcx
movslq 0x4(%r15), %rdx
imulq %rcx, %rdx
cmpq %rdx, %rax
jne 0x30b1
movq %rbx, %rdi
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2180
leaq 0x20(%rsp), %rdi
callq 0x2100
leaq 0x30(%rsp), %rdi
movq (%r14), %rsi
movq 0x8(%r14), %rdx
callq 0x21b0
movq %rax, %rbx
leaq 0x108d(%rip), %rsi      # 0x40cb
movl $0x1, %edx
movq %rax, %rdi
callq 0x21b0
callq 0x2030
movl (%rax), %edi
callq 0x2070
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2170
movl $0x10, %edi
callq 0x20d0
movq %rax, %r14
leaq 0x38(%rsp), %rsi
movq %rsp, %rdi
callq 0x2230
movb $0x1, %bpl
movq %rsp, %rsi
movq %r14, %rdi
callq 0x22c0
leaq 0x2cff(%rip), %rax      # 0x5d90
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0x2ccb(%rip), %rsi      # 0x5d68
movq 0x2f34(%rip), %rdx      # 0x5fd8
movq %r14, %rdi
callq 0x2260
jmp 0x319e
leaq 0x20(%rsp), %rdi
callq 0x2100
movq %rbx, %rdi
callq 0x22a0
testl %eax, %eax
jne 0x30f2
movq %rbx, %rdi
callq 0x2210
leaq 0x30(%rsp), %rdi
movq (%r14), %rsi
movq 0x8(%r14), %rdx
testl %eax, %eax
jne 0x3133
callq 0x21b0
movl $0x18, %edx
leaq 0x1063(%rip), %rsi      # 0x4153
jmp 0x3144
leaq 0x30(%rsp), %rdi
movq (%r14), %rsi
movq 0x8(%r14), %rdx
callq 0x21b0
movq %rax, %r14
leaq 0xfbe(%rip), %rsi       # 0x40cb
movl $0x1, %edx
movq %rax, %rdi
callq 0x21b0
callq 0x2030
movl (%rax), %edi
callq 0x2070
movq %r14, %rdi
movq %rax, %rsi
callq 0x2170
jmp 0x314c
callq 0x21b0
movl $0x11, %edx
leaq 0xfd4(%rip), %rsi       # 0x4118
movq %rax, %rdi
callq 0x21b0
movq %rbx, %rdi
callq 0x2180
movl $0x10, %edi
callq 0x20d0
movq %rax, %r14
leaq 0x38(%rsp), %rsi
movq %rsp, %rdi
callq 0x2230
movb $0x1, %bpl
movq %rsp, %rsi
movq %r14, %rdi
callq 0x22c0
leaq 0x2c0d(%rip), %rax      # 0x5d90
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0x2bd9(%rip), %rsi      # 0x5d68
movq 0x2e42(%rip), %rdx      # 0x5fd8
movq %r14, %rdi
callq 0x2260
jmp 0x31a2
jmp 0x31c2
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x31c8
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21a0
jmp 0x31c8
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x31dc
movq %r14, %rdi
callq 0x2120
jmp 0x31dc
jmp 0x31d9
movq %rax, %rbx
movq 0x2dd5(%rip), %rsi      # 0x5fb8
leaq 0x20(%rsp), %rdi
callq 0x2130
leaq 0xa0(%rsp), %rdi
callq 0x2060
movq %rbx, %rdi
callq 0x2270