// File: /workspace/github_cpp_makefile_star2_O1/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 0x13b5(%rip), %rsi      # 0x40c0
leaq 0x13b3(%rip), %rdx      # 0x40c5
leaq -0x88(%rbp), %rbx
movq %rbx, %rdi
callq 0x3610
movq (%rbx), %rdi
callq 0x22b0
movq %rax, %rbx
testq %rax, %rax
je 0x2eb7
leaq -0x48(%rbp), %r14
leaq -0x290(%rbp), %r15
movq %rbx, %rdi
callq 0x22c0
movq %rax, %r12
testq %rax, %rax
je 0x2e89
addq $0x13, %r12
movq %r12, %rdi
leaq 0x1376(%rip), %rsi      # 0x40d8
callq 0x2270
testl %eax, %eax
je 0x2d40
movq %r12, %rdi
leaq 0x1362(%rip), %rsi      # 0x40d7
callq 0x2270
testl %eax, %eax
je 0x2d40
leaq -0x58(%rbp), %rax
movq %rax, -0x68(%rbp)
movq %r12, %rdi
callq 0x20d0
leaq (%rax,%r12), %rdx
leaq -0x68(%rbp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x3610
movq %r14, %rdi
leaq -0x88(%rbp), %rsi
movq %r13, %rdx
callq 0x320a
movq %r15, %rdi
movq %r14, %rsi
movl $0x2, %edx
callq 0x22e0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x2ddc
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x290(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x270(%rbp,%rax)
jne 0x2ec8
movq %r15, %rdi
callq 0x2320
movq %rax, %r12
movq %r15, %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 %r15, %rdi
movq %rax, %rsi
callq 0x2230
movq 0x442a(%rip), %rsi      # 0x7260
cmpq 0x442b(%rip), %rsi      # 0x7268
je 0x2e50
movq -0x48(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0x4412(%rip)      # 0x7260
jmp 0x2e5f
leaq 0x4401(%rip), %rdi      # 0x7258
movq %r14, %rdx
callq 0x34ee
movq %r15, %rdi
callq 0x2060
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x2d40
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x2d40
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x2ea5
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 0x1208(%rip), %rdi      # 0x40c6
callq 0x2150
jmp 0x2d35
callq 0x23f8
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x2f05
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x2f05
jmp 0x2ef6
movq %rax, %rbx
jmp 0x2f05
jmp 0x2ef6
jmp 0x2f20
movq %rax, %rbx
leaq -0x290(%rbp), %rdi
callq 0x2060
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x2f23
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x2f23
movq %rax, %rbx
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x2f3f
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x21c0
movq %rbx, %rdi
callq 0x2330