// File: /workspace/github_cpp_makefile_star2_O3/lvandeve[P]lodepng/pngdetail.cpp
// Function: loadWithErrorRecovery(Data&, Options const&, bool)
void loadWithErrorRecovery(Data& data, const Options& options, bool show_errors_mode) {
  (void)options;
  unsigned& error = data.error;
  lodepng::State& state = data.state;

  data.loadPixels();

  if(show_errors_mode) {
    if(!error) std::cout << "No errors or warnings" << std::endl;
    return;
  }

  // In case of checksum errors and some other ignorable errors, report it but ignore it and retry
  while(error) {
    // Not showing regular error here, is shown at end of program.
    unsigned error2 = error;
    if(error == 57) {
      showError(data, options);
      if(!show_errors_mode) std::cerr << "Ignoring the error: enabling ignore_crc" << std::endl;
      state.decoder.ignore_crc = 1;
      data.reloadPixels();
    } else if(error == 58) {
      showError(data, options);
      if(!show_errors_mode) std::cerr << "Ignoring the error: enabling ignore_adler32" << std::endl;
      state.decoder.zlibsettings.ignore_adler32 = 1;
      data.reloadPixels();
    } else if(error == 69) {
      showError(data, options);
      if(!show_errors_mode) std::cerr << "Ignoring the error: enabling ignore_critical" << std::endl;
      state.decoder.ignore_critical = 1;
      data.reloadPixels();
    } else if(error == 30 || error == 63) {
      showError(data, options);
      if(!show_errors_mode) std::cerr << "Ignoring the error: enabling ignore_end" << std::endl;
      state.decoder.ignore_end = 1;
      data.reloadPixels();
    } else {
      showError(data, options);
      if(!show_errors_mode) std::cerr << "This error is unrecoverable" << std::endl;
      break;  // other error that we cannot ignore
    }
    if(!show_errors_mode) if(error == 0) std::cerr << "Successfully ignored the error" << std::endl;
    if(error == error2) {
      if(!show_errors_mode) std::cerr << "Failed to ignore the error" << std::endl;
      break; // avoid infinite loop if ignoring did not fix the error code
    }
  }

  if(show_errors_mode) {
    if(!error) std::cout << "The error is recoverable" << std::endl;
    else std::cout << "The error is not recoverable" << std::endl;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
movq 0x38(%rdi), %rax
cmpq 0x40(%rdi), %rax
jne 0x18c62
movq %r15, %rdi
callq 0x1e4e8
testb %bl, %bl
je 0x18c83
cmpl $0x0, 0x2d8(%r15)
je 0x18e8e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x2d8(%r15), %r12d
movq 0x1235f(%rip), %rbx     # 0x2aff0
leaq 0xb057(%rip), %r13      # 0x23cef
leaq 0xb094(%rip), %rbp      # 0x23d33
cmpl $0x39, %r12d
jle 0x18d19
cmpl $0x3a, %r12d
je 0x18dce
cmpl $0x3f, %r12d
je 0x18d7f
cmpl $0x45, %r12d
jne 0x18eac
movq %r15, %rdi
movq %r14, %rsi
callq 0x18a9c
movl $0x2c, %edx
movq %rbx, %rdi
leaq 0xafe5(%rip), %rsi      # 0x23cc2
callq 0x2290
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movl $0x1, 0x84(%r15)
jmp 0x18e1c
cmpl $0x1e, %r12d
je 0x18d7f
cmpl $0x39, %r12d
jne 0x18ea3
movq %r15, %rdi
movq %r14, %rsi
callq 0x18a9c
movl $0x27, %edx
movq %rbx, %rdi
leaq 0xaf2b(%rip), %rsi      # 0x23c6e
callq 0x2290
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movl $0x1, 0x80(%r15)
jmp 0x18e1c
movq %r15, %rdi
movq %r14, %rsi
callq 0x18a9c
movl $0x27, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2290
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movl $0x1, 0x88(%r15)
jmp 0x18e1c
movq %r15, %rdi
movq %r14, %rsi
callq 0x18a9c
movl $0x2b, %edx
movq %rbx, %rdi
leaq 0xaeae(%rip), %rsi      # 0x23c96
callq 0x2290
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movl $0x1, 0x58(%r15)
movq %r15, %rdi
callq 0x1e4e8
movl 0x2d8(%r15), %eax
testl %eax, %eax
jne 0x18e6d
movl $0x1e, %edx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2290
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movl 0x2d8(%r15), %eax
cmpl %r12d, %eax
movl %eax, %r12d
jne 0x18c9f
movq 0x12170(%rip), %rbx     # 0x2aff0
leaq 0xaecb(%rip), %rsi      # 0x23d52
movl $0x1a, %edx
jmp 0x18ec3
movq 0x1213b(%rip), %rbx     # 0x2afd0
leaq 0xadbc(%rip), %rsi      # 0x23c58
movl $0x15, %edx
jmp 0x18ec3
testl %r12d, %r12d
je 0x18c74
movq %r15, %rdi
movq %r14, %rsi
callq 0x18a9c
leaq 0xae59(%rip), %rsi      # 0x23d17
movl $0x1b, %edx
movq %rbx, %rdi
callq 0x2290
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2170