// File: lvandeve[P]lodepng/pngdetail.cpp
// Function: showExifIFD(unsigned char const*, unsigned long, unsigned long, bool, bool, bool)
void showExifIFD(const unsigned char* exif, size_t size, size_t ifd_pos, bool big_endian, bool is_thumbnail, bool is_sub) {
  size_t pos = ifd_pos;
  size_t sub_ifd = 0;
  if(pos + 2 > size) {
    std::cout << "EXIF IFD out of range: " << pos << std::endl;
    return;
  }
  size_t num_entries = readExifUint16(exif, size, pos, big_endian);
  if(is_sub) {
    std::cout << "EXIF Sub-IFD at " << pos << ", num entries: " << num_entries << std::endl;
  } else if(is_thumbnail) {
    std::cout << "EXIF Thumbnail IFD at " << pos << ", num entries: " << num_entries << std::endl;
  } else {
    std::cout << "EXIF IFD at " << pos << ", num entries: " << num_entries << std::endl;
  }
  pos += 2;
  for(size_t i = 0; i < num_entries; i++) {
    if(pos + 12 > size) {
      std::cout << "EXIF IFD entry out of range: " << pos << std::endl;
      return;
    }
    uint32_t tag_number = readExifUint16(exif, size, pos, big_endian);
    uint32_t format = readExifUint16(exif, size, pos + 2, big_endian);
    uint32_t num = readExifUint32(exif, size, pos + 4, big_endian);
    uint32_t offset = readExifUint32(exif, size, pos + 8, big_endian);
    uint32_t component_size = 1;
    if(format == 3 || format == 8) component_size = 2;
    else if(format == 4 || format == 9 || format == 11) component_size = 4;
    else if(format == 5 || format == 10 || format == 12) component_size = 8;
    size_t len = num * component_size;
    if(len <= 4) offset = pos + 8; // small value is stored in the offset itself
    pos += 12;

    if(format < 1 || format > 12) {
      std::cout << "EXIF unknown entry format" << std::endl;
      return;
    }
    if(is_thumbnail) std::cout << "EXIF tag (thumbnail): ";
    else std::cout << "EXIF tag: ";
    // Only show some common tags by full name
    if(tag_number == 256) std::cout << "Umage Width";
    else if(tag_number == 257) std::cout << "Image Height";
    else if(tag_number == 259) std::cout << "Compression";
    else if(tag_number == 269) std::cout << "Document Name";
    else if(tag_number == 270) std::cout << "Image Description";
    else if(tag_number == 274) std::cout << "Orientation";
    else if(tag_number == 282) std::cout << "X Resolution";
    else if(tag_number == 283) std::cout << "Y Resolution";
    else if(tag_number == 296) std::cout << "Resolution Unit";
    else if(tag_number == 513) std::cout << "Thumbnail Offset";
    else if(tag_number == 514) std::cout << "Thumbnail Size";
    else if(tag_number == 33434) std::cout << "Exposure Time";
    else if(tag_number == 33432) std::cout << "Copyright";
    else if(tag_number == 36864) std::cout << "Exif Version";
    else if(tag_number == 37510) std::cout << "User Comment";
    else std::cout << "#" << tag_number; // tag for which we don't show a name here
    std::cout << ": ";

    if(offset + len > size) {
      std::cout << "EXIF data out of range" << std::endl;
      return;
    }
    if(len == 0) {
      std::cout << "[empty]" << std::endl;
      continue;
    }

    if(format == 1) {
      std::cout << (uint32_t)exif[offset];
    } else if(format == 2) {
      for(size_t j = 0; j < len; j++) {
        if(!exif[offset + j]) break; // NULL terminator
        std::cout << exif[offset + j];
      }
    } else if(format == 3) {
      std::cout << readExifUint16(exif, size, offset, big_endian);
    } else if(format == 4) {
      if(tag_number == 34665) sub_ifd = readExifUint32(exif, size, offset, big_endian);
      else std::cout << readExifUint32(exif, size, offset, big_endian);
    } else if(format == 5) {
      double n = readExifUint32(exif, size, offset, big_endian);
      double d = readExifUint32(exif, size, offset + 4, big_endian);
      std::cout << (n / d);
    } else if(format == 7 && len > 8 && exif[offset + 0] == 'A' && exif[offset + 1] == 'S' &&
              exif[offset + 2] == 'C' && exif[offset + 3] == 'I' && exif[offset + 4] == 'I') {
      for(size_t j = 8; j < len; j++) std::cout << exif[offset + j];
    } else if(format == 7 && len == 4 && tag_number == 36864) {
      for(size_t j = 0; j < len; j++) std::cout << exif[offset + j];
    } else if(format == 8) {
      std::cout << (int32_t)readExifUint16(exif, size, offset, big_endian);
    } else if(format == 9) {
      std::cout << (int16_t)readExifUint32(exif, size, offset, big_endian);
    } else if(format == 10) {
      double n = (int32_t)readExifUint32(exif, size, offset, big_endian);
      double d = (int32_t)readExifUint32(exif, size, offset + 4, big_endian);
      std::cout << (n / d);
    } else {
      // Formats like double not handled here
      std::cout << "[format " << format << ", len " << len << "]";
    }
    std::cout << std::endl;
  }
  if(pos + 4 > size) {
    std::cout << "EXIF IFD footer out of range" << std::endl;
    return;
  }
  size_t next_ifd = readExifUint32(exif, size, pos, big_endian);

  // The > checks are to guarantee progress rather than infinity recursion, though it does mean
  // that an odd EXIF that places later parts earlier in the file won't be supported correctly
  if(sub_ifd && sub_ifd > ifd_pos && sub_ifd != next_ifd) {
    showExifIFD(exif, size, sub_ifd, big_endian, is_thumbnail, true);
  }
  if(next_ifd && next_ifd > ifd_pos) {
    showExifIFD(exif, size, sub_ifd, big_endian, true, is_sub);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movl %r8d, -0xb8(%rbp)
movl %ecx, %eax
movl -0xb8(%rbp), %ecx
movl %eax, -0xb4(%rbp)
movq %rdx, %rax
movl -0xb4(%rbp), %edx
movq %rax, -0xb0(%rbp)
movq %rsi, %rax
movq -0xb0(%rbp), %rsi
movq %rax, -0xa8(%rbp)
movq %rdi, %r8
movq -0xa8(%rbp), %rdi
movb %r9b, %al
movq %r8, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
andb $0x1, %dl
movb %dl, -0x19(%rbp)
andb $0x1, %cl
movb %cl, -0x1a(%rbp)
andb $0x1, %al
movb %al, -0x1b(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x28(%rbp), %rax
addq $0x2, %rax
cmpq -0x10(%rbp), %rax
jbe 0x2fc0c
movq 0x173f0(%rip), %rdi     # 0x46fd0
leaq 0xb369(%rip), %rsi      # 0x3af50
callq 0x2250
movq %rax, %rdi
movq -0x28(%rbp), %rsi
callq 0x2080
movq %rax, %rdi
movq 0x173be(%rip), %rsi     # 0x46fc0
callq 0x22a0
jmp 0x30645
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
movb -0x19(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0x2fad0
movl %eax, %eax
movq %rax, -0x38(%rbp)
testb $0x1, -0x1b(%rbp)
je 0x2fc7f
movq 0x17398(%rip), %rdi     # 0x46fd0
leaq 0xb329(%rip), %rsi      # 0x3af68
callq 0x2250
movq %rax, %rdi
movq -0x28(%rbp), %rsi
callq 0x2080
movq %rax, %rdi
leaq 0xb31f(%rip), %rsi      # 0x3af79
callq 0x2250
movq %rax, %rdi
movq -0x38(%rbp), %rsi
callq 0x2080
movq %rax, %rdi
movq 0x1734b(%rip), %rsi     # 0x46fc0
callq 0x22a0
jmp 0x2fd1b
testb $0x1, -0x1a(%rbp)
je 0x2fcd0
movq 0x17344(%rip), %rdi     # 0x46fd0
leaq 0xb2f6(%rip), %rsi      # 0x3af89
callq 0x2250
movq %rax, %rdi
movq -0x28(%rbp), %rsi
callq 0x2080
movq %rax, %rdi
leaq 0xb2cb(%rip), %rsi      # 0x3af79
callq 0x2250
movq %rax, %rdi
movq -0x38(%rbp), %rsi
callq 0x2080
movq %rax, %rdi
movq 0x172f7(%rip), %rsi     # 0x46fc0
callq 0x22a0
jmp 0x2fd19
movq 0x172f9(%rip), %rdi     # 0x46fd0
leaq 0xb2c2(%rip), %rsi      # 0x3afa0
callq 0x2250
movq %rax, %rdi
movq -0x28(%rbp), %rsi
callq 0x2080
movq %rax, %rdi
leaq 0xb280(%rip), %rsi      # 0x3af79
callq 0x2250
movq %rax, %rdi
movq -0x38(%rbp), %rsi
callq 0x2080
movq %rax, %rdi
movq 0x172ac(%rip), %rsi     # 0x46fc0
callq 0x22a0
jmp 0x2fd1b
movq -0x28(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x30567
movq -0x28(%rbp), %rax
addq $0xc, %rax
cmpq -0x10(%rbp), %rax
jbe 0x2fd7e
movq 0x1727e(%rip), %rdi     # 0x46fd0
leaq 0xb254(%rip), %rsi      # 0x3afad
callq 0x2250
movq %rax, %rdi
movq -0x28(%rbp), %rsi
callq 0x2080
movq %rax, %rdi
movq 0x1724c(%rip), %rsi     # 0x46fc0
callq 0x22a0
jmp 0x30645
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
movb -0x19(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0x2fad0
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
addq $0x2, %rdx
movb -0x19(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0x2fad0
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
addq $0x4, %rdx
movb -0x19(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0x2fa00
movl %eax, -0x4c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
addq $0x8, %rdx
movb -0x19(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0x2fa00
movl %eax, -0x50(%rbp)
movl $0x1, -0x54(%rbp)
cmpl $0x3, -0x48(%rbp)
je 0x2fe0d
cmpl $0x8, -0x48(%rbp)
jne 0x2fe16
movl $0x2, -0x54(%rbp)
jmp 0x2fe4e
cmpl $0x4, -0x48(%rbp)
je 0x2fe28
cmpl $0x9, -0x48(%rbp)
je 0x2fe28
cmpl $0xb, -0x48(%rbp)
jne 0x2fe31
movl $0x4, -0x54(%rbp)
jmp 0x2fe4c
cmpl $0x5, -0x48(%rbp)
je 0x2fe43
cmpl $0xa, -0x48(%rbp)
je 0x2fe43
cmpl $0xc, -0x48(%rbp)
jne 0x2fe4a
movl $0x8, -0x54(%rbp)
jmp 0x2fe4c
jmp 0x2fe4e
movl -0x4c(%rbp), %eax
imull -0x54(%rbp), %eax
movl %eax, %eax
movq %rax, -0x60(%rbp)
cmpq $0x4, -0x60(%rbp)
ja 0x2fe6d
movq -0x28(%rbp), %rax
addq $0x8, %rax
movl %eax, -0x50(%rbp)
movq -0x28(%rbp), %rax
addq $0xc, %rax
movq %rax, -0x28(%rbp)
cmpl $0x1, -0x48(%rbp)
jb 0x2fe85
cmpl $0xc, -0x48(%rbp)
jbe 0x2feac
movq 0x17144(%rip), %rdi     # 0x46fd0
leaq 0xb138(%rip), %rsi      # 0x3afcb
callq 0x2250
movq %rax, %rdi
movq 0x1711e(%rip), %rsi     # 0x46fc0
callq 0x22a0
jmp 0x30645
testb $0x1, -0x1a(%rbp)
je 0x2fec7
movq 0x17117(%rip), %rdi     # 0x46fd0
leaq 0xb125(%rip), %rsi      # 0x3afe5
callq 0x2250
jmp 0x2feda
movq 0x17102(%rip), %rdi     # 0x46fd0
leaq 0xb127(%rip), %rsi      # 0x3affc
callq 0x2250
cmpl $0x100, -0x44(%rbp)     # imm = 0x100
jne 0x2fefb
movq 0x170e6(%rip), %rdi     # 0x46fd0
leaq 0xb116(%rip), %rsi      # 0x3b007
callq 0x2250
jmp 0x300f7
cmpl $0x101, -0x44(%rbp)     # imm = 0x101
jne 0x2ff1c
movq 0x170c5(%rip), %rdi     # 0x46fd0
leaq 0xb101(%rip), %rsi      # 0x3b013
callq 0x2250
jmp 0x300f5
cmpl $0x103, -0x44(%rbp)     # imm = 0x103
jne 0x2ff3d
movq 0x170a4(%rip), %rdi     # 0x46fd0
leaq 0xb0ed(%rip), %rsi      # 0x3b020
callq 0x2250
jmp 0x300f3
cmpl $0x10d, -0x44(%rbp)     # imm = 0x10D
jne 0x2ff5e
movq 0x17083(%rip), %rdi     # 0x46fd0
leaq 0xb0d8(%rip), %rsi      # 0x3b02c
callq 0x2250
jmp 0x300f1
cmpl $0x10e, -0x44(%rbp)     # imm = 0x10E
jne 0x2ff7f
movq 0x17062(%rip), %rdi     # 0x46fd0
leaq 0xb0c5(%rip), %rsi      # 0x3b03a
callq 0x2250
jmp 0x300ef
cmpl $0x112, -0x44(%rbp)     # imm = 0x112
jne 0x2ffa0
movq 0x17041(%rip), %rdi     # 0x46fd0
leaq 0xb0b6(%rip), %rsi      # 0x3b04c
callq 0x2250
jmp 0x300ed
cmpl $0x11a, -0x44(%rbp)     # imm = 0x11A
jne 0x2ffc1
movq 0x17020(%rip), %rdi     # 0x46fd0
leaq 0xb0a1(%rip), %rsi      # 0x3b058
callq 0x2250
jmp 0x300eb
cmpl $0x11b, -0x44(%rbp)     # imm = 0x11B
jne 0x2ffe2
movq 0x16fff(%rip), %rdi     # 0x46fd0
leaq 0xb08d(%rip), %rsi      # 0x3b065
callq 0x2250
jmp 0x300e9
cmpl $0x128, -0x44(%rbp)     # imm = 0x128
jne 0x30003
movq 0x16fde(%rip), %rdi     # 0x46fd0
leaq 0xb079(%rip), %rsi      # 0x3b072
callq 0x2250
jmp 0x300e7
cmpl $0x201, -0x44(%rbp)     # imm = 0x201
jne 0x30024
movq 0x16fbd(%rip), %rdi     # 0x46fd0
leaq 0xb068(%rip), %rsi      # 0x3b082
callq 0x2250
jmp 0x300e5
cmpl $0x202, -0x44(%rbp)     # imm = 0x202
jne 0x30045
movq 0x16f9c(%rip), %rdi     # 0x46fd0
leaq 0xb058(%rip), %rsi      # 0x3b093
callq 0x2250
jmp 0x300e3
cmpl $0x829a, -0x44(%rbp)    # imm = 0x829A
jne 0x30063
movq 0x16f7b(%rip), %rdi     # 0x46fd0
leaq 0xb046(%rip), %rsi      # 0x3b0a2
callq 0x2250
jmp 0x300e1
cmpl $0x8298, -0x44(%rbp)    # imm = 0x8298
jne 0x30081
movq 0x16f5d(%rip), %rdi     # 0x46fd0
leaq 0xb036(%rip), %rsi      # 0x3b0b0
callq 0x2250
jmp 0x300df
cmpl $0x9000, -0x44(%rbp)    # imm = 0x9000
jne 0x3009f
movq 0x16f3f(%rip), %rdi     # 0x46fd0
leaq 0xb022(%rip), %rsi      # 0x3b0ba
callq 0x2250
jmp 0x300dd
cmpl $0x9286, -0x44(%rbp)    # imm = 0x9286
jne 0x300bd
movq 0x16f21(%rip), %rdi     # 0x46fd0
leaq 0xb011(%rip), %rsi      # 0x3b0c7
callq 0x2250
jmp 0x300db
movq 0x16f0c(%rip), %rdi     # 0x46fd0
leaq 0xa470(%rip), %rsi      # 0x3a53b
callq 0x2250
movq %rax, %rdi
movl -0x44(%rbp), %esi
callq 0x2340
jmp 0x300dd
jmp 0x300df
jmp 0x300e1
jmp 0x300e3
jmp 0x300e5
jmp 0x300e7
jmp 0x300e9
jmp 0x300eb
jmp 0x300ed
jmp 0x300ef
jmp 0x300f1
jmp 0x300f3
jmp 0x300f5
jmp 0x300f7
movq 0x16ed2(%rip), %rdi     # 0x46fd0
leaq 0xaef4(%rip), %rsi      # 0x3aff9
callq 0x2250
movl -0x50(%rbp), %eax
addq -0x60(%rbp), %rax
cmpq -0x10(%rbp), %rax
jbe 0x3013e
movq 0x16eb2(%rip), %rdi     # 0x46fd0
leaq 0xafaf(%rip), %rsi      # 0x3b0d4
callq 0x2250
movq %rax, %rdi
movq 0x16e8c(%rip), %rsi     # 0x46fc0
callq 0x22a0
jmp 0x30645
cmpq $0x0, -0x60(%rbp)
jne 0x3016c
movq 0x16e84(%rip), %rdi     # 0x46fd0
leaq 0xaf98(%rip), %rsi      # 0x3b0eb
callq 0x2250
movq %rax, %rdi
movq 0x16e5e(%rip), %rsi     # 0x46fc0
callq 0x22a0
jmp 0x30556
cmpl $0x1, -0x48(%rbp)
jne 0x3018e
movq -0x8(%rbp), %rax
movl -0x50(%rbp), %ecx
movzbl (%rax,%rcx), %esi
movq 0x16e4c(%rip), %rdi     # 0x46fd0
callq 0x2340
jmp 0x30543
cmpl $0x2, -0x48(%rbp)
jne 0x301e7
movq $0x0, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x60(%rbp), %rax
jae 0x301e2
movq -0x8(%rbp), %rax
movl -0x50(%rbp), %ecx
addq -0x68(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
jne 0x301b9
jmp 0x301e2
movq -0x8(%rbp), %rax
movl -0x50(%rbp), %ecx
addq -0x68(%rbp), %rcx
movq 0x16e05(%rip), %rdi     # 0x46fd0
movzbl (%rax,%rcx), %esi
callq 0x23a0
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x3019c
jmp 0x30541
cmpl $0x3, -0x48(%rbp)
jne 0x3021a
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x50(%rbp), %eax
movl %eax, %edx
movb -0x19(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0x2fad0
movl %eax, %esi
movq 0x16dc0(%rip), %rdi     # 0x46fd0
callq 0x2340
jmp 0x3053f
cmpl $0x4, -0x48(%rbp)
jne 0x30278
cmpl $0x8769, -0x44(%rbp)    # imm = 0x8769
jne 0x3024b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x50(%rbp), %eax
movl %eax, %edx
movb -0x19(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0x2fa00
movl %eax, %eax
movq %rax, -0x30(%rbp)
jmp 0x30273
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x50(%rbp), %eax
movl %eax, %edx
movb -0x19(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0x2fa00
movl %eax, %esi
movq 0x16d62(%rip), %rdi     # 0x46fd0
callq 0x2340
jmp 0x3053d
cmpl $0x5, -0x48(%rbp)
jne 0x302e6
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x50(%rbp), %eax
movl %eax, %edx
movzbl -0x19(%rbp), %ecx
andl $0x1, %ecx
callq 0x2fa00
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x50(%rbp), %eax
addl $0x4, %eax
movl %eax, %edx
movzbl -0x19(%rbp), %ecx
andl $0x1, %ecx
callq 0x2fa00
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x70(%rbp), %xmm0
divsd -0x78(%rbp), %xmm0
movq 0x16cf4(%rip), %rdi     # 0x46fd0
callq 0x2450
jmp 0x3053b
cmpl $0x7, -0x48(%rbp)
jne 0x303a8
cmpq $0x8, -0x60(%rbp)
jbe 0x303a8
movq -0x8(%rbp), %rax
movl -0x50(%rbp), %ecx
addl $0x0, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x41, %eax
jne 0x303a8
movq -0x8(%rbp), %rax
movl -0x50(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x53, %eax
jne 0x303a8
movq -0x8(%rbp), %rax
movl -0x50(%rbp), %ecx
addl $0x2, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x43, %eax
jne 0x303a8
movq -0x8(%rbp), %rax
movl -0x50(%rbp), %ecx
addl $0x3, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x49, %eax
jne 0x303a8
movq -0x8(%rbp), %rax
movl -0x50(%rbp), %ecx
addl $0x4, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x49, %eax
jne 0x303a8
movq $0x8, -0x80(%rbp)
movq -0x80(%rbp), %rax
cmpq -0x60(%rbp), %rax
jae 0x303a3
movq -0x8(%rbp), %rax
movl -0x50(%rbp), %ecx
addq -0x80(%rbp), %rcx
movq 0x16c44(%rip), %rdi     # 0x46fd0
movzbl (%rax,%rcx), %esi
callq 0x23a0
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0x30370
jmp 0x30539
cmpl $0x7, -0x48(%rbp)
jne 0x3040d
cmpq $0x4, -0x60(%rbp)
jne 0x3040d
cmpl $0x9000, -0x44(%rbp)    # imm = 0x9000
jne 0x3040d
movq $0x0, -0x88(%rbp)
movq -0x88(%rbp), %rax
cmpq -0x60(%rbp), %rax
jae 0x30408
movq -0x8(%rbp), %rax
movl -0x50(%rbp), %ecx
addq -0x88(%rbp), %rcx
movq 0x16be5(%rip), %rdi     # 0x46fd0
movzbl (%rax,%rcx), %esi
callq 0x23a0
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
jmp 0x303c9
jmp 0x30537
cmpl $0x8, -0x48(%rbp)
jne 0x30440
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x50(%rbp), %eax
movl %eax, %edx
movb -0x19(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0x2fad0
movl %eax, %esi
movq 0x16b9a(%rip), %rdi     # 0x46fd0
callq 0x2420
jmp 0x30535
cmpl $0x9, -0x48(%rbp)
jne 0x30474
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x50(%rbp), %eax
movl %eax, %edx
movb -0x19(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0x2fa00
movq 0x16b69(%rip), %rdi     # 0x46fd0
movswl %ax, %esi
callq 0x2220
jmp 0x30533
cmpl $0xa, -0x48(%rbp)
jne 0x304e9
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x50(%rbp), %eax
movl %eax, %edx
movb -0x19(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0x2fa00
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x90(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x50(%rbp), %eax
addl $0x4, %eax
movl %eax, %eax
movl %eax, %edx
movb -0x19(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0x2fa00
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x90(%rbp), %xmm0
divsd -0x98(%rbp), %xmm0
movq 0x16aee(%rip), %rdi     # 0x46fd0
callq 0x2450
jmp 0x30531
movq 0x16ae0(%rip), %rdi     # 0x46fd0
leaq 0xabfc(%rip), %rsi      # 0x3b0f3
callq 0x2250
movq %rax, %rdi
movl -0x48(%rbp), %esi
callq 0x2340
movq %rax, %rdi
leaq 0xabeb(%rip), %rsi      # 0x3b0fc
callq 0x2250
movq %rax, %rdi
movq -0x60(%rbp), %rsi
callq 0x2080
movq %rax, %rdi
leaq 0x942e(%rip), %rsi      # 0x3995a
callq 0x2250
jmp 0x30533
jmp 0x30535
jmp 0x30537
jmp 0x30539
jmp 0x3053b
jmp 0x3053d
jmp 0x3053f
jmp 0x30541
jmp 0x30543
movq 0x16a86(%rip), %rdi     # 0x46fd0
movq 0x16a6f(%rip), %rsi     # 0x46fc0
callq 0x22a0
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x2fd2f
movq -0x28(%rbp), %rax
addq $0x4, %rax
cmpq -0x10(%rbp), %rax
jbe 0x3059c
movq 0x16a54(%rip), %rdi     # 0x46fd0
leaq 0xab80(%rip), %rsi      # 0x3b103
callq 0x2250
movq %rax, %rdi
movq 0x16a2e(%rip), %rsi     # 0x46fc0
callq 0x22a0
jmp 0x30645
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
movb -0x19(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0x2fa00
movl %eax, %eax
movq %rax, -0xa0(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x30605
movq -0x30(%rbp), %rax
cmpq -0x18(%rbp), %rax
jbe 0x30605
movq -0x30(%rbp), %rax
cmpq -0xa0(%rbp), %rax
je 0x30605
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
movb -0x19(%rbp), %cl
movb -0x1a(%rbp), %al
movl $0x1, %r9d
andb $0x1, %cl
andb $0x1, %al
movzbl %cl, %ecx
movzbl %al, %r8d
callq 0x2fb50
cmpq $0x0, -0xa0(%rbp)
je 0x30645
movq -0xa0(%rbp), %rax
cmpq -0x18(%rbp), %rax
jbe 0x30645
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
movb -0x19(%rbp), %cl
movb -0x1b(%rbp), %al
movl $0x1, %r8d
andb $0x1, %cl
andb $0x1, %al
movzbl %cl, %ecx
movzbl %al, %r9d
callq 0x2fb50
addq $0xc0, %rsp
popq %rbp
retq
nop