LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/lvandeve[P]lodepng/pngdetail.cpp
// Function: showError(Data&, Options const&)
void showError(Data& data, const Options& options) {
  std::cout << (options.use_hex ? std::hex: std::dec);
  std::string prefix = (options.use_hex ? "0x": "");
  if(!data.error) {
    std::cout << "No error" << std::endl;
  }
  std::cout << "Decoding error " << prefix << data.error << ": " << lodepng_error_text(data.error) << std::endl;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x3ed7(%rip), %rax      # 0x190b2
leaq 0x3ee0(%rip), %rcx      # 0x190c2
cmpb $0x0, 0x24(%rsi)
cmovneq %rax, %rcx
movq 0x11ddf(%rip), %rdi     # 0x26fd0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
callq *%rcx
leaq 0x987f(%rip), %rax      # 0x1ea80
leaq 0xa01c(%rip), %rsi      # 0x1f224
cmpb $0x0, 0x24(%r14)
cmovneq %rax, %rsi
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x20b0
cmpl $0x0, 0x2d8(%rbx)
jne 0x15244
movq 0x11da0(%rip), %rdi     # 0x26fd0
leaq 0x984c(%rip), %rsi      # 0x1ea83
callq 0x2210
movq %rax, %rdi
callq 0x2100
movq 0x11d85(%rip), %rdi     # 0x26fd0
leaq 0x983a(%rip), %rsi      # 0x1ea8c
callq 0x2210
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x21e0
movl 0x2d8(%rbx), %esi
movq %rax, %rdi
callq 0x2150
leaq 0xa0e3(%rip), %rsi      # 0x1f35c
movq %rax, %rdi
callq 0x2210
movq %rax, %r14
movl 0x2d8(%rbx), %edi
callq 0xb599
movq %r14, %rdi
movq %rax, %rsi
callq 0x2210
movq %rax, %rdi
callq 0x2100
leaq 0x8(%rsp), %rdi
callq 0x22a0
addq $0x28, %rsp
popq %rbx
popq %r14
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x22a0
movq %rbx, %rdi
callq 0x23a0
movq %rax, %rdi
callq 0xe69c
// File: /workspace/github_cpp_makefile_star2_O2/lvandeve[P]lodepng/pngdetail.cpp
// Function: showSingleLineSummary(Data&, Options const&)
void showSingleLineSummary(Data& data, const Options& options) {
  data.loadInspect();
  if(data.error && data.error != 57) return; // CRC error (57) ignored here for parsing of header only
  std::cout << (options.use_hex ? std::hex: std::dec);
  std::cout << "Filesize: " << data.buffer.size() << " (" << data.buffer.size() / 1024 << "K)";
  if(data.is_icc) {
    std::cout << ", not a PNG but an ICC profile, use -i to expand ICC profile info." << std::endl;
    return;
  }
  if(data.is_exif) {
    std::cout << ", not a PNG but an EXIF file, use -e to expand EXIF file info." << std::endl;
    return;
  }

  std::cout << ", " << data.w << "x" << data.h << ", ";
  std::cout << "Color: " << colorTypeString(data.state.info_png.color.colortype) << ", " << data.state.info_png.color.bitdepth << " bit" << std::endl;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rsi, %r14
movq %rdi, %rbx
callq 0x18e38
movl 0x2d8(%rbx), %eax
cmpl $0x39, %eax
je 0x154b7
testl %eax, %eax
jne 0x1562b
leaq 0x3bf4(%rip), %rax      # 0x190b2
leaq 0x3bfd(%rip), %rcx      # 0x190c2
cmpb $0x0, 0x24(%r14)
cmovneq %rax, %rcx
movq 0x11afb(%rip), %r14     # 0x26fd0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
callq *%rcx
leaq 0x96c9(%rip), %rsi      # 0x1ebb1
movq %r14, %rdi
callq 0x2210
movq 0x28(%rbx), %rsi
subq 0x20(%rbx), %rsi
movq %rax, %rdi
callq 0x2150
leaq 0x9bea(%rip), %rsi      # 0x1f0f1
movq %rax, %rdi
callq 0x2210
movq 0x28(%rbx), %rsi
subq 0x20(%rbx), %rsi
shrq $0xa, %rsi
movq %rax, %rdi
callq 0x2150
leaq 0x9692(%rip), %rsi      # 0x1ebbc
movq %rax, %rdi
callq 0x2210
cmpb $0x1, 0x2de(%rbx)
jne 0x1554b
movq 0x11a8e(%rip), %rdi     # 0x26fd0
leaq 0x9676(%rip), %rsi      # 0x1ebbf
jmp 0x15562
cmpb $0x1, 0x2df(%rbx)
jne 0x15578
movq 0x11a75(%rip), %rdi     # 0x26fd0
leaq 0x96a0(%rip), %rsi      # 0x1ec02
callq 0x2210
movq %rax, %rdi
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0x2100
movq 0x11a51(%rip), %r14     # 0x26fd0
leaq 0x975e(%rip), %r15      # 0x1ece4
movq %r14, %rdi
movq %r15, %rsi
callq 0x2210
movl 0x50(%rbx), %esi
movq %rax, %rdi
callq 0x2150
leaq 0x9fa5(%rip), %rsi      # 0x1f548
movq %rax, %rdi
callq 0x2210
movl 0x54(%rbx), %esi
movq %rax, %rdi
callq 0x2150
movq %rax, %rdi
movq %r15, %rsi
callq 0x2210
leaq 0x9679(%rip), %rsi      # 0x1ec41
movq %r14, %rdi
callq 0x2210
movq %rax, %r14
movl 0x138(%rbx), %esi
movq %rsp, %r15
movq %r15, %rdi
callq 0x132ef
movq %r14, %rdi
movq %r15, %rsi
callq 0x21e0
leaq 0x96ee(%rip), %rsi      # 0x1ece4
movq %rax, %rdi
callq 0x2210
movl 0x13c(%rbx), %esi
movq %rax, %rdi
callq 0x2150
leaq 0x9636(%rip), %rsi      # 0x1ec49
movq %rax, %rdi
callq 0x2210
movq %rax, %rdi
callq 0x2100
movq %rsp, %rdi
callq 0x22a0
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
movq %rsp, %rdi
callq 0x22a0
movq %rbx, %rdi
callq 0x23a0
movq %rax, %rdi
callq 0xe69c
// File: /workspace/github_cpp_makefile_star2_O2/lvandeve[P]lodepng/pngdetail.cpp
// Function: printableICCWord[abi:cxx11](unsigned char const*, unsigned long, unsigned long)
static std::string printableICCWord(const unsigned char* icc, size_t size, size_t pos) {
  if (pos + 4 > size) {
    return "out of range";
  }
  std::string result;
  for (int i = 0; i < 4; i++) {
    char c = icc[pos + i];
    result += ((c >= 32 && c < 127) ? c : '?');
  }
  return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x4(%rcx), %rax
cmpq %rdx, %rax
jbe 0x16593
leaq 0x8ec9(%rip), %rsi      # 0x1f441
leaq 0x7(%rsp), %rdx
movq %rbx, %rdi
callq 0x20b0
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %r14
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
andq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
addq %rcx, %r14
xorl %r15d, %r15d
pushq $0x3f
popq %rbp
cmpq $0x4, %r15
je 0x16585
movzbl (%r14,%r15), %eax
leal -0x20(%rax), %ecx
cmpb $0x5f, %cl
jb 0x165c4
movl %ebp, %eax
movsbl %al, %esi
movq %rbx, %rdi
callq 0x21c0
incq %r15
jmp 0x165af
movq %rax, %r14
movq %rbx, %rdi
callq 0x22a0
movq %r14, %rdi
callq 0x23a0
movq %rax, %rdi
callq 0xe69c
// File: /workspace/github_cpp_makefile_star2_O2/lvandeve[P]lodepng/pngdetail.cpp
// Function: showHex(unsigned char const*, unsigned long, Options const&)
void showHex(const unsigned char* data, size_t size, const Options& options) {
  for(size_t i = 0; i < size; i++) {
    unsigned char c = data[i];
    if(options.hexformat == HF_BIN) {
      printf("%c", c);
    } else {
      if(c > 32 && c < 127 && options.hexformat == HF_MIX) printf(" %c ", c);
      else printf("%02x ", c);
      if(i % 32 == 31 && i + 1 != size) std::cout << std::endl;
    }
  }
  if(options.hexformat != HF_BIN) std::cout << std::endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x8861(%rip), %r13      # 0x1eeb9
leaq 0x885f(%rip), %rbp      # 0x1eebe
xorl %r12d, %r12d
cmpq %r14, %r12
je 0x166c0
movzbl (%r15,%r12), %esi
movl 0x10(%rbx), %eax
cmpl $0x2, %eax
jne 0x16680
movl %esi, %edi
callq 0x22d0
incq %r12
jmp 0x16662
movq %r13, %rdi
cmpl $0x1, %eax
je 0x1668b
movq %rbp, %rdi
leal -0x21(%rsi), %eax
cmpb $0x5e, %al
cmovaeq %rbp, %rdi
xorl %eax, %eax
callq 0x2050
movl %r12d, %eax
notl %eax
testb $0x1f, %al
setne %al
incq %r12
cmpq %r14, %r12
sete %cl
orb %al, %cl
jne 0x16662
movq 0x10917(%rip), %rdi     # 0x26fd0
callq 0x2100
jmp 0x16662
cmpl $0x2, 0x10(%rbx)
jne 0x166d5
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x108f4(%rip), %rdi     # 0x26fd0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2100
// File: /workspace/github_cpp_makefile_star2_O2/lvandeve[P]lodepng/pngdetail.cpp
// Function: shortenText(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, Options const&)
std::string shortenText(const std::string& text, const Options& options) {
  if(options.expand_long_texts) return text;
  size_t maxlen = 512;
  size_t maxnl = options.verbose ? 5 : 1;
  size_t numnl = 0; // amount of newlines
  for(size_t i = 0; i < text.size(); i++) {
    if(text[i] == 10) numnl++;
    if(numnl >= maxnl) {
      maxlen = i;
      break;
    }
  }

  if(text.size() < maxlen) return text;

  return text.substr(0, maxlen) + (numnl > 1 ? "\n" : "") + "... [TEXT SNIPPED! use -t to expand long text]";
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x40, %rsp
movq %rdi, %rbx
cmpb $0x1, 0x1(%rdx)
je 0x1712e
movzbl (%rdx), %eax
leaq 0x1(,%rax,4), %rdx
movq (%rsi), %rdi
movq 0x8(%rsi), %rax
xorl %r15d, %r15d
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x17124
xorl %r8d, %r8d
cmpb $0xa, (%rdi,%rcx)
sete %r8b
addq %r8, %r15
cmpq %rdx, %r15
jae 0x17129
incq %rcx
jmp 0x17107
movl $0x200, %ecx            # imm = 0x200
cmpq %rcx, %rax
jae 0x17138
movq %rbx, %rdi
callq 0x22c0
jmp 0x1718c
leaq 0x20(%rsp), %r14
movq %r14, %rdi
xorl %edx, %edx
callq 0x2240
cmpq $0x2, %r15
leaq 0x80d1(%rip), %rax      # 0x1f223
leaq 0x80cb(%rip), %rdx      # 0x1f224
cmovaeq %rax, %rdx
movq %rsp, %rdi
movq %r14, %rsi
callq 0x19395
leaq 0x8024(%rip), %rdx      # 0x1f193
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x19395
movq %rsp, %rdi
callq 0x22a0
leaq 0x20(%rsp), %rdi
callq 0x22a0
movq %rbx, %rax
addq $0x40, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
movq %rsp, %rdi
callq 0x22a0
jmp 0x171a9
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x22a0
movq %rbx, %rdi
callq 0x23a0
movq %rax, %rdi
callq 0xe69c
// File: /workspace/github_cpp_makefile_star2_O2/lvandeve[P]lodepng/pngdetail.cpp
// Function: readExifUint32(unsigned char const*, unsigned long, unsigned long, bool)
uint32_t readExifUint32(const unsigned char* exif, size_t size, size_t pos, bool big_endian) {
  if(pos + 4 > size) return 0;
  if(big_endian) {
    return ((uint32_t)exif[pos + 0] << 24u) | ((uint32_t)exif[pos + 1] << 16u) | ((uint32_t)exif[pos + 2] << 8u) | (uint32_t)exif[pos + 3];
  } else {
    return ((uint32_t)exif[pos + 3] << 24u) | ((uint32_t)exif[pos + 2] << 16u) | ((uint32_t)exif[pos + 1] << 8u) | (uint32_t)exif[pos + 0];
  }
}

// Assembly:
leaq 0x4(%rdx), %r8
xorl %eax, %eax
cmpq %rsi, %r8
ja 0x17a11
testb %cl, %cl
je 0x17a0e
movl (%rdi,%rdx), %eax
bswapl %eax
retq
movl (%rdi,%rdx), %eax
retq
// File: /workspace/github_cpp_makefile_star2_O2/lvandeve[P]lodepng/pngdetail.cpp
// Function: readExifUint16(unsigned char const*, unsigned long, unsigned long, bool)
uint32_t readExifUint16(const unsigned char* exif, size_t size, size_t pos, bool big_endian) {
  if(pos + 2 > size) return 0;
  if(big_endian) {
    return ((uint32_t)exif[pos + 0] << 8u) | (uint32_t)exif[pos + 1];
  } else {
    return ((uint32_t)exif[pos + 1] << 8u) | (uint32_t)exif[pos + 0];
  }
}

// Assembly:
leaq 0x2(%rdx), %r8
xorl %eax, %eax
cmpq %rsi, %r8
ja 0x17a31
testb %cl, %cl
je 0x17a2d
movzwl (%rdi,%rdx), %eax
rolw $0x8, %ax
movzwl %ax, %eax
retq
movzwl (%rdi,%rdx), %eax
retq
// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r14
pushq %rbx
movq %rdi, %r14
callq 0x18e38
cmpl $0x0, 0x2d8(%r14)
je 0x182e1
popq %rbx
popq %r14
popq %rbp
retq
cmpl $0x0, 0x1b0(%r14)
je 0x1831b
movl 0x1c0(%r14), %ebx
cmpq $0x7, %rbx
ja 0x1832b
movq 0xecd1(%rip), %rdi      # 0x26fd0
leaq 0x71a4(%rip), %rsi      # 0x1f4aa
callq 0x2210
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2150
jmp 0x183af
movq 0xecae(%rip), %rdi      # 0x26fd0
leaq 0x715a(%rip), %rsi      # 0x1f483
jmp 0x183aa
movq 0x1b8(%r14), %r14
movq 0xec97(%rip), %rdi      # 0x26fd0
leaq 0x7180(%rip), %rsi      # 0x1f4c0
callq 0x2210
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2150
movq %rax, %rdi
callq 0x2100
movzbl (%r14), %eax
cmpl $0x49, %eax
je 0x18387
cmpl $0x4d, %eax
jne 0x1839c
cmpb $0x4d, 0x1(%r14)
jne 0x1839c
cmpb $0x0, 0x2(%r14)
jne 0x1839c
cmpb $0x2a, 0x3(%r14)
jne 0x1839c
movb $0x1, %bpl
leaq 0x7147(%rip), %rsi      # 0x1f4cc
jmp 0x183c4
cmpb $0x49, 0x1(%r14)
jne 0x1839c
cmpb $0x2a, 0x2(%r14)
jne 0x1839c
cmpb $0x0, 0x3(%r14)
je 0x183bb
movq 0xec2d(%rip), %rdi      # 0x26fd0
leaq 0x716b(%rip), %rsi      # 0x1f515
callq 0x2210
movq %rax, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x2100
leaq 0x712d(%rip), %rsi      # 0x1f4ef
xorl %ebp, %ebp
movq 0xec05(%rip), %rdi      # 0x26fd0
callq 0x2210
movq %rax, %rdi
callq 0x2100
movzbl %bpl, %ebp
pushq $0x4
popq %rdx
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %ecx
callq 0x179f9
movl %eax, %edx
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
popq %rbx
popq %r14
popq %rbp
jmp 0x17a32
// File: /workspace/github_cpp_makefile_star2_O2/lvandeve[P]lodepng/pngdetail.cpp
// Function: showRender(Data&, Options const&)
void showRender(Data& data, const Options& options) {
  data.loadPixels();
  if(data.error) return;
  if(options.rendermode == RM_ASCII) {
    displayAsciiArt(data.pixels, data.w, data.h, options.rendersize);
  }

  if(options.rendermode == RM_HEX) {
    displayColorsHex(data.pixels, data.w, data.h, false);
  }

  if(options.rendermode == RM_HEX16) {
    displayColorsHex(data.pixels, data.w, data.h, true);
  }

  if(options.rendermode == RM_PAL) {
    displayPalettePixels(data.buffer, options);
  }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
callq 0x19322
cmpl $0x0, 0x2d8(%r14)
jne 0x1848e
movl 0x18(%rbx), %eax
testl %eax, %eax
jne 0x1843c
leaq 0x38(%r14), %rdi
movl 0x50(%r14), %esi
movl 0x54(%r14), %edx
movl 0x1c(%rbx), %ecx
callq 0x141ca
movl 0x18(%rbx), %eax
cmpl $0x1, %eax
jne 0x18457
leaq 0x38(%r14), %rdi
movl 0x50(%r14), %esi
movl 0x54(%r14), %edx
xorl %ecx, %ecx
callq 0x14448
movl 0x18(%rbx), %eax
cmpl $0x2, %eax
jne 0x18473
leaq 0x38(%r14), %rdi
movl 0x50(%r14), %esi
movl 0x54(%r14), %edx
pushq $0x1
popq %rcx
callq 0x14448
movl 0x18(%rbx), %eax
cmpl $0x3, %eax
jne 0x1848e
addq $0x20, %r14
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x14988
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/lvandeve[P]lodepng/pngdetail.cpp
// Function: showInfos(Data&, Options const&)
void showInfos(Data& data, const Options& options) {
  if(options.show_one_line_summary) showSingleLineSummary(data, options);
  if(options.show_errors) showErrors(data, options);
  if(options.show_exif) showExif(data);
  if(options.show_header || options.show_icc_details || options.show_icc_hex || options.show_exif_hex) showHeaderInfo(data, options);
  if(options.show_color_stats) showColorStats(data, options);
  if(options.show_png_info) showPNGInfo(data, options);
  if(options.show_palette) displayPalette(data, options);
  if(options.show_chunks || options.show_chunks2) displayChunkNames(data, options);
  if(options.show_filters) displayFilterTypes(data, options);
  if(options.show_zlib_info) printZlibInfo(data);
  if(options.show_render) showRender(data, options);

  if(data.error) showError(data, options);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
cmpb $0x1, 0x2(%rsi)
jne 0x184b1
movq %r14, %rdi
movq %rbx, %rsi
callq 0x15490
cmpb $0x1, 0x4(%rbx)
jne 0x184c2
movq %r14, %rdi
movq %rbx, %rsi
callq 0x17980
cmpb $0x1, 0x7(%rbx)
jne 0x184d0
movq %r14, %rdi
callq 0x182c6
cmpb $0x0, 0x3(%rbx)
jne 0x184e8
cmpb $0x0, 0x5(%rbx)
jne 0x184e8
cmpb $0x0, 0x6(%rbx)
jne 0x184e8
cmpb $0x1, 0x8(%rbx)
jne 0x184f3
movq %r14, %rdi
movq %rbx, %rsi
callq 0x166ef
cmpb $0x1, 0x9(%rbx)
jne 0x18504
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1753b
cmpb $0x1, 0xa(%rbx)
jne 0x18515
movq %r14, %rdi
movq %rbx, %rsi
callq 0x171c3
cmpb $0x1, 0xb(%rbx)
jne 0x18526
movq %r14, %rdi
movq %rbx, %rsi
callq 0x147fb
cmpb $0x0, 0x20(%rbx)
jne 0x18532
cmpb $0x1, 0x21(%rbx)
jne 0x1853d
movq %r14, %rdi
movq %rbx, %rsi
callq 0x133cb
cmpb $0x1, 0x22(%rbx)
jne 0x1854e
movq %r14, %rdi
movq %rbx, %rsi
callq 0x14651
cmpb $0x1, 0x23(%rbx)
jne 0x1855c
movq %r14, %rdi
callq 0x14c01
cmpb $0x1, 0x14(%rbx)
jne 0x1856d
movq %r14, %rdi
movq %rbx, %rsi
callq 0x18405
cmpl $0x0, 0x2d8(%r14)
je 0x18589
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x151c7
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/lvandeve[P]lodepng/pngdetail.cpp
// Function: Data::loadFile()
void loadFile() {
    if(buffer.empty()) {
      error = lodepng::load_file(buffer, filename); //load the image file with given filename
    } else {
      error = 0; // for reloadpixels, reset error if file was already successfully loaded
    }
  }

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x20(%rdi), %rcx
xorl %eax, %eax
cmpq 0x28(%rdi), %rcx
jne 0x190aa
leaq 0x20(%rbx), %rdi
movq %rbx, %rsi
callq 0xb5b7
movl %eax, 0x2d8(%rbx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/lvandeve[P]lodepng/pngdetail.cpp
// Function: Data::reloadPixels()
void reloadPixels() {
    loadFile();
    if(error) return;
    inspected = true;
    state.info_raw.colortype = LCT_RGBA;
    state.info_raw.bitdepth = 16;
    pixels.clear();
    error = lodepng::decode(pixels, w, h, state, buffer);
  }

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x1908e
cmpl $0x0, 0x2d8(%rbx)
jne 0x19389
movb $0x1, 0x2dc(%rbx)
leaq 0x58(%rbx), %rcx
movabsq $0x1000000006, %rax     # imm = 0x1000000006
movq %rax, 0x100(%rbx)
leaq 0x38(%rbx), %rdi
movq 0x38(%rbx), %rax
cmpq %rax, 0x40(%rbx)
je 0x19372
movq %rax, 0x40(%rbx)
leaq 0x50(%rbx), %rsi
leaq 0x54(%rbx), %rdx
leaq 0x20(%rbx), %r8
callq 0xb9bf
movl %eax, 0x2d8(%rbx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/lvandeve[P]lodepng/pngdetail.cpp
// Function: Data::isIcc()
bool isIcc() {
    if(isPng()) return false;
    if(buffer.size() < 128) return false;
    size_t size = (buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3];
    if(size != buffer.size()) return false;
    if(buffer[36] != 'a') return false;
    if(buffer[37] != 'c') return false;
    if(buffer[38] != 's') return false;
    if(buffer[39] != 'p') return false;
    return true;
  }

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x19242
testb %al, %al
jne 0x19565
movq 0x20(%rbx), %rax
movq 0x28(%rbx), %rcx
subq %rax, %rcx
cmpq $0x80, %rcx
jb 0x19565
movzbl (%rax), %edx
shll $0x18, %edx
movzbl 0x1(%rax), %esi
shll $0x10, %esi
movslq %edx, %rdx
orq %rsi, %rdx
movzbl 0x2(%rax), %esi
shll $0x8, %esi
orq %rdx, %rsi
movzbl 0x3(%rax), %edx
orq %rsi, %rdx
cmpq %rdx, %rcx
jne 0x19565
cmpb $0x61, 0x24(%rax)
jne 0x19565
cmpb $0x63, 0x25(%rax)
jne 0x19565
cmpb $0x73, 0x26(%rax)
jne 0x19565
cmpb $0x70, 0x27(%rax)
sete %al
jmp 0x19567
xorl %eax, %eax
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/zengfenfei[P]codility/src/BinaryGap.cpp
// Function: solution(int)
int solution(int N) {
	int len = sizeof(N) * 8;
	int max0s = 0, cur0s = -1;
	for (int i = 0; i < len; ++i) {
		int bit = N & (1 << i);
		if (bit > 0) {	// bit is 1
			if (cur0s > max0s) {
				max0s = cur0s;
			}
			cur0s = 0;
		} else if (cur0s > -1) {
			cur0s++;
		}
	}
	return max0s;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
xorl %ecx, %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x1, %esi
xorl %eax, %eax
cmpl $0x20, %ecx
je 0x11e8
movl %esi, %r8d
shll %cl, %r8d
testl %edi, %r8d
jle 0x11d7
cmpl %eax, %edx
cmovgl %edx, %eax
xorl %edx, %edx
jmp 0x11e4
movl %edx, %r8d
notl %r8d
shrl $0x1f, %r8d
addl %r8d, %edx
incl %ecx
jmp 0x11be
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/sidvishnoi[P]filesystem-assignment/main.cpp
// Function: main
int main(int argc, char const *argv[])
{
    string diskTitle;
    int diskSizeBytes;

    // get disk title
    if (argc > 1 && argv[1]) {
        diskTitle = argv[1];
    } else {
        cout << "Enter path to disk: ";
        cin >> diskTitle;
    }

    // initialize disk
    FileSystem disk(diskTitle);

    cout << "Type `help` to see available commands." << endl;

    int response = handleInput(disk);
    while (response != 1) {
        response = handleInput(disk);
    }
    return 0;
}

// Assembly:
pushq %rbx
subq $0xc0, %rsp
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
cmpl $0x2, %edi
jl 0x283d
movq 0x8(%rsi), %rsi
testq %rsi, %rsi
je 0x283d
movq %rsp, %rdi
callq 0x2370
jmp 0x285f
movq 0x578c(%rip), %rdi      # 0x7fd0
leaq 0x27b9(%rip), %rsi      # 0x5004
callq 0x21c0
movq 0x5789(%rip), %rdi      # 0x7fe0
movq %rsp, %rsi
callq 0x2240
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x2280
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x3a48
leaq 0x20(%rsp), %rdi
callq 0x20b0
movq 0x5744(%rip), %rdi      # 0x7fd0
leaq 0x2786(%rip), %rsi      # 0x5019
callq 0x21c0
movq %rax, %rdi
callq 0x20e0
leaq 0x40(%rsp), %rdi
callq 0x2b1a
leaq 0x40(%rsp), %rbx
cmpl $0x1, %eax
je 0x28be
movq %rbx, %rdi
callq 0x2b1a
jmp 0x28af
leaq 0x40(%rsp), %rdi
callq 0x2912
movq %rsp, %rdi
callq 0x20b0
xorl %eax, %eax
addq $0xc0, %rsp
popq %rbx
retq
jmp 0x28f5
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x20b0
jmp 0x2902
jmp 0x28ee
movq %rax, %rbx
jmp 0x2902
jmp 0x28f5
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x2912
movq %rsp, %rdi
callq 0x20b0
movq %rbx, %rdi
callq 0x2340
// File: /workspace/github_cpp_makefile_star2_O2/sidvishnoi[P]filesystem-assignment/handleInput.cpp
// Function: split(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, char)
vector<string> split(const string &s, const char delim) {
    /*
    castective: to split a string by given delimitter
    input:
        s: given string
        delim: delimitter
    return: vector of strings split at given delimitter
    */
    stringstream ss(s);
    string item;
    vector<string> tokens;
    while (getline(ss, item, delim)) {
        tokens.push_back(item);
    }
    return tokens;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movl %edx, %ebp
movq %rdi, %rbx
leaq 0x20(%rsp), %r14
pushq $0x18
popq %rdx
movq %r14, %rdi
callq 0x22d0
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
andq $0x0, 0x10(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movsbl %bpl, %ebp
movq %rsp, %r15
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x2360
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2a61
movq %rbx, %rdi
movq %r15, %rsi
callq 0x36e8
jmp 0x2a39
movq %rsp, %rdi
callq 0x20b0
leaq 0x20(%rsp), %rdi
callq 0x2150
movq %rbx, %rax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq %rbx, %rdi
callq 0x293a
movq %rsp, %rdi
callq 0x20b0
leaq 0x20(%rsp), %rdi
callq 0x2150
movq %r14, %rdi
callq 0x2340
// File: /workspace/github_cpp_makefile_star2_O2/sidvishnoi[P]filesystem-assignment/handleInput.cpp
// Function: createBuffer(char, char*)
void createBuffer(char temp, char* buf) {
    // creates a buffer based on a char
    if (temp == '.') {
        cout << "Enter alphabet: ";
        cin >> temp;
        cin.ignore(32767, '\n');
    }
    for (int i = 0; i < kSectorSize_g; i++) {
        buf[i] = temp;
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movb %dil, 0xf(%rsp)
cmpb $0x2e, %dil
jne 0x2afd
movq 0x5509(%rip), %rdi      # 0x7fd0
leaq 0x25b2(%rip), %rsi      # 0x5080
callq 0x21c0
movq 0x5506(%rip), %r14      # 0x7fe0
leaq 0xf(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2270
pushq $0xa
popq %rdx
movl $0x7fff, %esi           # imm = 0x7FFF
movq %r14, %rdi
callq 0x2130
movb (%r15), %dil
xorl %eax, %eax
cmpq $0x200, %rax            # imm = 0x200
je 0x2b10
movb %dil, (%rbx,%rax)
incq %rax
jmp 0x2aff
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/sidvishnoi[P]filesystem-assignment/day1/FileSystem.cpp
// Function: FileSystem::FileSystem(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
FileSystem::FileSystem(string title)
        : diskTitle_k(title) {

    // check if disk doesn't exists or is empty
    //  and if exists, get it's size in bytes

    /* %%
    >> write a code to check whether the disk already exists or not by checking it's size (store size in diskSize_k)
    and update the boolean variable
        alreadyExists = true, if file with same name exists
        else false
    */
    // %% logic here
    bool alreadyExists; // %%;

    // get size if not exists
    if (!alreadyExists) {
        int diskSizeMB;
        cout << "Enter disk size in MiB : ";
        cin >> diskSizeMB;
        cin.ignore(32767, '\n');
        diskSize_k = 1024*1024*diskSizeMB;
    }

    /* %%
    how many sectors of each size sectorSize_k exist, if total disk size = diskSize_k
    >> update right hand value for numberOfSectors_k
    */
    numberOfSectors_k = -1;

    /* %%
    how many sectors need to be reserved, if each sector needs 4 bytes (sizeof int) to store a status?
    >> update right hand value for reservedSectors_k
    */
    reservedSectors_k = -1;

    // reserve space, if disk doesn't already exist
    if (!alreadyExists) createDisk();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf0, %rsp
movq %rdi, %rbx
callq 0x2280
movl $0x200, 0x20(%rbx)      # imm = 0x200
movl $0x2, 0x30(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rbx)
movups %xmm0, 0x48(%rbx)
movups %xmm0, 0x58(%rbx)
leaq 0x17f8(%rip), %rsi      # 0x527c
leaq 0x10(%rsp), %r14
leaq 0xf(%rsp), %rdx
movq %r14, %rdi
callq 0x3714
leaq 0x30(%rsp), %r15
leaq 0x17df(%rip), %rsi      # 0x5281
leaq 0xe(%rsp), %rdx
movq %r15, %rdi
callq 0x3714
leaq 0x50(%rsp), %r15
leaq 0x17cb(%rip), %rsi      # 0x5286
leaq 0xd(%rsp), %rdx
movq %r15, %rdi
callq 0x3714
leaq 0x70(%rsp), %r15
leaq 0x17bb(%rip), %rsi      # 0x528f
leaq 0xc(%rsp), %rdx
movq %r15, %rdi
callq 0x3714
leaq 0x90(%rsp), %r15
leaq 0x17a9(%rip), %rsi      # 0x5299
leaq 0xb(%rsp), %rdx
movq %r15, %rdi
callq 0x3714
leaq 0xb0(%rsp), %r15
leaq 0x1797(%rip), %rsi      # 0x52a3
leaq 0xa(%rsp), %rdx
movq %r15, %rdi
callq 0x3714
leaq 0xd0(%rsp), %r15
leaq 0x1783(%rip), %rsi      # 0x52ab
leaq 0x9(%rsp), %rdx
movq %r15, %rdi
callq 0x3714
leaq 0x68(%rbx), %rdi
leaq 0x10(%rsp), %rsi
pushq $0x7
popq %rdx
leaq 0x8(%rsp), %rcx
callq 0x3bda
movl $0xc0, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x10, %rdi
callq 0x20b0
addq $-0x20, %rbx
jmp 0x3b50
movq %rax, %r12
movl $0xc0, %r13d
leaq (%rsp,%r13), %rdi
addq $0x10, %rdi
callq 0x20b0
addq $-0x20, %r13
cmpq $-0x20, %r13
jne 0x3b6c
movb $0x1, %al
jmp 0x3b96
jmp 0x3b91
jmp 0x3b91
jmp 0x3b91
jmp 0x3b91
jmp 0x3b91
movq %rax, %r12
xorl %eax, %eax
cmpq %r15, %r14
je 0x3bb5
testb %al, %al
jne 0x3bb5
addq $-0x20, %r15
movq %r15, %rdi
callq 0x20b0
cmpq %r14, %r15
jne 0x3b9f
jmp 0x3bb5
movq %rax, %r12
leaq 0x38(%rbx), %r14
leaq 0x50(%rbx), %rdi
callq 0x293a
movq %r14, %rdi
callq 0x29c0
movq %rbx, %rdi
callq 0x20b0
movq %r12, %rdi
callq 0x2340
// File: /workspace/github_cpp_makefile_star2_O2/sidvishnoi[P]filesystem-assignment/day1/createDisk.cpp
// Function: FileSystem::createDisk()
void FileSystem::createDisk()
{
    /*
    objective: reserves disk space by writing numberOfSectors_k sectors of size sectorSize_k each
    */
    ofstream fp;
    fp.open(diskTitle_k, ios::binary | ios::out);
    fp.close();
    char buffer[sectorSize_k];

    TypeCastInt cast;
    cast.num = 0;

    // create a buffer of size sectorSize_k
    for (int i = 0; i < sectorSize_k; ++i)
    {
        buffer[i] = cast.str[i % 4];
    }

    // reserve disk space by writing numberOfSectors_k sectors
    for (int i = 0; i < numberOfSectors_k; ++i)
    {
        writeSector(i, buffer);
    }

    // reserve space for root directory
    for (int i = numberOfSectors_k; i < numberOfSectors_k + sectorsForDir_k; ++i)
    {
        int s = (i == sectorsForDir_k - 1) ? 1 : i+1;
        setStatus(i, s);
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x210, %rsp            # imm = 0x210
movq %rdi, %rbx
leaq -0x228(%rbp), %r14
movq %r14, %rdi
callq 0x2310
pushq $0x14
popq %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x20d0
leaq -0x228(%rbp), %rdi
callq 0x2290
movq %rsp, %r12
movl 0x20(%rbx), %eax
movq %rsp, %r14
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %r14
movq %r14, %rsp
andl $0x0, -0x24(%rbp)
movl 0x20(%rbx), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpq %rcx, %rax
je 0x3d72
movl %ecx, %edx
andl $0x3, %edx
movb -0x24(%rbp,%rdx), %dl
movb %dl, (%r14,%rcx)
incq %rcx
jmp 0x3d5b
xorl %r15d, %r15d
movl 0x2c(%rbx), %esi
cmpl %esi, %r15d
jge 0x3d90
movq %rbx, %rdi
movl %r15d, %esi
movq %r14, %rdx
callq 0x3df4
incl %r15d
jmp 0x3d75
pushq $0x1
popq %r14
movl 0x30(%rbx), %eax
movl 0x2c(%rbx), %ecx
addl %eax, %ecx
cmpl %ecx, %esi
jge 0x3dbc
decl %eax
leal 0x1(%rsi), %r15d
cmpl %eax, %esi
movl %r15d, %edx
cmovel %r14d, %edx
movq %rbx, %rdi
callq 0x3f90
movl %r15d, %esi
jmp 0x3d94
movq %r12, %rsp
leaq -0x228(%rbp), %rdi
callq 0x22b0
leaq -0x20(%rbp), %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3ddc
jmp 0x3ddc
movq %rax, %rbx
leaq -0x228(%rbp), %rdi
callq 0x22b0
movq %rbx, %rdi
callq 0x2340
nop
// File: /workspace/github_cpp_makefile_star2_O2/sidvishnoi[P]filesystem-assignment/day1/writeSector.cpp
// Function: FileSystem::writeSector(int, char*)
int FileSystem::writeSector(int sector_no, char *buf)
{
    /*
    objective: to write a sector in disk
    input:
        sector_no: sector number to write in
        buf: a buffer of size sectorSize_k bytes, which is to be written in the sector
    return:
        0: success
        1: failure (%% handle errors)
    */

    ofstream fp;
    // open disk file in edit mode
    fp.open(diskTitle_k, ios::binary | ios::in | ios::out);

    /* %%
    at which byte position the buf be written?
    >> put that expression by replacing -1 below
    */
    int byteOffset = -1;
    fp.seekp(byteOffset);

    fp.write(buf, sectorSize_k);
    fp.close();

    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x200, %rsp            # imm = 0x200
movq %rdx, %rbx
movq %rdi, %r14
movq %rsp, %r15
movq %r15, %rdi
callq 0x2310
pushq $0x1c
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x20d0
movq %rsp, %rdi
pushq $-0x1
popq %rsi
xorl %edx, %edx
callq 0x2210
movslq 0x20(%r14), %rdx
movq %rsp, %rdi
movq %rbx, %rsi
callq 0x2260
movq %rsp, %rdi
callq 0x2290
movq %rsp, %rdi
callq 0x22b0
xorl %eax, %eax
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r14
popq %r15
retq
jmp 0x3e5c
movq %rax, %rbx
movq %rsp, %rdi
callq 0x22b0
movq %rbx, %rdi
callq 0x2340
nop
// File: /workspace/github_cpp_makefile_star2_O2/sidvishnoi[P]filesystem-assignment/day1/readSector.cpp
// Function: FileSystem::readSector(int, char*)
int FileSystem::readSector(int sector_no, char *buf)
{
    /*
    objective: to read a sector from disk into buf
    input:
        sector_no: sector number to read
        buf: a buffer of size sectorSize_k bytes, into which the content of sector are to be read
    return:
        0: success
        1: failure (%% handle errors)
    */
    ifstream fin;
    fin.open(diskTitle_k, ios::binary | ios::in);

    /* %%
    at which byte position the buf be read from?
    >> put that expression by replacing -1 below
    (hint: same as in writeSector())
    */
    int byteOffset = -1;
    fin.seekg(byteOffset);

    fin.read(buf, sectorSize_k);
    fin.close();
    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x210, %rsp            # imm = 0x210
movq %rdx, %rbx
movq %rdi, %r14
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x21f0
pushq $0xc
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x2180
leaq 0x8(%rsp), %rdi
pushq $-0x1
popq %rsi
xorl %edx, %edx
callq 0x2230
movslq 0x20(%r14), %rdx
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x2220
leaq 0x8(%rsp), %rdi
callq 0x2040
leaq 0x8(%rsp), %rdi
callq 0x2050
xorl %eax, %eax
addq $0x210, %rsp            # imm = 0x210
popq %rbx
popq %r14
popq %r15
retq
jmp 0x3ee2
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2050
movq %rbx, %rdi
callq 0x2340
nop
// File: /workspace/github_cpp_makefile_star2_O2/sidvishnoi[P]filesystem-assignment/day2/getStatus.cpp
// Function: FileSystem::getStatus(int)
int FileSystem::getStatus(int sector_no) {
    /*
    objective: to get status of a given sector
    input:
        sector_no = sector number
    return:
        status of a sector
    */

    if (sector_no > numberOfSectors_k - 1) {
        cout << "ERROR: Sector does not exist." << endl;
        return NOT_FOUND;
    }
      if (sector_no < reservedSectors_k) {
        cout << "ERROR: Sector is reserved." << endl;
        return RESERVED;
    }

    // cast will convert a char[4] array to an int, using type-punning
    TypeCastInt cast;

    /* %%
    Compute which to sector read from, as minimum unit of read/write is a sector
    >> based on sector_no, computer a <sectorOffset> which should have the status for sector_no
    >> also, compute a <byteOffset> which shows starting from which byte in <sectorOffset>, next 4 bytes need to be read
    (hint: same as in setStatus())
    */
    int sectorOffset, byteOffset;
    // compute here

    char buffer[sectorSize_k];
    readSector(sectorOffset, buffer);

    // edit buffer
    for (int i = byteOffset, j = 0; j < 4; ++i, ++j) {
        cast.str[j] = buffer[i];
    }

    return cast.num;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
cmpl %esi, 0x2c(%rdi)
jle 0x3f2c
cmpl %esi, 0x28(%rdi)
jle 0x3f4c
movq 0x40bc(%rip), %rdi      # 0x7fd0
leaq 0x13e3(%rip), %rsi      # 0x52fe
callq 0x21c0
movq %rax, %rdi
callq 0x20e0
pushq $0x2
jmp 0x3f49
movq 0x409d(%rip), %rdi      # 0x7fd0
leaq 0x13a6(%rip), %rsi      # 0x52e0
callq 0x21c0
movq %rax, %rdi
callq 0x20e0
pushq $0x3
popq %rax
jmp 0x3f85
movq %rsp, %r14
movl 0x20(%rdi), %eax
movq %rsp, %rbx
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %rbx
movq %rbx, %rsp
movq %rbx, %rdx
callq 0x3e70
xorl %eax, %eax
cmpq $0x4, %rax
je 0x3f7f
movb (%rbx,%rax), %cl
movb %cl, -0x14(%rbp,%rax)
incq %rax
jmp 0x3f6d
movl -0x14(%rbp), %eax
movq %r14, %rsp
leaq -0x10(%rbp), %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/sidvishnoi[P]filesystem-assignment/day2/setStatus.cpp
// Function: FileSystem::setStatus(int, int)
int FileSystem::setStatus(int sector_no, int x) {
    /*
    objective: to update status of a given sector
    input:
        sector_no = sector number
        x = status (0 = FREE, 1 = BUSY, other: continuation sector number)
    return:
        (failure) -1
        (success) 0
    effect: a sector is marked in disk
    */

    if (sector_no > numberOfSectors_k - 1) {
        cout << "ERROR: Sector does not exist." << endl;
        return -1;
    }
    if (sector_no < reservedSectors_k) {
        cout << "ERROR: Sector is reserved." << endl;
        return -1;
    }

    // cast will convert an int <x> to a char[4] array, using type-punning
    TypeCastInt cast;
    cast.num = x;

    /* %%
    Compute which to sector update, as minimum unit of read/write is a sector
    >> based on sector_no, computer a <sectorOffset> which should have the status for sector_no
    >> also, compute a <byteOffset> which shows starting from which byte in <sectorOffset>, next 4 bytes need to be updated
    */
    int sectorOffset, byteOffset;
    // compute here

    char buffer[sectorSize_k];
    readSector(sectorOffset, buffer);

    // edit buffer
    for (int i = byteOffset, j = 0; j < 4; ++i, ++j) {
        buffer[i] = cast.str[j];
    }

    writeSector(sectorOffset, buffer);

    return 0;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
cmpl %esi, 0x2c(%rdi)
jle 0x3fb7
movq %rdi, %rbx
cmpl %esi, 0x28(%rdi)
jle 0x3fd7
movq 0x4022(%rip), %rdi      # 0x7fd0
leaq 0x1349(%rip), %rsi      # 0x52fe
jmp 0x3fc5
movq 0x4012(%rip), %rdi      # 0x7fd0
leaq 0x131b(%rip), %rsi      # 0x52e0
callq 0x21c0
movq %rax, %rdi
callq 0x20e0
pushq $-0x1
popq %rax
jmp 0x4021
movq %rsp, %r15
movl %edx, -0x1c(%rbp)
movl 0x20(%rbx), %eax
movq %rsp, %r14
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %r14
movq %r14, %rsp
movq %rbx, %rdi
movq %r14, %rdx
callq 0x3e70
xorl %eax, %eax
cmpq $0x4, %rax
je 0x4011
movb -0x1c(%rbp,%rax), %cl
movb %cl, (%r14,%rax)
incq %rax
jmp 0x3ffe
movq %rbx, %rdi
movq %r14, %rdx
callq 0x3df4
movq %r15, %rsp
xorl %eax, %eax
leaq -0x18(%rbp), %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/sidvishnoi[P]filesystem-assignment/day3/findEmptySectors.cpp
// Function: FileSystem::findEmptySectors(int)
vector<int> FileSystem::findEmptySectors(int requiredNumber) {
    /*
    Objective: To get a list of sectors that are available to be written on
    Input Parameters:
        requiredNumber: Number of empty sectors required
    Return Value:
        list of available sectors
        if not enough available, return empty list
    */
    TypeCastInt cast;
    vector<int> availableSectors;
    int found = 0, sector = 0;
    int div = sectorSize_k/4;   // each sector contains status of this much sectors
    char buffer[sectorSize_k];
    while (found != requiredNumber && sector < reservedSectors_k) {
        readSector(sector, buffer);
        for (int s = 0; s < div; ++s) {
            for (int j = 0; j < 4; ++j) {
                cast.str[j] = buffer[4*s + j];
            }
            if (cast.num == FREE) {
                availableSectors.push_back(s + reservedSectors_k + sector*div);
                ++found;
            }
            if (found == requiredNumber) break;
        }
    ++sector;
    }

    // if still, found != requiredNumber, now try looking in DELETED sectors (DAY 4)
    // %% look in sectors marked deleted here

    if (found != requiredNumber) {
        // empty list if enough sectors are not available (failure)
        availableSectors.empty();
    }
    return availableSectors; // success
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, %ebx
movq %rsi, %r8
movq %rsp, -0x50(%rbp)
andq $0x0, 0x10(%rdi)
xorps %xmm0, %xmm0
movq %rdi, -0x30(%rbp)
movups %xmm0, (%rdi)
movl 0x20(%rsi), %ecx
pushq $0x4
popq %rsi
movl %ecx, %eax
cltd
idivl %esi
movq %rsp, %r15
addq $0xf, %rcx
andq $-0x10, %rcx
subq %rcx, %r15
movq %r15, %rsp
xorl %r12d, %r12d
testl %eax, %eax
movl $0x0, %r13d
movl %eax, -0x34(%rbp)
cmovgl %eax, %r13d
xorl %r14d, %r14d
movq %r8, -0x48(%rbp)
movq %r15, -0x58(%rbp)
cmpl %ebx, %r14d
je 0x4127
cmpl 0x28(%r8), %r12d
jge 0x4127
movq %r8, %rdi
movl %r12d, %esi
movq %r15, %rdx
callq 0x3e70
movq %r12, -0x60(%rbp)
imull -0x34(%rbp), %r12d
movq %r12, -0x68(%rbp)
xorl %r12d, %r12d
cmpq %r13, %r12
je 0x4113
xorl %eax, %eax
cmpq $0x4, %rax
je 0x40dd
movb (%r15,%rax), %cl
movb %cl, -0x3c(%rbp,%rax)
incq %rax
jmp 0x40ca
cmpl $0x0, -0x3c(%rbp)
jne 0x4104
movq -0x68(%rbp), %rax
addl %r12d, %eax
movq -0x48(%rbp), %rcx
addl 0x28(%rcx), %eax
movl %eax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x4154
incl %r14d
incq %r12
addq $0x4, %r15
cmpl %ebx, %r14d
jne 0x40c3
movl %ebx, %r14d
movq -0x60(%rbp), %r12
incl %r12d
movq -0x48(%rbp), %r8
movq -0x58(%rbp), %r15
jmp 0x4092
movq -0x50(%rbp), %rsp
movq -0x30(%rbp), %rax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4140
movq %rax, %r14
movq -0x30(%rbp), %rdi
callq 0x29c0
movq %r14, %rdi
callq 0x2340
// File: /workspace/github_cpp_makefile_star2_O2/sidvishnoi[P]filesystem-assignment/day3/alreadyExists.cpp
// Function: FileSystem::alreadyExists(char*, char)
vector<int> FileSystem::alreadyExists(char *name, char type) {
    /*
     Objective: To check whether a file/dir already exists in current working directory
     Input Parameters:
        name: dir/file name
        type: type (d = dir, f = file)
     Return value: vector<int>
        {-1,-1,0} if not found
        {sector_offset, byte_offset, 1} otherwise
     */
    TypeCastEntry cast;
    char buffer[sectorSize_k];
    int next = reservedSectors_k;
    for(int count = 0; count < sectorsForDir_k; ++count) {
        readSector(next, buffer);
        for (int i = 0; i < sectorSize_k/32; ++i) {
            for (int j = 0; j < 32; ++j) {
                cast.str[j] = buffer[32*i + j];
            }
            // %% check if file with same characteristics exists
            if (true /* %%  CONDITION */) {
                vector<int> offset = {next, 32*i, 1};
                return offset;
            }
        }
        next = getStatus(next);
    }
    vector<int> offset = {-1,-1,0};
    return offset;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl 0x20(%rsi), %eax
movq %rsp, %r15
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %r15
movq %r15, %rsp
movl 0x28(%rsi), %r12d
xorl %r13d, %r13d
cmpl 0x30(%r14), %r13d
jge 0x432c
movq %r14, %rdi
movl %r12d, %esi
movq %r15, %rdx
callq 0x3e70
cmpl $0x20, 0x20(%r14)
jge 0x433a
movq %r14, %rdi
movl %r12d, %esi
callq 0x3ef8
movl %eax, %r12d
incl %r13d
jmp 0x42fe
leaq -0x38(%rbp), %rsi
orq $-0x1, (%rsi)
andl $0x0, 0x8(%rsi)
jmp 0x434f
leaq -0x38(%rbp), %rsi
movl %r12d, (%rsi)
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x4(%rsi)
pushq $0x3
popq %rdx
leaq -0x29(%rbp), %rcx
movq %rbx, %rdi
callq 0x4370
movq %rbx, %rax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/sidvishnoi[P]filesystem-assignment/day3/getEntryPosition.cpp
// Function: FileSystem::getEntryPosition()
vector<int> FileSystem::getEntryPosition() {
    /*
    Objective: return the offsets for free position for file/directory entry
    Input Parameters:
        None
    return:
        vector [sectorOffset, byteOffset] if space available
            else: [-1, -1]
    */
    char buffer[sectorSize_k];
    TypeCastEntry cast;

    // start looking from first non-reserved sector
    // (or current working directory)
    int current = reservedSectors_k;
    for (int s = 0; s < sectorsForDir_k; ++s) {
        readSector(current, buffer);
        for (int b = 0; b < sectorSize_k; b += 32) {
            for (int k = 0; k < 32; ++k) {
                cast.str[k] = buffer[b+k];
            }
            if (strlen(cast.entry.name) == 0) {
                // found free space
                vector<int> offsets = {current, b};
                return offsets;
            }
        }
        // next sector to look in
        current = getStatus(current);
    }
    // no position found
    vector<int> offsets = {-1, -1};
    return offsets;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl 0x20(%rsi), %eax
movq %rsp, %r15
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %r15
movq %r15, %rsp
movl 0x28(%rsi), %r12d
xorl %r13d, %r13d
cmpl 0x30(%r14), %r13d
jge 0x44d8
movq %r14, %rdi
movl %r12d, %esi
movq %r15, %rdx
callq 0x3e70
movslq 0x20(%r14), %rcx
movq %r15, %rdx
xorl %eax, %eax
cmpq %rcx, %rax
jge 0x449a
xorl %esi, %esi
cmpq $0x20, %rsi
je 0x448a
movb (%rdx,%rsi), %dil
movb %dil, -0x58(%rbp,%rsi)
incq %rsi
jmp 0x4476
cmpb $0x0, -0x48(%rbp)
je 0x44ad
addq $0x20, %rax
addq $0x20, %rdx
jmp 0x446f
movq %r14, %rdi
movl %r12d, %esi
callq 0x3ef8
movl %eax, %r12d
incl %r13d
jmp 0x444e
leaq -0x34(%rbp), %rsi
movl %r12d, (%rsi)
movl %eax, 0x4(%rsi)
pushq $0x2
popq %rdx
leaq -0x29(%rbp), %rcx
movq %rbx, %rdi
callq 0x4370
movq %rbx, %rax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x34(%rbp), %rsi
orq $-0x1, (%rsi)
jmp 0x44b7
nop
// File: /workspace/github_cpp_makefile_star2_O2/sidvishnoi[P]filesystem-assignment/day3/writeEntry.cpp
// Function: FileSystem::writeEntry(std::vector<int, std::allocator<int>>, char const*)
void FileSystem::writeEntry(vector<int> offset, const char * buffer) {
    /*
     Objective: to write a file/dir entry at right offset
     Input Parameters:
        offset (sectorOffset, byteOffset) to write at
        buffer: 32 bytes from cast.str
     return: None
     effect: 32 bytes of new entry are written in disk
     */
    char buf[sectorSize_k];
    readSector(offset[0],buf);

    // %% modify correct 32 bytes of 'buf' starting from byte offset

    // write updated buf
    writeSector(offset[0], buf);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movl 0x20(%rdi), %eax
movq %rsp, %r15
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %r15
movq %r15, %rsp
movq (%rsi), %rax
movl (%rax), %esi
movq %r15, %rdx
callq 0x3e70
movq (%rbx), %rax
movl (%rax), %esi
movq %r14, %rdi
movq %r15, %rdx
callq 0x3df4
leaq -0x18(%rbp), %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/t0mm4rx[P]piscine_cpp/day01/ex06/main.cpp
// Function: main
int main()
{

	Weapon club1 = Weapon("crude spiked club");
	HumanA bob("Bob", club1);
	bob.attack();
	club1.setType("some other type of club");
	bob.attack();

	Weapon club2 = Weapon("crude spiked club");
	HumanB jim("Jim");
	jim.setWeapon(club2);
	jim.attack();
	club2.setType("some other type of club");
	jim.attack();

}

// Assembly:
pushq %rbx
subq $0x160, %rsp            # imm = 0x160
leaq 0xc08(%rip), %rsi       # 0x2017
leaq 0x140(%rsp), %rdi
leaq 0x78(%rsp), %rdx
callq 0x166e
leaq 0x58(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x1384
leaq 0x140(%rsp), %rdi
callq 0x1040
leaq 0xbe2(%rip), %rsi       # 0x2029
leaq 0x120(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x166e
leaq 0x78(%rsp), %rdi
leaq 0x120(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x127c
leaq 0x120(%rsp), %rdi
callq 0x1040
leaq 0x78(%rsp), %rdi
callq 0x1288
leaq 0xb9f(%rip), %rsi       # 0x202d
leaq 0x100(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x166e
leaq 0x58(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x13ea
leaq 0x100(%rsp), %rdi
callq 0x1040
leaq 0x78(%rsp), %rdi
callq 0x1288
leaq 0xb47(%rip), %rsi       # 0x2017
leaq 0xe0(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x166e
leaq 0x38(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x1384
leaq 0xe0(%rsp), %rdi
callq 0x1040
leaq 0xb3d(%rip), %rsi       # 0x2045
leaq 0xc0(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x166e
leaq 0x10(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x1300
leaq 0xc0(%rsp), %rdi
callq 0x1040
leaq 0x10(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x1380
leaq 0x10(%rsp), %rdi
callq 0x130a
leaq 0xad4(%rip), %rsi       # 0x202d
leaq 0xa0(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x166e
leaq 0x38(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x13ea
leaq 0xa0(%rsp), %rdi
callq 0x1040
leaq 0x10(%rsp), %rdi
callq 0x130a
leaq 0x18(%rsp), %rdi
callq 0x1040
leaq 0x38(%rsp), %rdi
callq 0x1040
leaq 0x80(%rsp), %rdi
callq 0x1040
leaq 0x58(%rsp), %rdi
callq 0x1040
xorl %eax, %eax
addq $0x160, %rsp            # imm = 0x160
popq %rbx
retq
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x1040
jmp 0x163a
jmp 0x1637
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
jmp 0x163f
movq %rax, %rbx
jmp 0x1644
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
jmp 0x1649
jmp 0x1632
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
jmp 0x1649
jmp 0x1632
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
jmp 0x1656
movq %rax, %rbx
jmp 0x165b
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
jmp 0x1660
movq %rax, %rbx
jmp 0x1665
movq %rax, %rbx
jmp 0x164e
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x1040
leaq 0x38(%rsp), %rdi
callq 0x1040
leaq 0x80(%rsp), %rdi
callq 0x1040
leaq 0x58(%rsp), %rdi
callq 0x1040
movq %rbx, %rdi
callq 0x10e0
nop