LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/williewillus[P]panda_scratchpad/src/utils/Tester.cpp
// Function: Tester::restore_snapshot()
int Tester::restore_snapshot() {
	cout << "Restoring snapshot of " << record_device_path 
		<< " to " << replay_device_path << endl;
	string command = "dd if=" MNT_POINT_SNAPSHOT "/" SNAPSHOT_NAME 
		" of=" + replay_device_path + " bs=1M count=" + to_string(device_size);
	cout << "Restore snapshot dev command is : " << command << endl;
	if (system(command.c_str()) != 0 ) {
		return RESTORE_ERR;
	}
	return SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
movq 0xd7c4(%rip), %rdi      # 0x19fc0
leaq 0x58b0(%rip), %rsi      # 0x120b3
callq 0x5480
leaq 0x50(%rbx), %rsi
movq %rax, %rdi
callq 0x5410
leaq 0x5a9f(%rip), %rsi      # 0x122ba
movq %rax, %rdi
callq 0x5480
leaq 0x70(%rbx), %r14
movq %rax, %rdi
movq %r14, %rsi
callq 0x5410
movq %rax, %rdi
callq 0x5240
leaq 0x5889(%rip), %rsi      # 0x120ca
leaq -0x98(%rbp), %r15
movq %r15, %rdi
movq %r14, %rdx
callq 0xbd84
leaq 0x5895(%rip), %rdx      # 0x120ef
leaq -0x78(%rbp), %rdi
movq %r15, %rsi
callq 0x739c
movq 0x90(%rbx), %rsi
leaq -0x58(%rbp), %rdi
callq 0xd8a4
leaq -0x38(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0xd833
leaq -0x58(%rbp), %rdi
callq 0x58a8
leaq -0x78(%rbp), %rdi
callq 0x58a8
leaq -0x98(%rbp), %rdi
callq 0x58a8
movq 0xd714(%rip), %rdi      # 0x19fc0
leaq 0x584a(%rip), %rsi      # 0x120fd
callq 0x5480
leaq -0x38(%rbp), %rsi
movq %rax, %rdi
callq 0x5410
movq %rax, %rdi
callq 0x5240
movq -0x38(%rbp), %rdi
callq 0x53e0
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
leal -0x2(,%rcx,2), %ebx
leaq -0x38(%rbp), %rdi
callq 0x58a8
movl %ebx, %eax
addq $0x88, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x58a8
jmp 0xc90d
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x58a8
jmp 0xc91b
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
jmp 0xc92b
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x58a8
movq %rbx, %rdi
callq 0x5780
// File: /workspace/github_cpp_makefile_star2_O2/williewillus[P]panda_scratchpad/src/utils/Tester.cpp
// Function: Tester::mount_device(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int Tester::mount_device(string device_path, string mount_point) {
	string command = fs_commands_->GetMountCommand(device_path, mount_point);
	if (system(command.c_str()) != 0) {
		return MNT_ERR;
	}
	return SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rcx
movq %rsi, %rdx
movq 0x8(%rdi), %rsi
movq (%rsi), %rax
leaq -0x28(%rbp), %rbx
movq %rbx, %rdi
callq *0x10(%rax)
movq (%rbx), %rdi
callq 0x53e0
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
leal (%rcx,%rcx,2), %ebx
addl $-0x3, %ebx
leaq -0x28(%rbp), %rdi
callq 0x58a8
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %rbp
retq
movq %rax, %rbx
leaq -0x28(%rbp), %rdi
callq 0x58a8
movq %rbx, %rdi
callq 0x5780
nop
// File: /workspace/github_cpp_makefile_star2_O2/williewillus[P]panda_scratchpad/src/utils/Tester.cpp
// Function: Tester::format_and_mount_device(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int Tester::format_and_mount_device(string device_path, string mount_point) {
	string command = fs_commands_->GetMkfsCommand(device_path, mount_point);
	if (system(command.c_str()) != 0) {
		return FMT_ERR;
	}
	return SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rcx
movq %rsi, %rdx
movq 0x8(%rdi), %rsi
movq (%rsi), %rax
leaq -0x28(%rbp), %rbx
movq %rbx, %rdi
callq *0x8(%rax)
movq (%rbx), %rdi
callq 0x53e0
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
leal -0x4(,%rcx,4), %ebx
leaq -0x28(%rbp), %rdi
callq 0x58a8
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %rbp
retq
movq %rax, %rbx
leaq -0x28(%rbp), %rdi
callq 0x58a8
movq %rbx, %rdi
callq 0x5780
// File: /workspace/github_cpp_makefile_star2_O2/williewillus[P]panda_scratchpad/src/utils/Tester.cpp
// Function: Tester::cleanup_harness()
void Tester::cleanup_harness() {
	int umount_res;
	int err;
	do {
		umount_res = umount_device();
		if (umount_res < 0) {
			err = errno;
			usleep(500);
		}
	}while (umount_res < 0 && err == EBUSY);

	if (umount_res < 0) {
		cerr << "Unable to unmount device" << endl;
		test_unload_class();
		return; 
	}

	test_unload_class();
	if (fs_commands_ != NULL) {
		delete fs_commands_;
		fs_commands_ = NULL;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq %rbx, %rdi
callq 0xc9f0
testl %eax, %eax
jns 0xd667
callq 0x5050
movl (%rax), %r14d
movl $0x1f4, %edi            # imm = 0x1F4
callq 0x55d0
cmpl $0x10, %r14d
je 0xd618
movq 0xc9ad(%rip), %rdi      # 0x19ff0
leaq 0x4ce2(%rip), %rsi      # 0x1232c
callq 0x5480
movq %rax, %rdi
callq 0x5240
addq $0x10, %rbx
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0xdae6
leaq 0x10(%rbx), %rdi
callq 0xdae6
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0xd683
callq 0x5470
andq $0x0, 0x8(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/williewillus[P]panda_scratchpad/src/utils/Tester.cpp
// Function: operator<<(std::ostream&, Tester::time_stats)
std::ostream& operator<<(std::ostream& os, Tester::time_stats time) {
	switch (time) {
		case Tester::SNAPSHOT_TIME:
			os << "snapshot restore time";
			break;
		case Tester::TEST_CASE_TIME:
			os << "test case time";
			break;
		case Tester::MOUNT_TIME:
			os << "mount/umount time";
			break;
		case Tester::TOTAL_TIME:
			os << "total time";
			break;
		default:
			os.setstate(std::ios_base::failbit);
	}
	return os;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
decl %esi
cmpl $0x5, %esi
ja 0xd728
leaq 0x4871(%rip), %rax      # 0x11f5c
movslq (%rax,%rsi,4), %rcx
addq %rax, %rcx
jmpq *%rcx
leaq 0x4c4a(%rip), %rsi      # 0x12345
jmp 0xd716
leaq 0x4c66(%rip), %rsi      # 0x1236a
jmp 0xd716
leaq 0x4c4e(%rip), %rsi      # 0x1235b
jmp 0xd716
leaq 0x4c66(%rip), %rsi      # 0x1237c
movq %rbx, %rdi
callq 0x5480
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
pushq $0x4
popq %rsi
callq 0x5300
jmp 0xd71e
// File: /workspace/github_cpp_makefile_star2_O2/williewillus[P]panda_scratchpad/src/utils/ClassLoader.h
// Function: int utils::ClassLoader<tests::BaseTestCase>::load_class<tests::BaseTestCase* (*)()>(char const*, char const*, char const*)
int load_class(const char *path, const char *factory_name,
      const char *defactory_name) {
    const char* dl_error = NULL;

    loader_handle = dlopen(path, RTLD_LAZY);
    if (loader_handle == NULL) {
      std::cerr << "Error loading class " << path << std::endl
        << dlerror() << std::endl;
      return CASE_HANDLE_ERR;
    }

    // Get needed methods from loaded class.
    factory = dlsym(loader_handle, factory_name);
    dl_error = dlerror();
    if (dl_error) {
      std::cerr << "Error gettig factory method " << dl_error << std::endl;
      dlclose(loader_handle);
      factory = NULL;
      defactory = NULL;
      loader_handle = NULL;
      return CASE_INIT_ERR;
    }
    defactory = dlsym(loader_handle, defactory_name);
    dl_error = dlerror();
    if (dl_error) {
      std::cerr << "Error gettig deleter method " << dl_error << std::endl;
      dlclose(loader_handle);
      factory = NULL;
      defactory = NULL;
      loader_handle = NULL;
      return CASE_DEST_ERR;
    }
    instance = ((F)(factory))();
    return SUCCESS;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rbx
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0x5590
movq %rax, (%rbx)
testq %rax, %rax
je 0xda34
movq %rax, %rdi
movq %r12, %rsi
callq 0x5450
movq %rax, 0x8(%rbx)
callq 0x5460
testq %rax, %rax
je 0xda79
movq %rax, %r15
movq 0xc5f5(%rip), %rdi      # 0x19ff0
leaq 0x4a15(%rip), %rsi      # 0x12417
callq 0x5480
movq %rax, %rdi
movq %r15, %rsi
callq 0x5480
movq %rax, %rdi
callq 0x5240
movq (%rbx), %rdi
callq 0x53a0
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
pushq $-0x2
jmp 0xdad0
movq 0xc5b5(%rip), %rdi      # 0x19ff0
leaq 0x49c0(%rip), %rsi      # 0x12402
callq 0x5480
movq %rax, %rdi
movq %r15, %rsi
callq 0x5480
movq %rax, %rdi
callq 0x5240
movq %rax, %rbx
callq 0x5460
movq %rbx, %rdi
movq %rax, %rsi
callq 0x5480
movq %rax, %rdi
callq 0x5240
pushq $-0x1
jmp 0xdad0
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x5450
movq %rax, 0x10(%rbx)
callq 0x5460
testq %rax, %rax
je 0xdada
movq %rax, %r14
movq 0xc554(%rip), %rdi      # 0x19ff0
leaq 0x4991(%rip), %rsi      # 0x12434
callq 0x5480
movq %rax, %rdi
movq %r14, %rsi
callq 0x5480
movq %rax, %rdi
callq 0x5240
movq (%rbx), %rdi
callq 0x53a0
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
pushq $-0x3
popq %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq *0x8(%rbx)
movq %rax, 0x18(%rbx)
xorl %eax, %eax
jmp 0xdad1
nop
// File: /workspace/github_cpp_makefile_star2_O2/williewillus[P]panda_scratchpad/src/utils/ClassLoader.h
// Function: void utils::ClassLoader<tests::BaseTestCase>::unload_class<void (*)(tests::BaseTestCase*)>()
void unload_class() {
    if (loader_handle != NULL && instance != NULL) {
      ((DF)(defactory))(instance);
      dlclose(loader_handle);
      factory = NULL;
      defactory = NULL;
      loader_handle = NULL;
      instance = NULL;
    }
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
cmpq $0x0, (%rdi)
je 0xdb13
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
testq %rdi, %rdi
je 0xdb13
callq *0x10(%rbx)
movq (%rbx), %rdi
callq 0x53a0
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movups %xmm0, 0x10(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/williewillus[P]panda_scratchpad/src/checker/DiskContents.cpp
// Function: fileAttributes::fileAttributes()
fileAttributes::fileAttributes() {
  md5sum = "";
  // Initialize dir_attr entries
  dir_attr.d_ino = -1;
  dir_attr.d_off = -1;
  dir_attr.d_reclen = -1;
  dir_attr.d_type = -1;
  dir_attr.d_name[0] = '\0';
  // Initialize stat_attr entried
  stat_attr.st_ino == -1;
  stat_attr.st_mode = -1;
  stat_attr.st_nlink = -1;
  stat_attr.st_uid = -1;
  stat_attr.st_gid = -1;
  stat_attr.st_size = -1;
  stat_attr.st_blksize = -1;
  stat_attr.st_blocks = -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x1a8(%rdi), %r14
leaq 0x1b8(%rdi), %rax
movq %rax, 0x1a8(%rdi)
andq $0x0, 0x1b0(%rdi)
movb $0x0, 0x1b8(%rdi)
leaq 0x2ff7(%rip), %rsi      # 0x1110c
movq %r14, %rdi
callq 0x5820
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, (%rbx)
orl $-0x1, 0xf(%rbx)
movb $0x0, 0x13(%rbx)
movdqu %xmm0, 0x128(%rbx)
orl $-0x1, 0x138(%rbx)
movdqu %xmm0, 0x148(%rbx)
orq $-0x1, 0x158(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rbx
movq %r14, %rdi
callq 0x58a8
movq %rbx, %rdi
callq 0x5780
// File: /workspace/github_cpp_makefile_star2_O2/williewillus[P]panda_scratchpad/src/checker/DiskContents.cpp
// Function: fileAttributes::set_stat_attr(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool)
void fileAttributes::set_stat_attr(string path, bool islstat) {
  if (islstat) {
    lstat(path.c_str(), &stat_attr);
  } else {
    stat(path.c_str(), &stat_attr);
  }
  return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, %rax
movq (%rsi), %rdi
addq $0x118, %rax            # imm = 0x118
movq %rax, %rsi
testl %edx, %edx
je 0xe1d9
popq %rbp
jmp 0x5840
popq %rbp
jmp 0x5420
nop
// File: /workspace/github_cpp_makefile_star2_O2/williewillus[P]panda_scratchpad/src/checker/DiskContents.cpp
// Function: fileAttributes::set_md5sum(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void fileAttributes::set_md5sum(string file_path) {
  FILE *fp;
  string command = "md5sum " + file_path;
  char md5[100];
  fp = popen(command.c_str(), "r");
  fscanf(fp, "%s", md5);
  fclose(fp);
  md5sum = string(md5);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0xb0, %rsp
movq %rsi, %rdx
movq %rdi, %rbx
leaq 0x44cb(%rip), %rsi      # 0x126c6
leaq -0x38(%rbp), %r14
movq %r14, %rdi
callq 0xbd84
movq (%r14), %rdi
leaq 0x3263(%rip), %rsi      # 0x11474
callq 0x5160
movq %rax, %r14
leaq 0x4309(%rip), %rsi      # 0x12529
leaq -0xc0(%rbp), %rdx
movq %rax, %rdi
xorl %eax, %eax
callq 0x57c0
movq %r14, %rdi
callq 0x5490
leaq -0x58(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
leaq -0x11(%rbp), %rdx
callq 0x51c0
addq $0x1a8, %rbx            # imm = 0x1A8
leaq -0x58(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x54f0
movq %r14, %rdi
callq 0x58a8
leaq -0x38(%rbp), %rdi
callq 0x58a8
addq $0xb0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
jmp 0xe282
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x58a8
movq %rbx, %rdi
callq 0x5780
// File: /workspace/github_cpp_makefile_star2_O2/williewillus[P]panda_scratchpad/src/checker/DiskContents.cpp
// Function: fileAttributes::compare_dir_attr(dirent)
bool fileAttributes::compare_dir_attr(struct dirent a) {

  return ((dir_attr.d_ino == a.d_ino) &&
    (dir_attr.d_off == a.d_off) &&
    (dir_attr.d_reclen == a.d_reclen) &&
    (dir_attr.d_type == a.d_type) &&
    (strcmp(dir_attr.d_name, a.d_name) == 0));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq (%rdi), %rax
cmpq 0x10(%rbp), %rax
jne 0xe2d7
leaq 0x10(%rbp), %rsi
movq 0x8(%rdi), %rax
cmpq 0x8(%rsi), %rax
jne 0xe2d7
movzwl 0x10(%rdi), %eax
cmpw 0x10(%rsi), %ax
jne 0xe2d7
movb 0x12(%rdi), %al
cmpb 0x12(%rsi), %al
jne 0xe2d7
addq $0x13, %rdi
addq $0x13, %rsi
callq 0x55b0
testl %eax, %eax
sete %al
jmp 0xe2d9
xorl %eax, %eax
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/williewillus[P]panda_scratchpad/src/checker/DiskContents.cpp
// Function: fileAttributes::compare_stat_attr(stat)
bool fileAttributes::compare_stat_attr(struct stat a) {

  return ((stat_attr.st_ino == a.st_ino) &&
    (stat_attr.st_mode == a.st_mode) &&
    (stat_attr.st_nlink == a.st_nlink) &&
    (stat_attr.st_uid == a.st_uid) &&
    (stat_attr.st_gid == a.st_gid) &&
    // (stat_attr.st_rdev == a.st_rdev) &&
    // (stat_attr.st_dev == a.st_dev) &&
    (stat_attr.st_size == a.st_size) &&
    (stat_attr.st_blksize == a.st_blksize) &&
    (stat_attr.st_blocks == a.st_blocks));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
addq $0x120, %rdi            # imm = 0x120
leaq 0x18(%rbp), %rsi
pushq $0x1c
popq %rdx
callq 0x5200
testl %eax, %eax
je 0xe300
xorl %eax, %eax
jmp 0xe31f
leaq 0x10(%rbp), %rsi
addq $0x148, %rbx            # imm = 0x148
addq $0x30, %rsi
pushq $0x18
popq %rdx
movq %rbx, %rdi
callq 0x5200
testl %eax, %eax
sete %al
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/williewillus[P]panda_scratchpad/src/checker/DiskContents.cpp
// Function: DiskContents::mount_disk()
int DiskContents::mount_disk() {
  // Construct and set mount_point
  mount_point = "/mnt/";
  mount_point += disk_path.substr(5);
  // Create the mount directory with read/write/search permissions for owner and group, 
  // and with read/search permissions for others.
  int ret = mkdir(mount_point.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
  if (ret == -1 && errno != EEXIST) {
    cout << "creating mountpoint failed" << endl;
    return -1;
  }
  // Mount the disk
  if (mount(disk_path.c_str(), mount_point.c_str(), fs_type.c_str(), MS_RDONLY, NULL) < 0) {
    return -1;
  }
  // sleep after mount
  unsigned int to_sleep = 0;
  do {
    to_sleep = sleep(to_sleep);
  } while (to_sleep > 0);

  device_mounted = true;
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x28(%rdi), %r14
leaq 0x3f45(%rip), %rsi      # 0x12616
movq %r14, %rdi
callq 0x5820
leaq 0x8(%rbx), %rsi
leaq -0x38(%rbp), %r15
pushq $0x5
popq %rdx
pushq $-0x1
popq %rcx
movq %r15, %rdi
callq 0x54b0
movq %r14, %rdi
movq %r15, %rsi
callq 0x5850
leaq -0x38(%rbp), %rdi
callq 0x58a8
movq (%r14), %rdi
movl $0x1fd, %esi            # imm = 0x1FD
callq 0x5210
cmpl $-0x1, %eax
jne 0xe71f
callq 0x5050
cmpl $0x11, (%rax)
jne 0xe753
movq 0x8(%rbx), %rdi
movq 0x28(%rbx), %rsi
movq 0x48(%rbx), %rdx
xorl %r14d, %r14d
pushq $0x1
popq %rcx
xorl %r8d, %r8d
callq 0x57f0
testl %eax, %eax
js 0xe76e
movl %r14d, %edi
callq 0x5360
movl %eax, %r14d
testl %eax, %eax
jne 0xe73d
movb $0x1, (%rbx)
xorl %eax, %eax
jmp 0xe771
movq 0xb866(%rip), %rdi      # 0x19fc0
leaq 0x3ebb(%rip), %rsi      # 0x1261c
callq 0x5480
movq %rax, %rdi
callq 0x5240
pushq $-0x1
popq %rax
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x58a8
movq %rbx, %rdi
callq 0x5780
// File: /workspace/github_cpp_makefile_star2_O2/williewillus[P]panda_scratchpad/src/checker/DiskContents.cpp
// Function: DiskContents::unmount_and_delete_mount_point()
int DiskContents::unmount_and_delete_mount_point() {
  // umount till successful
  int umount_res;
  int err;
  string command = "umount ";
  command += mount_point;
  do {
    umount_res = system(command.c_str());
    if (umount_res < 0) {
      err = errno;
      usleep(500);
    }
  } while (umount_res < 0 && err == EBUSY);

  // Delete the mount directory
  if (unlink(mount_point.c_str()) != 0) {
    return -1;
  }
  device_mounted = false;
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x3e90(%rip), %rsi      # 0x12637
leaq -0x40(%rbp), %r15
leaq -0x19(%rbp), %rdx
movq %r15, %rdi
callq 0x51c0
leaq 0x28(%rbx), %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x5850
movq -0x40(%rbp), %rdi
callq 0x53e0
testl %eax, %eax
jns 0xe7eb
callq 0x5050
movl (%rax), %r15d
movl $0x1f4, %edi            # imm = 0x1F4
callq 0x55d0
cmpl $0x10, %r15d
je 0xe7c6
movq (%r14), %rdi
callq 0x5230
testl %eax, %eax
je 0xe7fc
pushq $-0x1
popq %rbx
jmp 0xe801
movb $0x0, (%rbx)
xorl %ebx, %ebx
leaq -0x40(%rbp), %rdi
callq 0x58a8
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0xe819
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x58a8
movq %rbx, %rdi
callq 0x5780
nop
// File: /workspace/github_cpp_makefile_star2_O2/williewillus[P]panda_scratchpad/src/checker/DiskContents.cpp
// Function: isEmptyDirOrFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool isEmptyDirOrFile(string path) {
  DIR *directory = opendir(path.c_str());
  if (directory == NULL) {
    return true;
  }

  struct dirent *dir_entry;
  int num_dir_entries = 0;
  while (dir_entry = readdir(directory)) {
    if (++num_dir_entries > 2) {
      break;
    }
  }
  closedir(directory);
  if (num_dir_entries <= 2) {
    return true;
  }
  return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq (%rdi), %rdi
callq 0x5640
testq %rax, %rax
je 0xfa16
movq %rax, %rbx
xorl %r14d, %r14d
pushq $0x3
popq %r15
movq %rbx, %rdi
callq 0x5670
testq %rax, %rax
je 0xfa05
incl %r14d
cmpl $0x3, %r14d
jne 0xf9ec
movl %r15d, %r14d
movq %rbx, %rdi
callq 0x56d0
cmpl $0x3, %r14d
setb %al
jmp 0xfa18
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/williewillus[P]panda_scratchpad/src/checker/DiskContents.cpp
// Function: isFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool isFile(string path) {
  struct stat sb;
  if (stat(path.c_str(), &sb) < 0) {
    cout << __func__ << ": Failed stating " << path << endl;
    return false;
  }
  if (S_ISDIR(sb.st_mode)) {
    return false;
  }
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
movq (%rdi), %rdi
leaq -0x98(%rbp), %rsi
callq 0x5420
testl %eax, %eax
js 0xfa57
movl $0xf000, %eax           # imm = 0xF000
andl -0x80(%rbp), %eax
cmpl $0x4000, %eax           # imm = 0x4000
setne %al
jmp 0xfa8e
movq 0xa562(%rip), %rdi      # 0x19fc0
leaq 0x2cf3(%rip), %rsi      # 0x12758
callq 0x5480
leaq 0x2cee(%rip), %rsi      # 0x1275f
movq %rax, %rdi
callq 0x5480
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5410
movq %rax, %rdi
callq 0x5240
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/williewillus[P]panda_scratchpad/src/checker/DiskContents.cpp
// Function: DiskContents::makeFiles(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::basic_ofstream<char, std::char_traits<char>>&)
bool DiskContents::makeFiles(string base_path, ofstream &diff_file) {
  get_contents(base_path.c_str());
  for (auto &i : contents) {
    if (S_ISDIR((i.second).stat_attr.st_mode)) {
      string filepath = base_path + i.first + "/" + "_dummy";
      int fd = open(filepath.c_str(), O_CREAT|O_RDWR);
      if (fd < 0) {
        diff_file <<  "Couldn't create file " << filepath << endl;
        cout <<  "Couldn't create file " << filepath << endl;
        return false;
      }
      close(fd);
    }
  }
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, -0x30(%rbp)
movq %rdi, %r14
movq %rsi, -0x38(%rbp)
movq (%rsi), %rsi
callq 0xe83c
movq 0x80(%r14), %r12
addq $0x70, %r14
movl $0xf000, %r15d          # imm = 0xF000
leaq -0x78(%rbp), %r13
leaq -0x98(%rbp), %rbx
cmpq %r14, %r12
je 0xffbb
movl 0x170(%r12), %eax
andl %r15d, %eax
cmpl $0x4000, %eax           # imm = 0x4000
jne 0xffab
leaq 0x20(%r12), %rdx
movq %r13, %rdi
movq -0x38(%rbp), %rsi
callq 0x1026b
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x2715(%rip), %rdx      # 0x1261a
callq 0x739c
leaq -0x58(%rbp), %rdi
movq %rbx, %rsi
leaq 0x2891(%rip), %rdx      # 0x127a9
callq 0x739c
movq %rbx, %rdi
callq 0x58a8
movq %r13, %rdi
callq 0x58a8
movq -0x58(%rbp), %rdi
pushq $0x42
popq %rsi
xorl %eax, %eax
callq 0x5340
movl %eax, %r15d
testl %eax, %eax
js 0xff4c
movl %r15d, %edi
callq 0x5860
jmp 0xff97
movq -0x30(%rbp), %rdi
leaq 0x2859(%rip), %rsi      # 0x127b0
callq 0x5480
movq %rax, %rdi
leaq -0x58(%rbp), %rsi
callq 0x5410
movq %rax, %rdi
callq 0x5240
movq 0xa049(%rip), %rdi      # 0x19fc0
leaq 0x2832(%rip), %rsi      # 0x127b0
callq 0x5480
movq %rax, %rdi
leaq -0x58(%rbp), %rsi
callq 0x5410
movq %rax, %rdi
callq 0x5240
leaq -0x58(%rbp), %rdi
callq 0x58a8
testl %r15d, %r15d
movl $0xf000, %r15d          # imm = 0xF000
js 0xffbb
movq %r12, %rdi
callq 0x5330
movq %rax, %r12
jmp 0xfec8
cmpq %r14, %r12
sete %al
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0x58a8
jmp 0xffe4
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
jmp 0xfff1
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x58a8
movq %rbx, %rdi
callq 0x5780
// File: /workspace/github_cpp_makefile_star2_O2/williewillus[P]panda_scratchpad/src/checker/DiskContents.cpp
// Function: DiskContents::sanity_checks(std::basic_ofstream<char, std::char_traits<char>>&)
bool DiskContents::sanity_checks(ofstream &diff_file) {
  cout << __func__ << endl;
  string base_path = "/mnt/pmem0";
  if (!makeFiles(base_path, diff_file)) {
    cout << "Failed: Couldn't create files in all directories" << endl;
    diff_file << "Failed: Couldn't create files in all directories" << endl;
    return false;
  }

  if (!deleteFiles(base_path, diff_file)) {
    cout << "Failed: Couldn't delete all the existing directories" << endl;
    diff_file << "Failed: Couldn't delete all the existing directories" << endl;
    return false;
  }

  cout << "Passed sanity checks" << endl;
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x68, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x9fa8(%rip), %rdi      # 0x19fc0
leaq 0x27a7(%rip), %rsi      # 0x127c6
callq 0x5480
movq %rax, %rdi
callq 0x5240
leaq 0x217f(%rip), %rsi      # 0x121b2
leaq -0x80(%rbp), %r15
leaq -0x19(%rbp), %rdx
movq %r15, %rdi
callq 0x51c0
leaq -0x60(%rbp), %rdi
movq %r15, %rsi
callq 0x5580
leaq -0x60(%rbp), %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0xfe88
movl %eax, %r15d
leaq -0x60(%rbp), %rdi
callq 0x58a8
testb %r15b, %r15b
je 0x100bb
leaq -0x40(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x5580
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0xfa98
movl %eax, %r14d
leaq -0x40(%rbp), %rdi
callq 0x58a8
testb %r14b, %r14b
je 0x100db
movq 0x9f1d(%rip), %rdi      # 0x19fc0
leaq 0x2790(%rip), %rsi      # 0x1283a
callq 0x5480
movb $0x1, %bl
movq %rax, %rdi
callq 0x5240
jmp 0x1010e
movq 0x9efe(%rip), %rdi      # 0x19fc0
leaq 0x270b(%rip), %r14      # 0x127d4
movq %r14, %rsi
callq 0x5480
movq %rax, %rdi
callq 0x5240
jmp 0x100f9
movq 0x9ede(%rip), %rdi      # 0x19fc0
leaq 0x271c(%rip), %r14      # 0x12805
movq %r14, %rsi
callq 0x5480
movq %rax, %rdi
callq 0x5240
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5480
movq %rax, %rdi
callq 0x5240
xorl %ebx, %ebx
leaq -0x80(%rbp), %rdi
callq 0x58a8
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
jmp 0x10134
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x58a8
jmp 0x1013e
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x58a8
movq %rbx, %rdi
callq 0x5780
// File: /workspace/github_cpp_makefile_star2_O2/ch4rli3kop[P]ch4rli3-fuzzer/main.cc
// Function: is_newPath()
bool is_newPath(){
	uint8_t *digest = sha256((unsigned char*)shmAddr, 0x1000);

	for (int i = 0; i < path.size(); i++){
		if (!memcmp(digest, path[i], 32)) return false;
	}

	path.push_back(digest);
	totalpath++;
	
	// debug
	// cout << "Path : " << totalpath << endl;
	// char buf[2*SHA256::DIGEST_SIZE+1];
    // buf[2*SHA256::DIGEST_SIZE] = 0;
    // for (int i = 0; i < SHA256::DIGEST_SIZE; i++)
    //     sprintf(buf+i*2, "%02x", digest[i]);
	// cout << buf << endl;

	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x4cbf(%rip), %rdi      # 0x71e0
movl $0x1000, %esi           # imm = 0x1000
callq 0x3a9c
movq %rax, %rbx
movq %rax, -0x30(%rbp)
movq 0x4d37(%rip), %r15      # 0x7270
movq 0x4d28(%rip), %r13      # 0x7268
subq %r13, %r15
sarq $0x3, %r15
xorl %ecx, %ecx
pushq $0x20
popq %r14
movq %rcx, %r12
cmpq %rcx, %r15
je 0x2570
movq (%r13,%r12,8), %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x21b0
leaq 0x1(%r12), %rcx
testl %eax, %eax
jne 0x254d
jmp 0x2586
leaq 0x4cf1(%rip), %rdi      # 0x7268
leaq -0x30(%rbp), %rsi
callq 0x2d36
incl 0x4c6a(%rip)            # 0x71f0
cmpq %r12, %r15
setbe %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/ch4rli3kop[P]ch4rli3-fuzzer/main.cc
// Function: Add_cur_input()
void Add_cur_input(){
	ifstream in("out/cur_input.j2k", ios::ate);
	if (in.fail()){
        perror("open cur_input error!\n");
        exit(-1);
    }
	uint32_t length = in.tellg();
	in.seekg(0, ios::beg);
	uint8_t* buf = new uint8_t[length+1];
    in.read((char*)buf, length);
	
	string fileName = "out/crash/input_" + to_string(crash);
	ofstream out(fileName, ios::binary);
	out.write((char*)buf, length);
	out.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x430, %rsp            # imm = 0x430
leaq 0x1b4d(%rip), %rsi      # 0x4118
leaq -0x438(%rbp), %rbx
pushq $0x2
popq %rdx
movq %rbx, %rdi
callq 0x2330
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x418(%rbp,%rax)
jne 0x26c5
leaq -0x438(%rbp), %rdi
callq 0x2300
movq %rax, %r14
leaq -0x438(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2230
leal 0x1(%r14), %edi
callq 0x2030
movq %rax, %rbx
movl %r14d, %r14d
leaq -0x438(%rbp), %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x2200
movl 0x4bc0(%rip), %esi      # 0x71f8
leaq -0x230(%rbp), %rdi
callq 0x2d88
leaq 0x19ec(%rip), %rsi      # 0x4037
leaq -0x30(%rbp), %rdi
leaq -0x230(%rbp), %rdx
callq 0x2d5a
leaq -0x230(%rbp), %rdi
callq 0x20c0
leaq -0x230(%rbp), %rdi
leaq -0x30(%rbp), %rsi
pushq $0x4
popq %rdx
callq 0x2340
leaq -0x230(%rbp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2220
leaq -0x230(%rbp), %rdi
callq 0x2260
leaq -0x230(%rbp), %rdi
callq 0x2280
leaq -0x30(%rbp), %rdi
callq 0x20c0
leaq -0x438(%rbp), %rdi
callq 0x2060
addq $0x430, %rsp            # imm = 0x430
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x1954(%rip), %rdi      # 0x4020
callq 0x2140
pushq $-0x1
popq %rdi
callq 0x21e0
movq %rax, %rbx
jmp 0x26ff
movq %rax, %rbx
leaq -0x230(%rbp), %rdi
jmp 0x2703
jmp 0x270a
jmp 0x270a
jmp 0x270a
movq %rax, %rbx
leaq -0x230(%rbp), %rdi
callq 0x2280
leaq -0x30(%rbp), %rdi
callq 0x20c0
jmp 0x270d
movq %rax, %rbx
leaq -0x438(%rbp), %rdi
callq 0x2060
movq %rbx, %rdi
callq 0x2310
// File: /workspace/github_cpp_makefile_star2_O2/ch4rli3kop[P]ch4rli3-fuzzer/main.cc
// Function: Add_state(int)
void Add_state(int state){
	ofstream out("out/crash_log", ios::app);
	out << "======================================" << endl;
	out << "crash " << crash << endl;
	out << "  signal : " << (int)WTERMSIG(state) << endl;
	out.close();
	crash++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x200, %rsp            # imm = 0x200
movl %edi, %ebx
leaq 0x1910(%rip), %rsi      # 0x4048
leaq -0x210(%rbp), %r14
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0x21c0
leaq 0x1905(%rip), %rsi      # 0x4056
movq %r14, %rdi
callq 0x2180
movq %rax, %rdi
callq 0x20d0
leaq 0x1915(%rip), %rsi      # 0x407d
leaq -0x210(%rbp), %rdi
callq 0x2180
movl 0x4a7e(%rip), %esi      # 0x71f8
movq %rax, %rdi
callq 0x22f0
movq %rax, %rdi
callq 0x20d0
leaq 0x18f3(%rip), %rsi      # 0x4084
leaq -0x210(%rbp), %rdi
callq 0x2180
andl $0x7f, %ebx
movq %rax, %rdi
movl %ebx, %esi
callq 0x22f0
movq %rax, %rdi
callq 0x20d0
leaq -0x210(%rbp), %rdi
callq 0x2260
incl 0x4a34(%rip)            # 0x71f8
leaq -0x210(%rbp), %rdi
callq 0x2280
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rbx
leaq -0x210(%rbp), %rdi
callq 0x2280
movq %rbx, %rdi
callq 0x2310
// File: /workspace/github_cpp_makefile_star2_O2/ch4rli3kop[P]ch4rli3-fuzzer/main.cc
// Function: Add_to_corpus()
void Add_to_corpus(){
	ifstream in("out/cur_input.j2k", ios::ate);
	if (in.fail()){
        perror("open cur_input error!\n");
        exit(-1);
    }
	uint32_t length = in.tellg();
	in.seekg(0, ios::beg);

	uint8_t* buf = new uint8_t[length+1+4];
    memcpy(buf, &length, 4);
	in.read((char*)buf+4, length);
	corpus.insert(corpus.begin(), buf);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
leaq 0x18f8(%rip), %rsi      # 0x4118
leaq -0x218(%rbp), %rbx
pushq $0x2
popq %rdx
movq %rbx, %rdi
callq 0x2330
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x1f8(%rbp,%rax)
jne 0x28b2
leaq -0x218(%rbp), %rdi
callq 0x2300
movq %rax, %rbx
leaq -0x218(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2230
leal 0x5(%rbx), %edi
callq 0x2030
movq %rax, -0x10(%rbp)
movl %ebx, (%rax)
addq $0x4, %rax
movl %ebx, %edx
leaq -0x218(%rbp), %rdi
movq %rax, %rsi
callq 0x2200
movq 0x49c4(%rip), %rsi      # 0x7250
leaq 0x49bd(%rip), %rdi      # 0x7250
leaq -0x10(%rbp), %rdx
callq 0x2de8
leaq -0x218(%rbp), %rdi
callq 0x2060
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %rbp
retq
leaq 0x1767(%rip), %rdi      # 0x4020
callq 0x2140
pushq $-0x1
popq %rdi
callq 0x21e0
jmp 0x28cc
jmp 0x28cc
jmp 0x28cc
movq %rax, %rbx
leaq -0x218(%rbp), %rdi
callq 0x2060
movq %rbx, %rdi
callq 0x2310
// File: /workspace/github_cpp_makefile_star2_O2/ch4rli3kop[P]ch4rli3-fuzzer/main.cc
// Function: run_target(char*, char**)
void run_target(char* target, char* argvs[]){

	pid_t pid = fork();
	int state;

	if (pid < 0){
		perror("fork() error!\n");
		exit(-1);
	}
	else if (pid == 0){
		execv(target, argvs);
		totalexec++;
		exit(0);
	}
	else {
		wait(&state);

		// Check if the testcase causes crash.
		if (is_crashed(state)){
			Add_to_report(state);
		}


		// Check if the testcase hits new code path.
		if (is_newPath()){
			// If it hits new code path, Add to corpus.
			Add_to_corpus();	
		}

		//printf("status : %d\n", state);
		//printf("child exited!\n");
	}	
	
	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, %r14
callq 0x2070
testl %eax, %eax
js 0x293d
je 0x2951
leaq -0x14(%rbp), %rbx
movq %rbx, %rdi
callq 0x21f0
movl (%rbx), %edi
movl %edi, %eax
andl $0x7f, %eax
shll $0x18, %eax
addl $0x1000000, %eax        # imm = 0x1000000
cmpl $0x2000000, %eax        # imm = 0x2000000
jl 0x2926
callq 0x27f3
callq 0x250c
testb %al, %al
je 0x2934
callq 0x280d
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x174c(%rip), %rdi      # 0x4090
callq 0x2140
pushq $-0x1
popq %rdi
callq 0x21e0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2170
incl 0x4892(%rip)            # 0x71f4
xorl %edi, %edi
callq 0x21e0
// File: /workspace/github_cpp_makefile_star2_O2/ch4rli3kop[P]ch4rli3-fuzzer/main.cc
// Function: shared_memory_init()
void shared_memory_init(){
	int shmID;
	
	if ((shmID = shmget((key_t)1337, 0x1000, IPC_CREAT | 0666)) < 0 ){
		perror("shmget() error!\n");
		exit(-1);
	}
	
	if ((shmAddr = shmat(shmID, (void*)0, 0)) == (void*)-1){
		perror("shmat() error!\n");
		exit(-1);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl $0x1000, %esi           # imm = 0x1000
movl $0x539, %edi            # imm = 0x539
movl $0x3b6, %edx            # imm = 0x3B6
callq 0x2100
testl %eax, %eax
js 0x299f
movl %eax, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2250
movq %rax, 0x4849(%rip)      # 0x71e0
cmpq $-0x1, %rax
je 0x29a8
popq %rbp
retq
leaq 0x16f9(%rip), %rdi      # 0x409f
jmp 0x29af
leaq 0x1701(%rip), %rdi      # 0x40b0
callq 0x2140
pushq $-0x1
popq %rdi
callq 0x21e0
// File: /workspace/github_cpp_makefile_star2_O2/ch4rli3kop[P]ch4rli3-fuzzer/main.cc
// Function: init_corpus()
void init_corpus(){
	
	DIR *dir;
	struct dirent *entry;
	string in_dir = "./in/";

	if (!(dir = opendir(in_dir.c_str()))){
		perror("open dir error!\n");
	}

	while ((entry = readdir(dir))){
		if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name,"..")) continue;
		string filename(entry->d_name);
		ifstream in(in_dir + filename, ios::ate);

		if (in.fail()){
			perror("open file error!\n");
			exit(-1);
		}

		uint32_t length = in.tellg();
		in.seekg(0, ios::beg);

		uint8_t* buf = new uint8_t[length+1+4];
		memcpy(buf, &length, 4);
		in.read((char*)buf + 4, length);

		// cout << "./in/" << entry->d_name << endl;
		// cout << "File length : " << length << endl;
		// cout << buf << endl;
		corpus.push_back(buf);
		//input.push(buf);
	}

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
leaq 0x16e9(%rip), %rsi      # 0x40c0
leaq -0x48(%rbp), %rbx
leaq -0x290(%rbp), %rdx
movq %rbx, %rdi
callq 0x2e56
movq (%rbx), %rdi
callq 0x2290
movq %rax, %rbx
testq %rax, %rax
je 0x2b01
leaq -0x88(%rbp), %r14
leaq -0x290(%rbp), %r15
leaq -0x68(%rbp), %r12
movq %rbx, %rdi
callq 0x22a0
testq %rax, %rax
je 0x2ae6
cmpb $0x2e, 0x13(%rax)
jne 0x2a39
cmpb $0x0, 0x14(%rax)
je 0x2a10
cmpb $0x2e, 0x14(%rax)
jne 0x2a39
cmpb $0x0, 0x15(%rax)
je 0x2a10
addq $0x13, %rax
movq %r14, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x2e56
movq %r12, %rdi
leaq -0x48(%rbp), %rsi
movq %r14, %rdx
callq 0x2e91
movq %r15, %rdi
movq %r12, %rsi
pushq $0x2
popq %rdx
callq 0x22c0
movq %r12, %rdi
callq 0x20c0
movq -0x290(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x270(%rbp,%rax)
jne 0x2b12
movq %r15, %rdi
callq 0x2300
movq %rax, %r13
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2230
leal 0x5(%r13), %edi
callq 0x2030
movq %rax, -0x68(%rbp)
movl %r13d, (%rax)
addq $0x4, %rax
movl %r13d, %edx
movq %r15, %rdi
movq %rax, %rsi
callq 0x2200
leaq 0x4787(%rip), %rdi      # 0x7250
movq %r12, %rsi
callq 0x2d36
movq %r15, %rdi
callq 0x2060
movq %r14, %rdi
callq 0x20c0
jmp 0x2a10
leaq -0x48(%rbp), %rdi
callq 0x20c0
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x15be(%rip), %rdi      # 0x40c6
callq 0x2140
jmp 0x29fe
leaq 0x15be(%rip), %rdi      # 0x40d7
callq 0x2140
pushq $-0x1
popq %rdi
callq 0x21e0
jmp 0x2b3f
jmp 0x2b44
jmp 0x2b44
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x20c0
jmp 0x2b53
movq %rax, %rbx
jmp 0x2b53
movq %rax, %rbx
jmp 0x2b5f
movq %rax, %rbx
leaq -0x290(%rbp), %rdi
callq 0x2060
leaq -0x88(%rbp), %rdi
callq 0x20c0
leaq -0x48(%rbp), %rdi
callq 0x20c0
movq %rbx, %rdi
callq 0x2310
// File: /workspace/github_cpp_makefile_star2_O2/ch4rli3kop[P]ch4rli3-fuzzer/main.cc
// Function: create_input()
void create_input(){
	// make cur_input file by <vector>input
	uint8_t* data = input.front();
	uint32_t length;

	memcpy((char*)&length, data, 4);

	ofstream out("out/cur_input.j2k", ios::binary);
	out.write((char*)data + 4, length);
	out.close();
	input.pop();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq 0x464b(%rip), %rax      # 0x7210
movq (%rax), %rbx
movl (%rbx), %r14d
leaq 0x1546(%rip), %rsi      # 0x4118
leaq -0x218(%rbp), %r15
pushq $0x4
popq %rdx
movq %r15, %rdi
callq 0x21c0
addq $0x4, %rbx
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2220
leaq -0x218(%rbp), %rdi
callq 0x2260
leaq 0x45f7(%rip), %rdi      # 0x7200
callq 0x3686
leaq -0x218(%rbp), %rdi
callq 0x2280
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x218(%rbp), %rdi
callq 0x2280
movq %rbx, %rdi
callq 0x2310
// File: /workspace/github_cpp_makefile_star2_O2/ch4rli3kop[P]ch4rli3-fuzzer/main.cc
// Function: main
int main(int argc, char* argv[]){

	char* target = TARGET;
	char* argvs[] = {TARGET, "-i", "out/cur_input.j2k", "-o", "out/tmp.pgm", NULL};

	printf("[+] target : %s\n", target);

	shared_memory_init();
	init_corpus();

	while (true){
	
		for (int i = 0; i < corpus.size(); i++){
			mutation(corpus[i]);

			// run target with the input created by mutation.
			int input_size = input.size();
			for (int j = 0; j < input_size; j++){
				create_input();
				//use_radamsa();
				run_target(target, argvs);
			}
		}
	}

	// cout << corpus.size() << endl;
	// int len = corpus.size();
	// for (int i = 0; i < len; i++){
	// 	char* tmp = corpus.front();
	// 	corpus.pop();
	// 	printf("%p\n", tmp);
	// 	printf("%s\n", tmp);
	// }

	// char* Data = reinterpret_cast<char*>(shmAddr);
	// printf("%p\n", shmAddr);
	// printf("%p\n", Data);

	// printf("Result : %s\n", shmAddr);
	// for (int i = 0; i < 0x100; i++){
	// 	if (i % 0x10 == 0) printf("\n");
	// 	printf("%x ", Data[i]);
	// }

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movaps 0x4159(%rip), %xmm0     # 0x6db0
leaq -0x60(%rbp), %rbx
movaps %xmm0, 0x20(%rbx)
movaps 0x413a(%rip), %xmm0     # 0x6da0
movaps %xmm0, 0x10(%rbx)
movaps 0x411f(%rip), %xmm0     # 0x6d90
movaps %xmm0, (%rbx)
leaq 0x14ed(%rip), %rdi      # 0x4168
leaq 0x14a8(%rip), %r14      # 0x412a
movq %r14, %rsi
xorl %eax, %eax
callq 0x2040
callq 0x2969
callq 0x29bc
leaq 0x4563(%rip), %r15      # 0x7200
xorl %ecx, %ecx
movq %rcx, %r13
movq 0x45af(%rip), %rdx      # 0x7258
movq 0x45a0(%rip), %rax      # 0x7250
subq %rax, %rdx
sarq $0x3, %rdx
movl $0x0, %ecx
cmpq %r13, %rdx
jbe 0x2c9f
movq (%rax,%r13,8), %rdi
callq 0x2b8d
movq %r15, %rdi
callq 0x34d0
movq %rax, %r12
testl %r12d, %r12d
movl $0x0, %eax
cmovlel %eax, %r12d
subl $0x1, %r12d
jb 0x2cf9
callq 0x2bae
movq %r14, %rdi
movq %rbx, %rsi
callq 0x28e3
jmp 0x2ce1
incq %r13
movq %r13, %rcx
jmp 0x2c9f
nop
// File: /workspace/github_cpp_makefile_star2_O2/ch4rli3kop[P]ch4rli3-fuzzer/sha256.cpp
// Function: sha256(unsigned char*, int)
unsigned char* sha256(unsigned char* input, int length)
{
    unsigned char* digest = new unsigned char[SHA256::DIGEST_SIZE];
    memset(digest,0,SHA256::DIGEST_SIZE);
 
    SHA256 ctx = SHA256();
    ctx.init();
    ctx.update(input, length);
    ctx.final(digest);
 
    return digest;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xb0, %rsp
movl %esi, %r14d
movq %rdi, %r15
pushq $0x20
popq %rdi
callq 0x2030
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
leaq -0xc8(%rbp), %r12
movups %xmm0, 0x78(%r12)
movups %xmm0, 0x68(%r12)
movups %xmm0, 0x58(%r12)
movups %xmm0, 0x48(%r12)
movups %xmm0, 0x38(%r12)
movups %xmm0, 0x28(%r12)
movups %xmm0, 0x18(%r12)
movups %xmm0, 0x8(%r12)
movaps 0x7b9(%rip), %xmm0      # 0x42c0
movups %xmm0, 0x88(%r12)
movaps 0x7b9(%rip), %xmm0      # 0x42d0
movups %xmm0, 0x98(%r12)
andq $0x0, (%r12)
movq %r12, %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0x3902
movq %r12, %rdi
movq %rbx, %rsi
callq 0x39aa
movq %rbx, %rax
addq $0xb0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/lmclaramunt[P]AES-Crypto/Main.cpp
// Function: help(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
static void help(string name) {
    cerr<<name<<endl
        <<"Three options are provided:\n"
        <<"1. Encrypt/Decrypt with keys stored locally in default secret folder\n"
        <<"\t-e/encrypt [-p/path filePath] && (-ofb || -cbc) && "
        <<"[-b/bits length]"<<endl
        <<"\t-d/decrypt [-p/path filePath] && (-ofb || -cbc) && "
        <<"[-b/bits length]"<<endl
        <<"2. Encrypt/Decrypt using existing keys in a specified path\n"
        <<"\t-e/encrypt [-p/path filePath] && [-aes aesPath] && [-mac macPath] && "
        <<"(-ofb || -cbc)"<<endl
        <<"\t-d/decrypt [-p/path filePath] && [-aes aesPath] && [-mac macPath] && "
        <<"(-ofb || -cbc)"<<endl
        <<"3. Encrypt storing new keys in USB Drive. Include Key's filename in path to USB\n"
        <<"\t-e/encrypt [-p/path filePath] && [-aes aesPath] && [-mac macPath] && " 
        <<"(-ofb || -cbc) && [-b/bits length]"<<endl;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rsi
movq 0x833a(%rip), %rdi      # 0xaff0
callq 0x21b0
movq %rax, %rdi
callq 0x20f0
leaq 0x4478(%rip), %rsi      # 0x7142
movq %rax, %rdi
callq 0x21f0
leaq 0x4486(%rip), %rsi      # 0x715f
movq %rax, %rdi
callq 0x21f0
leaq 0x44bd(%rip), %rsi      # 0x71a5
movq %rax, %rdi
callq 0x21f0
leaq 0x4654(%rip), %rbx      # 0x734b
movq %rax, %rdi
movq %rbx, %rsi
callq 0x21f0
movq %rax, %rdi
callq 0x20f0
leaq 0x44c9(%rip), %rsi      # 0x71da
movq %rax, %rdi
callq 0x21f0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x21f0
movq %rax, %rdi
callq 0x20f0
leaq 0x44dc(%rip), %rsi      # 0x720f
movq %rax, %rdi
callq 0x21f0
leaq 0x4509(%rip), %rbx      # 0x724b
movq %rax, %rdi
movq %rbx, %rsi
callq 0x21f0
leaq 0x453e(%rip), %r14      # 0x7292
movq %rax, %rdi
movq %r14, %rsi
callq 0x21f0
movq %rax, %rdi
callq 0x20f0
leaq 0x4533(%rip), %rsi      # 0x72a1
movq %rax, %rdi
callq 0x21f0
movq %rax, %rdi
movq %r14, %rsi
callq 0x21f0
movq %rax, %rdi
callq 0x20f0
leaq 0x4558(%rip), %rsi      # 0x72e8
movq %rax, %rdi
callq 0x21f0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x21f0
leaq 0x458f(%rip), %rsi      # 0x7339
movq %rax, %rdi
callq 0x21f0
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x20f0
nop
// File: /workspace/github_cpp_makefile_star2_O2/lmclaramunt[P]AES-Crypto/Sequence.cpp
// Function: Sequence::setSize(int)
void Sequence::setSize(int _size) {
    if(_size > 16 || _size < 0) throw "Invalid capacity\n";
    if(size != _size) {
        unsigned char* temp = new unsigned char[_size];
        for(int i=0; i< _size; i++)
            temp[i] = sq[i];
        delete[] sq;
        sq = temp;
        size = _size;
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x11, %esi
jae 0x2f18
movl %esi, %ebx
movq %rdi, %r14
cmpl %esi, 0x8(%rdi)
je 0x2f0c
movl %ebx, %r12d
movq %r12, %rdi
callq 0x2030
movq %rax, %r15
movq (%r14), %rdi
xorl %eax, %eax
cmpq %rax, %r12
je 0x2efb
movb (%rdi,%rax), %cl
movb %cl, (%r15,%rax)
incq %rax
jmp 0x2eea
testq %rdi, %rdi
je 0x2f05
callq 0x2270
movq %r15, (%r14)
movl %ebx, 0x8(%r14)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
pushq $0x8
popq %rdi
callq 0x2100
leaq 0x445f(%rip), %rcx      # 0x7386
movq %rcx, (%rax)
movq 0x8097(%rip), %rsi      # 0xafc8
movq %rax, %rdi
xorl %edx, %edx
callq 0x23a0
nop
// File: /workspace/github_cpp_makefile_star2_O2/lmclaramunt[P]AES-Crypto/Sequence.cpp
// Function: Sequence::updateSequence(Sequence)
void Sequence::updateSequence(Sequence seq) {
    if(size == (seq).getSize()) {
        for(int i=0; i < (seq).getSize(); i++)
            sq[i] = (seq).getSequence()[i];
    } else
        throw "Sequences of different size";   
}

// Assembly:
pushq %rax
cmpl %edx, 0x8(%rdi)
jne 0x2f5f
xorl %eax, %eax
testl %edx, %edx
cmovlel %eax, %edx
cmpq %rax, %rdx
je 0x2f5d
movb (%rsi,%rax), %cl
movq (%rdi), %r8
movb %cl, (%r8,%rax)
incq %rax
jmp 0x2f49
popq %rax
retq
pushq $0x8
popq %rdi
callq 0x2100
leaq 0x442a(%rip), %rcx      # 0x7398
movq %rcx, (%rax)
movq 0x8050(%rip), %rsi      # 0xafc8
movq %rax, %rdi
xorl %edx, %edx
callq 0x23a0
// File: /workspace/github_cpp_makefile_star2_O2/lmclaramunt[P]AES-Crypto/Sequence.cpp
// Function: operator<<(std::ostream&, Sequence&)
ostream& operator<<(ostream& os, Sequence& seq) {
    for (int i=0; i < seq.getSize(); i++) 
        os << hex <<(int)seq.getSequence()[i]<< ' ';
    os << endl;
    return os;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
xorl %r15d, %r15d
pushq $0x20
popq %rbp
movslq 0x8(%r14), %rax
cmpq %rax, %r15
jge 0x2fd2
movq (%rbx), %rax
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%rbx,%rax)
movq (%r14), %rax
movzbl (%rax,%r15), %esi
movq %rbx, %rdi
callq 0x23b0
movq %rax, %rdi
movl %ebp, %esi
callq 0x2230
incq %r15
jmp 0x2f95
movq %rbx, %rdi
callq 0x20f0
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/lmclaramunt[P]AES-Crypto/Sequence.cpp
// Function: operator^(Sequence&, Sequence&)
Sequence& operator^(Sequence& a, Sequence& b) {
    int m = min(a.getSize(), b.getSize());
    for (int i=0; i < m; i++) {
        a.getSequence()[i] ^= b.getSequence()[i];
    }
    return a;
}

// Assembly:
movq %rdi, %rax
movl 0x8(%rdi), %ecx
movl 0x8(%rsi), %edx
cmpl %ecx, %edx
cmovll %edx, %ecx
xorl %edx, %edx
testl %ecx, %ecx
cmovlel %edx, %ecx
cmpq %rdx, %rcx
je 0x3015
movq (%rsi), %rdi
movb (%rdi,%rdx), %dil
movq (%rax), %r8
xorb %dil, (%r8,%rdx)
incq %rdx
jmp 0x2ffd
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/lmclaramunt[P]AES-Crypto/Block.cpp
// Function: Block::Block(std::vector<unsigned char, std::allocator<unsigned char>>*, bool)
Block::Block(vector<unsigned char>* input, bool pad) {
    if(pad) padding(input);
    Sequence sq = ((*input).size() >= 16) ? Sequence(16) : Sequence((*input).size());
    int j = 0;
    for (int i=0; i < (*input).size(); i++) {
        sq.getSequence()[j] = (unsigned) (*input).at(i);
        if (i%16==15) {
            sequenceVct.push_back(sq);      //Append 128 bits, and restart
            sq = (((*input).size()-(i+1)) >= 16) ? Sequence(16) : Sequence(((*input).size()-(i+1)));
            j = -1;
        }
        j++;
    }
    if (j != 0) sequenceVct.push_back(sq);       //Left over is padding was avoided
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
testl %edx, %edx
je 0x3043
movq %r14, %rsi
callq 0x3128
movq 0x8(%r14), %rsi
subq (%r14), %rsi
cmpq $0x10, %rsi
pushq $0x10
popq %rax
cmovael %eax, %esi
leaq 0x8(%rsp), %rdi
callq 0x2ea0
xorl %r15d, %r15d
leaq 0x8(%rsp), %r12
xorl %ebp, %ebp
movq 0x8(%r14), %rax
subq (%r14), %rax
cmpq %r15, %rax
jbe 0x30ed
movq %r14, %rdi
movq %r15, %rsi
callq 0x3230
movb (%rax), %r13b
movq %r12, %rdi
callq 0x2eb4
movq (%rax), %rax
movslq %ebp, %rcx
movb %r13b, (%rax,%rcx)
movl %r15d, %eax
notl %eax
testb $0xf, %al
je 0x30a4
incq %r15
incl %ebp
jmp 0x3068
movq %rbx, %rdi
movq %r12, %rsi
callq 0x324e
movq 0x8(%r14), %rsi
subq (%r14), %rsi
incq %r15
movq %rsi, %rax
subq %r15, %rax
subl %r15d, %esi
cmpq $0x10, %rax
pushq $0x10
popq %rax
cmovael %eax, %esi
leaq 0x18(%rsp), %rdi
callq 0x2ea0
movl 0x20(%rsp), %eax
movl %eax, 0x10(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
jmp 0x3066
testl %ebp, %ebp
je 0x30fe
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x324e
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3115
jmp 0x3115
jmp 0x3115
jmp 0x3115
movq %rax, %r14
movq %rbx, %rdi
callq 0x3276
movq %r14, %rdi
callq 0x23d0