// File: lvandeve[P]lodepng/pngdetail.cpp
// Function: showExif(Data&)
void showExif(Data& data) {
  data.loadInspect();
  if(data.error) return;
  if(!data.state.info_png.exif_defined) {
    std::cout << "No EXIF data present in this PNG image" << std::endl;
    return;
  }
  const unsigned char* exif = data.state.info_png.exif;
  size_t size = data.state.info_png.exif_size;
  if(size < 8) {
    std::cout << "EXIF size too small: " << size << std::endl;
    return;
  }
  std::cout << "EXIF size: " << size << std::endl;
  bool big_endian = exif[0] == 'M' && exif[1] == 'M' && exif[2] == 0 && exif[3] == 42;
  bool little_endian = exif[0] == 'I' && exif[1] == 'I' && exif[2] == 42 && exif[3] == 0;
  if(big_endian) {
    std::cout << "EXIF encoded using big endian (MM)" << std::endl;
  } else if(little_endian) {
    std::cout << "EXIF encoded using little endian (II)" << std::endl;
  } else {
    std::cout << "EXIF has invalid header, must start with MM or II" << std::endl;
    return;
  }
  size_t ifd = readExifUint32(exif, size, 4, big_endian);
  showExifIFD(exif, size, ifd, big_endian, false, false);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x317c0
movq -0x8(%rbp), %rax
cmpl $0x0, 0x2d8(%rax)
je 0x30677
jmp 0x30885
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1b0(%rax)
jne 0x306ab
movq 0x16945(%rip), %rdi     # 0x46fd0
leaq 0xaa8e(%rip), %rsi      # 0x3b120
callq 0x2250
movq %rax, %rdi
movq 0x1691f(%rip), %rsi     # 0x46fc0
callq 0x22a0
jmp 0x30885
movq -0x8(%rbp), %rax
movq 0x1b8(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x1c0(%rax), %eax
movq %rax, -0x18(%rbp)
cmpq $0x8, -0x18(%rbp)
jae 0x30702
movq 0x168fa(%rip), %rdi     # 0x46fd0
leaq 0xaa6a(%rip), %rsi      # 0x3b147
callq 0x2250
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x2080
movq %rax, %rdi
movq 0x168c8(%rip), %rsi     # 0x46fc0
callq 0x22a0
jmp 0x30885
movq 0x168c7(%rip), %rdi     # 0x46fd0
leaq 0xaa4d(%rip), %rsi      # 0x3b15d
callq 0x2250
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x2080
movq %rax, %rdi
movq 0x16895(%rip), %rsi     # 0x46fc0
callq 0x22a0
movq -0x10(%rbp), %rax
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x4d, %ecx
movb %al, -0x29(%rbp)
jne 0x30776
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %ecx
xorl %eax, %eax
cmpl $0x4d, %ecx
movb %al, -0x29(%rbp)
jne 0x30776
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x29(%rbp)
jne 0x30776
movq -0x10(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x2a, %eax
sete %al
movb %al, -0x29(%rbp)
movb -0x29(%rbp), %al
andb $0x1, %al
movb %al, -0x19(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x49, %ecx
movb %al, -0x2a(%rbp)
jne 0x307c4
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %ecx
xorl %eax, %eax
cmpl $0x49, %ecx
movb %al, -0x2a(%rbp)
jne 0x307c4
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %ecx
xorl %eax, %eax
cmpl $0x2a, %ecx
movb %al, -0x2a(%rbp)
jne 0x307c4
movq -0x10(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x0, %eax
sete %al
movb %al, -0x2a(%rbp)
movb -0x2a(%rbp), %al
andb $0x1, %al
movb %al, -0x1a(%rbp)
testb $0x1, -0x19(%rbp)
je 0x307f6
movq 0x167f7(%rip), %rdi     # 0x46fd0
leaq 0xa989(%rip), %rsi      # 0x3b169
callq 0x2250
movq %rax, %rdi
movq 0x167d1(%rip), %rsi     # 0x46fc0
callq 0x22a0
jmp 0x30846
testb $0x1, -0x1a(%rbp)
je 0x30820
movq 0x167cd(%rip), %rdi     # 0x46fd0
leaq 0xa982(%rip), %rsi      # 0x3b18c
callq 0x2250
movq %rax, %rdi
movq 0x167a7(%rip), %rsi     # 0x46fc0
callq 0x22a0
jmp 0x30844
movq 0x167a9(%rip), %rdi     # 0x46fd0
leaq 0xa984(%rip), %rsi      # 0x3b1b2
callq 0x2250
movq %rax, %rdi
movq 0x16783(%rip), %rsi     # 0x46fc0
callq 0x22a0
jmp 0x30885
jmp 0x30846
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movb -0x19(%rbp), %al
movl $0x4, %edx
andb $0x1, %al
movzbl %al, %ecx
callq 0x2fa00
movl %eax, %eax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rdx
movb -0x19(%rbp), %al
xorl %r9d, %r9d
andb $0x1, %al
movzbl %al, %ecx
movl %r9d, %r8d
callq 0x2fb50
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)