// File: /workspace/github_cpp_makefile_star2_O3/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 -0x78(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x13c0(%rip), %rsi      # 0x40c0
leaq 0x13be(%rip), %rdx      # 0x40c5
leaq -0x88(%rbp), %rbx
movq %rbx, %rdi
callq 0x3614
movq (%rbx), %rdi
callq 0x22a0
movq %rax, %rbx
testq %rax, %rax
je 0x2ea6
leaq -0x68(%rbp), %r14
leaq -0x48(%rbp), %r15
leaq -0x290(%rbp), %r13
movq %rbx, %rdi
callq 0x22b0
movq %rax, %r12
testq %rax, %rax
je 0x2e78
cmpb $0x2e, 0x13(%r12)
jne 0x2d6d
cmpb $0x0, 0x14(%r12)
je 0x2d39
cmpb $0x2e, 0x14(%r12)
jne 0x2d6d
cmpb $0x0, 0x15(%r12)
je 0x2d39
addq $0x13, %r12
leaq -0x58(%rbp), %rax
movq %rax, -0x68(%rbp)
movq %r12, %rdi
callq 0x20d0
leaq (%rax,%r12), %rdx
movq %r14, %rdi
movq %r12, %rsi
callq 0x3614
movq %r15, %rdi
leaq -0x88(%rbp), %rsi
movq %r14, %rdx
callq 0x3202
movq %r13, %rdi
movq %r15, %rsi
movl $0x2, %edx
callq 0x22d0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x2dcb
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x290(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x270(%rbp,%rax)
jne 0x2eb7
movq %r13, %rdi
callq 0x2310
movq %rax, %r12
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2250
leal 0x5(%r12), %edi
callq 0x2030
movq %rax, -0x48(%rbp)
movl %r12d, (%rax)
addq $0x4, %rax
movl %r12d, %edx
movq %r13, %rdi
movq %rax, %rsi
callq 0x2230
movq 0x4433(%rip), %rsi      # 0x7258
cmpq 0x4434(%rip), %rsi      # 0x7260
je 0x2e3f
movq -0x48(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0x441b(%rip)      # 0x7258
jmp 0x2e4e
leaq 0x440a(%rip), %rdi      # 0x7250
movq %r15, %rdx
callq 0x34f2
movq %r13, %rdi
callq 0x2060
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x2d39
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x2d39
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x2e94
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x21c0
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1219(%rip), %rdi      # 0x40c6
callq 0x2150
jmp 0x2d2a
callq 0x23e8
jmp 0x2eea
jmp 0x2eea
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x2ef9
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x2ef9
movq %rax, %rbx
jmp 0x2ef9
jmp 0x2ee5
movq %rax, %rbx
jmp 0x2f12
movq %rax, %rbx
leaq -0x290(%rbp), %rdi
callq 0x2060
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x2f12
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x2f2e
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x21c0
movq %rbx, %rdi
callq 0x2320