// File: /workspace/github_cpp_makefile_star2_O1/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, %ebp
movq %rsi, %r15
movq %rdi, %rbx
movq 0x38(%rdi), %rax
cmpq 0x40(%rdi), %rax
jne 0x18e43
movq %rbx, %rdi
callq 0x1e5f4
testb %bpl, %bpl
je 0x18e6d
cmpl $0x0, 0x2d8(%rbx)
jne 0x190de
movq 0x12174(%rip), %rdi     # 0x2afd0
leaq 0xabd5(%rip), %rsi      # 0x23a38
movl $0x15, %edx
jmp 0x19100
movq 0x1217c(%rip), %r14     # 0x2aff0
leaq 0xac98(%rip), %r12      # 0x23b13
movl 0x2d8(%rbx), %r13d
cmpl $0x39, %r13d
jle 0x18f00
cmpl $0x3a, %r13d
je 0x18fc1
cmpl $0x3f, %r13d
je 0x18f6a
cmpl $0x45, %r13d
jne 0x1914a
movq %rbx, %rdi
movq %r15, %rsi
callq 0x18c7d
testb %bpl, %bpl
jne 0x18ef1
movl $0x2c, %edx
movq %r14, %rdi
leaq 0xabdd(%rip), %rsi      # 0x23aa2
callq 0x2280
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2160
movl $0x1, 0x84(%rbx)
jmp 0x19013
cmpl $0x1e, %r13d
je 0x18f6a
cmpl $0x39, %r13d
jne 0x19141
movq %rbx, %rdi
movq %r15, %rsi
callq 0x18c7d
testb %bpl, %bpl
jne 0x18f5b
movl $0x27, %edx
movq %r14, %rdi
leaq 0xab1f(%rip), %rsi      # 0x23a4e
callq 0x2280
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2160
movl $0x1, 0x80(%rbx)
jmp 0x19013
movq %rbx, %rdi
movq %r15, %rsi
callq 0x18c7d
testb %bpl, %bpl
jne 0x18fb5
movl $0x27, %edx
movq %r14, %rdi
leaq 0xab46(%rip), %rsi      # 0x23acf
callq 0x2280
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2160
movl $0x1, 0x88(%rbx)
jmp 0x19013
movq %rbx, %rdi
movq %r15, %rsi
callq 0x18c7d
testb %bpl, %bpl
jne 0x1900c
movl $0x2b, %edx
movq %r14, %rdi
leaq 0xaa96(%rip), %rsi      # 0x23a76
callq 0x2280
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2160
movl $0x1, 0x58(%rbx)
movq %rbx, %rdi
callq 0x1e5f4
testb %bpl, %bpl
jne 0x19060
cmpl $0x0, 0x2d8(%rbx)
jne 0x19060
movl $0x1e, %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0x2280
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2160
movl 0x2d8(%rbx), %eax
cmpl %r13d, %eax
setne %cl
orb %bpl, %cl
je 0x1907c
cmpl %r13d, %eax
jne 0x18e7b
jmp 0x190bb
movq 0x11f6d(%rip), %rdi     # 0x2aff0
leaq 0xaaa8(%rip), %rsi      # 0x23b32
movl $0x1a, %edx
callq 0x2280
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2160
testb %bpl, %bpl
je 0x190de
cmpl $0x0, 0x2d8(%rbx)
je 0x190ed
movq 0x11f00(%rip), %rdi     # 0x2afd0
leaq 0xaa8f(%rip), %rsi      # 0x23b66
movl $0x1c, %edx
jmp 0x19100
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x11edc(%rip), %rdi     # 0x2afd0
leaq 0xaa52(%rip), %rsi      # 0x23b4d
movl $0x18, %edx
callq 0x2280
movq 0x11ec4(%rip), %rbx     # 0x2afd0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2210
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 0x2160
testl %r13d, %r13d
je 0x190bb
movq %rbx, %rdi
movq %r15, %rsi
callq 0x18c7d
testb %bpl, %bpl
jne 0x190c0
movq 0x11e8b(%rip), %rdi     # 0x2aff0
leaq 0xa98b(%rip), %rsi      # 0x23af7
movl $0x1b, %edx
jmp 0x1908f