LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/lvandeve[P]lodepng/pngdetail.cpp
// Function: RGBtoHCT(unsigned char, unsigned char, unsigned char, unsigned char*, unsigned char*, unsigned char*)
void RGBtoHCT(unsigned char r, unsigned char g, unsigned char b, unsigned char* h, unsigned char* c, unsigned char* t) {
  int cmax = std::max<int>(r, std::max<int>(g, b));
  int cmin = std::min<int>(r, std::min<int>(g, b));
  RGBtoHSL(r, g, b, h, c, t);
  *c = cmax - cmin;
  *t = *c == 255 ? 0 : 255 * cmin / (255 + cmin - cmax);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %r9, %rbx
movq %r8, %r14
cmpb %dl, %sil
movl %edx, %r15d
cmoval %esi, %r15d
cmpb %r15b, %dil
cmoval %edi, %r15d
cmpb %sil, %dl
movl %esi, %r12d
cmovbl %edx, %r12d
cmpb %dil, %r12b
cmovael %edi, %r12d
callq 0x16a87
movl %r15d, %eax
subl %r12d, %eax
movb %al, (%r14)
cmpb $-0x1, %al
jne 0x16b9a
xorl %eax, %eax
jmp 0x16bb5
movl %r12d, %eax
shll $0x8, %eax
subl %r12d, %eax
negl %r15d
leal (%r12,%r15), %ecx
addl $0xff, %ecx
xorl %edx, %edx
divw %cx
movb %al, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/lvandeve[P]lodepng/pngdetail.cpp
// Function: HueToLetter(int)
char HueToLetter(int h) {
  char hl = 'R';
  // 12 unique hue letters for 30 degree increment hues.
  if(h < 11 || h >= 244) hl = 'R';  // red
  else if(h >= 11 && h < 32) hl = 'O';  // orange
  else if(h >= 32 && h < 53) hl = 'Y';  // yellow
  else if(h >= 53 && h < 74) hl = 'L';  // lime (officialy "chartreuse" but c is for cyan)
  else if(h >= 74 && h < 96) hl = 'G';  // green
  else if(h >= 96 && h < 117) hl = 'T';  // turquoise (officially "spring green" but that name overlaps green)
  else if(h >= 117 && h < 138) hl = 'C';  // cyan
  else if(h >= 138 && h < 159) hl = 'A';  // azure
  else if(h >= 159 && h < 181) hl = 'B';  // blue
  else if(h >= 181 && h < 202) hl = 'V';  // violet
  else if(h >= 202 && h < 223) hl = 'M';  // magenta
  else if(h >= 223 && h < 244) hl = 'F';  // fuchsia (officially "rose" but r is for red)
  return hl;
}

// Assembly:
leal -0xf4(%rdi), %ecx
movb $0x52, %al
cmpl $0xffffff17, %ecx       # imm = 0xFFFFFF17
jb 0x16c31
movb $0x4f, %al
cmpl $0x20, %edi
jb 0x16c31
movb $0x59, %al
cmpl $0x35, %edi
jb 0x16c31
movb $0x4c, %al
cmpl $0x4a, %edi
jb 0x16c31
movb $0x47, %al
cmpl $0x60, %edi
jb 0x16c31
movb $0x54, %al
cmpl $0x75, %edi
jb 0x16c31
movb $0x43, %al
cmpl $0x8a, %edi
jb 0x16c31
movb $0x41, %al
cmpl $0x9f, %edi
jb 0x16c31
movb $0x42, %al
cmpl $0xb5, %edi
jb 0x16c31
movb $0x56, %al
cmpl $0xca, %edi
jb 0x16c31
cmpl $0xdf, %edi
movl $0x4d, %ecx
movl $0x46, %eax
cmovbl %ecx, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O3/lvandeve[P]lodepng/pngdetail.cpp
// Function: lightnessToLetter(int)
char lightnessToLetter(int l) {
  int c = ' ';
  if(l < 16) c = ' ';
  else if(l < 48) c = '.';
  else if(l < 80) c = ':';
  else if(l < 112) c = '-';
  else if(l < 144) c = '!';
  else if(l < 176) c = '*';
  else if(l < 208) c = '+'; // The + looks denser than the * in a terminal...
  else if(l < 240) c = '=';
  else c = '#';
  return c;
}

// Assembly:
movb $0x20, %al
cmpl $0x10, %edi
jl 0x16c7f
movb $0x2e, %al
cmpl $0x30, %edi
jb 0x16c7f
movb $0x3a, %al
cmpl $0x50, %edi
jb 0x16c7f
movb $0x2d, %al
cmpl $0x70, %edi
jb 0x16c7f
movb $0x21, %al
cmpl $0x90, %edi
jb 0x16c7f
movb $0x2a, %al
cmpl $0xb0, %edi
jb 0x16c7f
movb $0x2b, %al
cmpl $0xd0, %edi
jb 0x16c7f
cmpl $0xf0, %edi
movl $0x3d, %ecx
movl $0x23, %eax
cmovbl %ecx, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x5737(%rip), %rax      # 0x1e1e9
leaq 0x5740(%rip), %rcx      # 0x1e1f9
cmpb $0x0, 0x24(%rsi)
cmovneq %rax, %rcx
movq 0x12508(%rip), %rdi     # 0x2afd0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
callq *%rcx
movzbl 0x24(%r14), %eax
leaq 0xb15f(%rip), %rcx      # 0x23c3c
leaq 0xb8fc(%rip), %rsi      # 0x243e0
testl %eax, %eax
cmovneq %rcx, %rsi
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq (%rsi,%rax,2), %rdx
movq %rsp, %rdi
callq 0x14ece
cmpl $0x0, 0x2d8(%rbx)
jne 0x18b4e
movq 0x124c1(%rip), %r14     # 0x2afd0
leaq 0xb129(%rip), %rsi      # 0x23c3f
movl $0x8, %edx
movq %r14, %rdi
callq 0x2290
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq 0x1248f(%rip), %rdi     # 0x2afd0
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq 0x1247b(%rip), %rdi     # 0x2afd0
leaq 0xb0ec(%rip), %rsi      # 0x23c48
movl $0xf, %edx
callq 0x2290
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x1245a(%rip), %rdi     # 0x2afd0
callq 0x2290
movl 0x2d8(%rbx), %esi
movq %rax, %rdi
callq 0x2160
movq %rax, %r14
leaq 0xb985(%rip), %rsi      # 0x24518
movl $0x2, %edx
movq %rax, %rdi
callq 0x2290
movl 0x2d8(%rbx), %edi
callq 0xd080
movq %rax, %rbx
testq %rax, %rax
je 0x18bcb
movq %rbx, %rdi
callq 0x20e0
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2290
jmp 0x18be5
movq (%r14), %rax
movq -0x18(%rax), %rax
movq %r14, %rdi
addq %rax, %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x2380
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x18c1a
callq 0x2210
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x18c35
callq 0x2210
movq %rbx, %rdi
callq 0x23a0
// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x4(%rcx), %rax
leaq 0x10(%rdi), %r15
movq %r15, (%rdi)
cmpq %rdx, %rax
jbe 0x1a754
leaq 0x9ec3(%rip), %rsi      # 0x245fd
leaq 0x9ec8(%rip), %rdx      # 0x24609
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x14ece
movq %rsi, %r14
movq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
addq %rcx, %r14
xorl %r12d, %r12d
movzbl (%r14,%r12), %eax
leal -0x20(%rax), %ecx
cmpb $0x5f, %cl
jb 0x1a77b
movl $0x3f, %eax
movsbl %al, %esi
movq %rbx, %rdi
callq 0x21e0
incq %r12
cmpq $0x4, %r12
jne 0x1a769
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %r14
movq (%rbx), %rdi
cmpq %r15, %rdi
je 0x1a7ab
callq 0x2210
movq %r14, %rdi
callq 0x23a0
// File: /workspace/github_cpp_makefile_star2_O3/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
testq %rsi, %rsi
je 0x1a85f
movq %rsi, %r14
movq %rdi, %r15
leaq 0x98a3(%rip), %rbp      # 0x2407a
movq 0x107f2(%rip), %r12     # 0x2afd0
xorl %r13d, %r13d
movzbl (%r15,%r13), %esi
movl 0x10(%rbx), %eax
cmpl $0x2, %eax
jne 0x1a7fa
movl %esi, %edi
callq 0x22d0
incq %r13
jmp 0x1a85a
cmpl $0x1, %eax
movq %rbp, %rdi
leaq 0x986e(%rip), %rax      # 0x24075
cmoveq %rax, %rdi
leal -0x21(%rsi), %eax
cmpb $0x5e, %al
cmovaeq %rbp, %rdi
xorl %eax, %eax
callq 0x2060
movl %r13d, %eax
notl %eax
testb $0x1f, %al
setne %al
incq %r13
cmpq %r14, %r13
sete %cl
orb %al, %cl
jne 0x1a85a
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
cmpq %r14, %r13
jne 0x1a7e1
cmpl $0x2, 0x10(%rbx)
jne 0x1a874
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10755(%rip), %rbx     # 0x2afd0
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
// File: /workspace/github_cpp_makefile_star2_O3/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 %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
cmpb $0x1, 0x1(%rdx)
jne 0x1b847
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq (%rsi), %rax
movq 0x8(%rsi), %rdx
addq %rax, %rdx
movq %rbx, %rdi
movq %rax, %rsi
jmp 0x1b8b2
movq %rdx, %rax
movq 0x8(%rsi), %rdx
testq %rdx, %rdx
je 0x1b8a2
movzbl (%rax), %eax
leaq 0x1(,%rax,4), %rdi
movq (%rsi), %r8
xorl %ecx, %ecx
xorl %eax, %eax
movq %rax, %r9
xorl %eax, %eax
cmpb $0xa, (%r8,%rcx)
sete %al
addq %r9, %rax
cmpq %rdi, %rax
jae 0x1b887
incq %rcx
cmpq %rcx, %rdx
jne 0x1b865
movl $0x200, %ecx            # imm = 0x200
cmpq $0x2, %rax
leaq 0x8b4d(%rip), %rax      # 0x243df
leaq 0x8b47(%rip), %r14      # 0x243e0
cmovaeq %rax, %r14
cmpq %rcx, %rdx
jae 0x1b8c6
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq (%rsi), %rsi
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x150ea
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x28(%rsp), %r15
movq %r15, %rdi
xorl %edx, %edx
callq 0x2260
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x150ea
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x23c0
leaq 0x10(%rbx), %r15
movq %r15, (%rbx)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x150ea
leaq 0x8a2c(%rip), %rsi      # 0x2434f
movq %rbx, %rdi
callq 0x23c0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x1b93a
callq 0x2210
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1b8b7
callq 0x2210
jmp 0x1b8b7
movq %rax, %r14
movq (%rbx), %rdi
cmpq %r15, %rdi
je 0x1b96d
callq 0x2210
jmp 0x1b96d
jmp 0x1b96a
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x1b981
callq 0x2210
jmp 0x1b981
movq %rax, %r14
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1b994
callq 0x2210
movq %r14, %rdi
callq 0x23a0
// File: /workspace/github_cpp_makefile_star2_O3/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 0x1c5c0
testb %cl, %cl
je 0x1c5bd
movl (%rdi,%rdx), %eax
bswapl %eax
retq
movl (%rdi,%rdx), %eax
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 0x1c5e0
testb %cl, %cl
je 0x1c5dc
movzwl (%rdi,%rdx), %eax
rolw $0x8, %ax
movzwl %ax, %eax
retq
movzwl (%rdi,%rdx), %eax
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movq 0x38(%rdi), %rax
cmpq 0x40(%rdi), %rax
jne 0x1d422
movq %r14, %rdi
callq 0x1e4e8
cmpl $0x0, 0x2d8(%r14)
jne 0x1d49d
leaq 0x38(%r14), %r15
movl 0x18(%rbx), %eax
testl %eax, %eax
jne 0x1d44d
movl 0x50(%r14), %esi
movl 0x54(%r14), %edx
movl 0x1c(%rbx), %ecx
movq %r15, %rdi
callq 0x174dd
movl 0x18(%rbx), %eax
cmpl $0x1, %eax
jne 0x1d467
movl 0x50(%r14), %esi
movl 0x54(%r14), %edx
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x17849
movl 0x18(%rbx), %eax
cmpl $0x2, %eax
jne 0x1d484
movl 0x50(%r14), %esi
movl 0x54(%r14), %edx
movq %r15, %rdi
movl $0x1, %ecx
callq 0x17849
movl 0x18(%rbx), %eax
cmpl $0x3, %eax
jne 0x1d49d
addq $0x20, %r14
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x17f56
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 0x1d4be
movq %r14, %rdi
movq %rbx, %rsi
callq 0x18f00
cmpb $0x1, 0x4(%rbx)
jne 0x1d4cf
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1c49d
cmpb $0x1, 0x7(%rbx)
jne 0x1d4dd
movq %r14, %rdi
callq 0x1d1e1
cmpb $0x0, 0x3(%rbx)
jne 0x1d4f5
cmpb $0x0, 0x5(%rbx)
jne 0x1d4f5
cmpb $0x0, 0x6(%rbx)
jne 0x1d4f5
cmpb $0x1, 0x8(%rbx)
jne 0x1d500
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1a8b0
cmpb $0x1, 0x9(%rbx)
jne 0x1d511
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1bf03
cmpb $0x1, 0xa(%rbx)
jne 0x1d522
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1b99c
cmpb $0x1, 0xb(%rbx)
jne 0x1d533
movq %r14, %rdi
movq %rbx, %rsi
callq 0x17d55
cmpb $0x0, 0x20(%rbx)
jne 0x1d53f
cmpb $0x1, 0x21(%rbx)
jne 0x1d54a
movq %r14, %rdi
movq %rbx, %rsi
callq 0x163d0
cmpb $0x1, 0x22(%rbx)
jne 0x1d55b
movq %r14, %rdi
movq %rbx, %rsi
callq 0x17ae6
cmpb $0x1, 0x23(%rbx)
jne 0x1d569
movq %r14, %rdi
callq 0x182e2
cmpb $0x1, 0x14(%rbx)
jne 0x1d57a
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1d405
cmpl $0x0, 0x2d8(%r14)
je 0x1d596
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x18a9c
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x20(%rdi), %r14
movq 0x20(%rdi), %rax
cmpq 0x28(%rdi), %rax
je 0x1e54d
movl $0x0, 0x2d8(%rbx)
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 0x1e535
movq %rax, 0x40(%rbx)
leaq 0x50(%rbx), %rsi
leaq 0x54(%rbx), %rdx
movq %r14, %r8
callq 0xd69b
movl %eax, 0x2d8(%rbx)
jmp 0x1e562
movq %r14, %rdi
movq %rbx, %rsi
callq 0xd09e
movl %eax, 0x2d8(%rbx)
testl %eax, %eax
je 0x1e507
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 0x1e3c6
testb %al, %al
jne 0x1e725
movq 0x20(%rbx), %rax
movq 0x28(%rbx), %rcx
subq %rax, %rcx
cmpq $0x80, %rcx
jb 0x1e725
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 0x1e725
cmpb $0x61, 0x24(%rax)
jne 0x1e725
cmpb $0x63, 0x25(%rax)
jne 0x1e725
cmpb $0x73, 0x26(%rax)
jne 0x1e725
cmpb $0x70, 0x27(%rax)
sete %al
jmp 0x1e727
xorl %eax, %eax
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %rbx
subq $0xc0, %rsp
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
movq $0x0, -0x8(%r14)
movb $0x0, (%r14)
cmpl $0x2, %edi
jl 0x28a7
movq 0x8(%rsi), %rbx
testq %rbx, %rbx
je 0x28a7
movq %rbx, %rdi
callq 0x20a0
movq %rsp, %rdi
xorl %esi, %esi
xorl %edx, %edx
movq %rbx, %rcx
movq %rax, %r8
callq 0x22d0
jmp 0x28ce
movq 0x5722(%rip), %rdi      # 0x7fd0
leaq 0x274f(%rip), %rsi      # 0x5004
movl $0x14, %edx
callq 0x2210
movq 0x571a(%rip), %rdi      # 0x7fe0
movq %rsp, %rsi
callq 0x2250
leaq 0x30(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
addq %rsi, %rdx
leaq 0x20(%rsp), %rdi
callq 0x2ae4
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x40b0
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x2913
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21e0
movq 0x56b6(%rip), %rbx      # 0x7fd0
leaq 0x26f8(%rip), %rsi      # 0x5019
movl $0x26, %edx
movq %rbx, %rdi
callq 0x2210
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq 0x5684(%rip), %rdi      # 0x7fd0
callq 0x2030
movq %rax, %rdi
callq 0x2130
leaq 0x40(%rsp), %rdi
callq 0x2cf9
leaq 0x40(%rsp), %rbx
cmpl $0x1, %eax
je 0x2977
movq %rbx, %rdi
callq 0x2cf9
jmp 0x2968
leaq 0xa8(%rsp), %rdi
callq 0x2a86
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
callq 0x2a86
movq -0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x29ad
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x21e0
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x29c8
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x21e0
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x29de
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21e0
xorl %eax, %eax
addq $0xc0, %rsp
popq %rbx
popq %r14
popq %r15
retq
jmp 0x2a14
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x2a21
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21e0
jmp 0x2a21
jmp 0x2a0d
movq %rax, %rbx
jmp 0x2a21
jmp 0x2a14
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x2a40
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x2a37
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21e0
movq %rbx, %rdi
callq 0x2350
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 %r12
pushq %rbx
subq $0x1b0, %rsp            # imm = 0x1B0
movl %edx, %ebp
movq %rdi, %rbx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movl $0x18, %edx
callq 0x22e0
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
xorl %eax, %eax
movq %rax, -0x8(%r12)
movb $0x0, (%r12)
movq %rax, 0x10(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movsbl %bpl, %ebp
leaq 0x8(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x2370
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2bf3
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3dc6
jmp 0x2bcb
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x2c0a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21e0
movq 0x5397(%rip), %rsi      # 0x7fa8
leaq 0x28(%rsp), %rdi
callq 0x2150
leaq 0xa8(%rsp), %rdi
callq 0x2070
movq %rbx, %rax
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq %rbx, %rdi
callq 0x2a86
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x2c5d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21e0
movq 0x5344(%rip), %rsi      # 0x7fa8
leaq 0x28(%rsp), %rdi
callq 0x2150
leaq 0xa8(%rsp), %rdi
callq 0x2070
movq %r14, %rdi
callq 0x2350
// File: /workspace/github_cpp_makefile_star2_O3/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 0x2cde
movq 0x532f(%rip), %rdi      # 0x7fd0
leaq 0x2418(%rip), %rsi      # 0x50c0
movl $0x10, %edx
callq 0x2210
movq 0x5327(%rip), %r14      # 0x7fe0
leaq 0xf(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2270
movl $0x7fff, %esi           # imm = 0x7FFF
movq %r14, %rdi
movl $0xa, %edx
callq 0x2120
movb (%r15), %dil
movzbl %dil, %esi
movl $0x200, %edx            # imm = 0x200
movq %rbx, %rdi
callq 0x20f0
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 0x2320
movq %r14, %rdi
movq %rbx, %rsi
movl $0x14, %edx
callq 0x20b0
leaq -0x228(%rbp), %rdi
callq 0x2280
movq %rsp, %r12
movl 0x20(%rbx), %eax
movq %rsp, %r14
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %r14
movq %r14, %rsp
movl $0x0, -0x24(%rbp)
movslq 0x20(%rbx), %rax
testq %rax, %rax
jle 0x44ee
xorl %ecx, %ecx
movl %ecx, %edx
andl $0x3, %edx
movb -0x24(%rbp,%rdx), %dl
movb %dl, (%r14,%rcx)
incq %rcx
cmpq %rcx, %rax
jne 0x44d9
movl 0x2c(%rbx), %esi
testl %esi, %esi
jle 0x4511
xorl %r15d, %r15d
movq %rbx, %rdi
movl %r15d, %esi
movq %r14, %rdx
callq 0x45a0
incl %r15d
movl 0x2c(%rbx), %esi
cmpl %esi, %r15d
jl 0x44f8
movl $0x1, %r14d
movl 0x30(%rbx), %eax
movl 0x2c(%rbx), %ecx
addl %eax, %ecx
cmpl %ecx, %esi
jge 0x453f
decl %eax
leal 0x1(%rsi), %r15d
cmpl %eax, %esi
movl %r15d, %edx
cmovel %r14d, %edx
movq %rbx, %rdi
callq 0x47bc
movl %r15d, %esi
jmp 0x4517
movq %r12, %rsp
movq 0x3a77(%rip), %rax      # 0x7fc0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x220(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x228(%rbp,%rcx)
callq 0x2180
leaq -0x130(%rbp), %rdi
callq 0x2070
leaq -0x20(%rbp), %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4589
jmp 0x4589
movq %rax, %rbx
leaq -0x228(%rbp), %rdi
callq 0x22b0
movq %rbx, %rdi
callq 0x2350
// File: /workspace/github_cpp_makefile_star2_O3/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 0x2320
movq %r15, %rdi
movq %r14, %rsi
movl $0x1c, %edx
callq 0x20b0
movq %rsp, %rdi
movq $-0x1, %rsi
xorl %edx, %edx
callq 0x2220
movslq 0x20(%r14), %rdx
movq %rsp, %rdi
movq %rbx, %rsi
callq 0x2260
movq %rsp, %rdi
callq 0x2280
movq 0x39c4(%rip), %rax      # 0x7fc0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x8(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, (%rsp,%rcx)
callq 0x2180
leaq 0xf8(%rsp), %rdi
callq 0x2070
xorl %eax, %eax
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r14
popq %r15
retq
jmp 0x4637
movq %rax, %rbx
movq %rsp, %rdi
callq 0x22b0
movq %rbx, %rdi
callq 0x2350
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 0x2200
movq %r15, %rdi
movq %r14, %rsi
movl $0xc, %edx
callq 0x2190
leaq 0x8(%rsp), %rdi
movq $-0x1, %rsi
xorl %edx, %edx
callq 0x2240
movslq 0x20(%r14), %rdx
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x2230
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 0x46c4
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2050
movq %rbx, %rdi
callq 0x2350
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %rbx
pushq %rax
cmpl %esi, 0x2c(%rdi)
jle 0x473d
cmpl %esi, 0x28(%rdi)
jle 0x4786
movq 0x38d5(%rip), %rbx      # 0x7fd0
leaq 0xc12(%rip), %rsi       # 0x5314
movl $0x1a, %edx
movq %rbx, %rdi
callq 0x2210
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movl $0x2, %eax
jmp 0x47b0
movq 0x388c(%rip), %rbx      # 0x7fd0
leaq 0xbab(%rip), %rsi       # 0x52f6
movl $0x1d, %edx
movq %rbx, %rdi
callq 0x2210
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movl $0x3, %eax
jmp 0x47b0
movq %rsp, %rbx
movl 0x20(%rdi), %r14d
movq %rsp, %r15
addq $0xf, %r14
andq $-0x10, %r14
movq %r15, %rdx
subq %r14, %rdx
movq %rdx, %rsp
negq %r14
callq 0x464c
movl (%r15,%r14), %eax
movq %rbx, %rsp
leaq -0x18(%rbp), %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
pushq %rax
cmpl %esi, 0x2c(%rdi)
jle 0x47ec
movq %rdi, %rbx
cmpl %esi, 0x28(%rdi)
jle 0x4835
movq 0x37f2(%rip), %rbx      # 0x7fd0
leaq 0xb2f(%rip), %rsi       # 0x5314
movl $0x1a, %edx
jmp 0x47ff
movq 0x37dd(%rip), %rbx      # 0x7fd0
leaq 0xafc(%rip), %rsi       # 0x52f6
movl $0x1d, %edx
movq %rbx, %rdi
callq 0x2210
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x4877
movl %edx, %r14d
movq %rsp, -0x30(%rbp)
movl 0x20(%rbx), %r13d
movq %rsp, %r12
addq $0xf, %r13
andq $-0x10, %r13
movq %r12, %r15
subq %r13, %r15
movq %r15, %rsp
negq %r13
movq %rbx, %rdi
movq %r15, %rdx
callq 0x464c
movl %r14d, (%r12,%r13)
movq %rbx, %rdi
movq %r15, %rdx
callq 0x45a0
xorl %eax, %eax
movq -0x30(%rbp), %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 $0x38, %rsp
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movl 0x20(%rsi), %eax
leal 0x3(%rax), %r15d
testl %eax, %eax
cmovnsl %eax, %r15d
movq %rsp, %r12
movq %rax, -0x58(%rbp)
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %r12
movq %r12, %rsp
testl %edx, %edx
je 0x498a
movl %edx, %r14d
movq %rsi, %rbx
sarl $0x2, %r15d
movl %r15d, %eax
movq %rax, -0x50(%rbp)
movq $0x0, -0x38(%rbp)
xorl %r13d, %r13d
xorl %esi, %esi
movq %rdi, -0x30(%rbp)
movq %rbx, -0x48(%rbp)
cmpl 0x28(%rbx), %esi
jge 0x498a
movq %rbx, %rdi
movl %esi, -0x3c(%rbp)
movq %r12, %rdx
callq 0x464c
cmpl $0x4, -0x58(%rbp)
jl 0x4968
xorl %ebx, %ebx
cmpl $0x0, (%r12,%rbx,4)
jne 0x495b
movq -0x48(%rbp), %rax
movl 0x28(%rax), %eax
movq -0x38(%rbp), %rcx
addq %rbx, %rcx
addq %rcx, %rax
movl %eax, -0x40(%rbp)
movq -0x30(%rbp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x494f
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x4958
leaq -0x40(%rbp), %rdx
callq 0x49c6
incl %r13d
cmpl %r14d, %r13d
je 0x4968
incq %rbx
cmpl %ebx, %r15d
jg 0x491a
movl -0x3c(%rbp), %esi
incl %esi
movq -0x38(%rbp), %rax
addq -0x50(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpl %r14d, %r13d
movq -0x30(%rbp), %rdi
movq -0x48(%rbp), %rbx
jne 0x48fb
movq %rdi, %rax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x499e
movq %rax, %r14
movq -0x30(%rbp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x49bd
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rsi
subq %rdi, %rsi
callq 0x21e0
movq %r14, %rdi
callq 0x2350
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 %rdi, %rbx
movl 0x20(%rsi), %eax
movq %rsp, %r15
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %r15
movq %r15, %rsp
cmpl $0x0, 0x30(%rsi)
jle 0x4b68
movq %rsi, %r14
movl 0x28(%rsi), %r12d
xorl %r13d, %r13d
movq %r14, %rdi
movl %r12d, %esi
movq %r15, %rdx
callq 0x464c
cmpl $0x20, 0x20(%r14)
jge 0x4b7c
movq %r14, %rdi
movl %r12d, %esi
callq 0x46dc
movl %eax, %r12d
incl %r13d
cmpl 0x30(%r14), %r13d
jl 0x4b3c
leaq -0x38(%rbp), %rsi
movq $-0x1, (%rsi)
movl $0x0, 0x8(%rsi)
jmp 0x4b91
leaq -0x38(%rbp), %rsi
movl %r12d, (%rsi)
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x4(%rsi)
leaq -0x29(%rbp), %rcx
movl $0x3, %edx
movq %rbx, %rdi
callq 0x4bb4
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_O3/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 $0x18, %rsp
movq %rdi, %rbx
movl 0x20(%rsi), %eax
movq %rsp, %r15
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %r15
movq %r15, %rsp
cmpl $0x0, 0x30(%rsi)
jle 0x4cef
movq %rsi, %r14
movl 0x28(%rsi), %r12d
xorl %r13d, %r13d
movq %r14, %rdi
movl %r12d, %esi
movq %r15, %rdx
callq 0x464c
movl 0x20(%r14), %eax
testl %eax, %eax
jle 0x4cd8
xorl %ecx, %ecx
cmpb $0x0, 0x10(%r15,%rcx)
je 0x4cfc
addq $0x20, %rcx
cmpl %eax, %ecx
jl 0x4cc8
movq %r14, %rdi
movl %r12d, %esi
callq 0x46dc
movl %eax, %r12d
incl %r13d
cmpl 0x30(%r14), %r13d
jl 0x4cb0
leaq -0x34(%rbp), %rsi
movq $-0x1, (%rsi)
jmp 0x4d06
leaq -0x34(%rbp), %rsi
movl %r12d, (%rsi)
movl %ecx, 0x4(%rsi)
leaq -0x29(%rbp), %rcx
movl $0x2, %edx
movq %rbx, %rdi
callq 0x4bb4
movq %rbx, %rax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O3/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 0x464c
movq (%rbx), %rax
movl (%rax), %esi
movq %r14, %rdi
movq %r15, %rdx
callq 0x45a0
leaq -0x18(%rbp), %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/phillip-h[P]todo/src/args.cpp
// Function: printLists()
void printLists()
{
    auto list = listFiles(TodoList::getSaveDir());

    cout << ANSI_BLUE << "to-do lists:\n" << ANSI_RESET;
    cout << "\n";

    unsigned count = 0;
    const unsigned width = getTermWidth();
    
    for (unsigned i = 0; i < list.size(); i++){
        if (count + list.at(i).length() + 10 >= width){
            count = 0;
            cout << "\n";
        }
        cout << ANSI_GREEN << list.at(i) << "  ";
        count += list.at(i).length() + 2;
    }

    cout << ANSI_RESET << "\n";
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
callq 0x9030
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x595a
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x545c
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32b0
movq 0xafed(%rip), %rsi      # 0x10450
movq 0xafee(%rip), %rdx      # 0x10458
movq 0xab5f(%rip), %rdi      # 0xffd0
callq 0x3310
movq %rax, %rbx
leaq 0x6c64(%rip), %rsi      # 0xc0e4
movl $0xd, %edx
movq %rax, %rdi
callq 0x3310
movq 0xaf5c(%rip), %rsi      # 0x103f0
movq 0xaf5d(%rip), %rdx      # 0x103f8
movq %rbx, %rdi
callq 0x3310
movq 0xab26(%rip), %rdi      # 0xffd0
leaq 0x6c31(%rip), %rsi      # 0xc0e2
movl $0x1, %edx
callq 0x3310
xorl %r13d, %r13d
leaq 0x20(%rsp), %rdx
movl $0x5413, %esi           # imm = 0x5413
xorl %edi, %edi
xorl %eax, %eax
callq 0x33a0
movq 0x8(%rsp), %rax
cmpq %rax, 0x10(%rsp)
je 0x55ae
movzwl 0x22(%rsp), %ebp
movl $0x1, %r12d
movq 0xaadd(%rip), %rbx      # 0xffd0
xorl %r15d, %r15d
movl %r13d, %ecx
movq %r15, %r14
shlq $0x5, %r14
movq 0x8(%rax,%r14), %rax
addq %rcx, %rax
addq $0xa, %rax
cmpq %rbp, %rax
jb 0x5528
xorl %r13d, %r13d
movl $0x1, %edx
movq %rbx, %rdi
leaq 0x6bbf(%rip), %rsi      # 0xc0e2
callq 0x3310
movq 0xaf01(%rip), %rsi      # 0x10430
movq 0xaf02(%rip), %rdx      # 0x10438
movq %rbx, %rdi
callq 0x3310
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rdx
subq %rcx, %rdx
sarq $0x5, %rdx
cmpq %r15, %rdx
jbe 0x55f5
movq (%rcx,%r14), %rsi
movq 0x8(%rcx,%r14), %rdx
movq %rax, %rdi
callq 0x3310
movl $0x2, %edx
movq %rax, %rdi
leaq 0x6f60(%rip), %rsi      # 0xc4d8
callq 0x3310
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq %r15, %rdx
jbe 0x55f5
movl 0x8(%rax,%r14), %ecx
addl %ecx, %r13d
addl $0x2, %r13d
movl %r12d, %r15d
incl %r12d
cmpq %r15, %rdx
ja 0x54f6
movq 0xae3b(%rip), %rsi      # 0x103f0
movq 0xae3c(%rip), %rdx      # 0x103f8
movq 0xaa0d(%rip), %rdi      # 0xffd0
callq 0x3310
leaq 0x6b13(%rip), %rsi      # 0xc0e2
movl $0x1, %edx
movq %rax, %rdi
callq 0x3310
leaq 0x8(%rsp), %rdi
callq 0x5b8a
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6dec(%rip), %rdi      # 0xc3e8
movq %r15, %rsi
xorl %eax, %eax
callq 0x3410
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5639
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32b0
jmp 0x5639
jmp 0x562c
jmp 0x562c
jmp 0x562c
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x5b8a
movq %rbx, %rdi
callq 0x3500
// File: /workspace/github_cpp_makefile_star2_O3/phillip-h[P]todo/src/args.cpp
// Function: listFiles(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
vector<string> listFiles(string dir)
{
    auto list = std::vector<std::string>();

    DIR *dp;
    struct dirent *dirp;
    if ((dp = opendir(dir.c_str())) == NULL){
        cout << ANSI_RED << "Could not find directory \"";
        cout << dir << "\" !\n";
        cout << ANSI_RESET;
    }

    while ((dirp = readdir(dp)) != NULL){
        if (dirp->d_name[0] != '.'){
            string name(dirp->d_name);
            if (name.size() > extension.size()){
                name = name.substr(0, name.size() - extension.size());
            }
            if (!name.empty()){
                list.push_back(name);
            }
        }
    }
    closedir(dp);
    
    return list;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r15
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq (%rsi), %rdi
callq 0x3400
movq %rax, %r14
testq %rax, %rax
jne 0x59fb
movq 0xaa7d(%rip), %rsi      # 0x10410
movq 0xaa7e(%rip), %rdx      # 0x10418
movq 0xa62f(%rip), %rdi      # 0xffd0
callq 0x3310
leaq 0x6717(%rip), %rsi      # 0xc0c4
movl $0x1a, %edx
movq %rax, %rdi
callq 0x3310
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0xa608(%rip), %rdi      # 0xffd0
callq 0x3310
leaq 0x670b(%rip), %rsi      # 0xc0df
movl $0x4, %edx
movq %rax, %rdi
callq 0x3310
movq 0xaa08(%rip), %rsi      # 0x103f0
movq 0xaa09(%rip), %rdx      # 0x103f8
movq 0xa5da(%rip), %rdi      # 0xffd0
callq 0x3310
leaq 0x18(%rsp), %rbp
leaq 0x8(%rsp), %r15
leaq 0x28(%rsp), %r12
movq %r14, %rdi
callq 0x3420
movq %rax, %r13
testq %rax, %rax
je 0x5abf
cmpb $0x2e, 0x13(%r13)
je 0x5a0a
addq $0x13, %r13
movq %rbp, 0x8(%rsp)
movq %r13, %rdi
callq 0x3170
leaq (%rax,%r13), %rdx
movq %r15, %rdi
movq %r13, %rsi
callq 0x5c8a
movq 0x10(%rsp), %rax
movq %rax, %rcx
subq 0xa964(%rip), %rcx      # 0x103b8
jbe 0x5a8f
movq %r12, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x32c0
movq %r15, %rdi
movq %r12, %rsi
callq 0x3360
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x5a8a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32b0
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x5a9f
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5b4c
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x5a0a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x32b0
jmp 0x5a0a
movq %r14, %rdi
callq 0x3490
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5afb
jmp 0x5add
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x5afe
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x32b0
jmp 0x5afe
jmp 0x5afb
movq %rax, %r14
movq %rbx, %rdi
callq 0x5b8a
movq %r14, %rdi
callq 0x3500