// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Process_Read.cpp
// Function: init_Debug_reads(Debug_reads*, char const*)
void init_Debug_reads(Debug_reads* x, const char* file)
{
	int nameLen, i, bufLen = 1000;
	if((uint64_t)(bufLen) < strlen(file) + 50) bufLen = strlen(file) + 50;
	char* Name_Buffer = (char*)malloc(sizeof(char)*bufLen);
	fprintf(stderr, "Queried debugging reads at: %s\n", file);

	x->fp = fopen(file,"r");
	x->query_num = 0;
	
	while(fgets(Name_Buffer, bufLen, x->fp))
	{
		x->query_num++;
	}
	x->read_name = (char**)malloc(sizeof(char*)*x->query_num);
	x->candidate_count = (kvec_t_u64_warp*)malloc(sizeof(kvec_t_u64_warp)*x->query_num);
	x->read_id = NULL; MALLOC(x->read_id, x->query_num); 
	memset(x->read_id, -1, sizeof((*(x->read_id)))*x->query_num);
	fseek(x->fp, 0, SEEK_SET);

	i = 0;
	while(fgets(Name_Buffer, bufLen, x->fp))
	{
		nameLen = strlen(Name_Buffer) - 1;
		x->read_name[i] = (char*)malloc(sizeof(char)*(nameLen+1));
		memcpy(x->read_name[i], Name_Buffer, sizeof(char)*nameLen);
		x->read_name[i][nameLen] = '\0';
		kv_init(x->candidate_count[i].a);
		i++;
	}
	
    fclose(x->fp);

	sprintf(Name_Buffer, "%s.debug.stdout", file);
	x->fp = fopen(Name_Buffer,"w");
	fprintf(stderr, "Print debugging information to: %s\n", Name_Buffer);

	sprintf(Name_Buffer, "%s.debug.r0.fa", file);
	x->fp_r0 = fopen(Name_Buffer,"w");
	fprintf(stderr, "Print raw reads to: %s\n", Name_Buffer);

	sprintf(Name_Buffer, "%s.debug.r1.fa", file);
	x->fp_r1 = fopen(Name_Buffer,"w");
	fprintf(stderr, "Print corrected reads to: %s\n", Name_Buffer);

	free(Name_Buffer);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x2090
addq $0x32, %rax
cmpq $0x3e9, %rax            # imm = 0x3E9
movl $0x3e8, %r12d           # imm = 0x3E8
cmovaeq %rax, %r12
movslq %r12d, %rdi
callq 0x2280
movq %rax, %r14
movq 0x24b4ed(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
leaq 0x1dac72(%rip), %rsi    # 0x1e276f
xorl %r13d, %r13d
movq %r15, %rdx
xorl %eax, %eax
callq 0x22b0
leaq 0x1e9ba6(%rip), %rsi    # 0x1f16b7
movq %r15, %rdi
callq 0x2210
movq %rax, %rdx
movq %rax, 0x20(%rbx)
movq %r13, 0x10(%rbx)
movq %r14, %rdi
movl %r12d, %esi
callq 0x2340
movq 0x10(%rbx), %r13
testq %rax, %rax
je 0x7b41
incq %r13
movq 0x20(%rbx), %rdx
jmp 0x7b20
leaq (,%r13,8), %rbp
movq %rbp, %rdi
callq 0x2280
movq %rax, (%rbx)
shlq $0x5, %r13
movq %r13, %rdi
callq 0x2280
movq %rax, 0x18(%rbx)
movq %rbp, %rdi
callq 0x2280
movq %rax, 0x8(%rbx)
movq %rax, %rdi
movl $0xff, %esi
movq %rbp, %rdx
callq 0x20e0
movq 0x20(%rbx), %rdi
xorl %ebp, %ebp
xorl %esi, %esi
xorl %edx, %edx
callq 0x21b0
movq 0x20(%rbx), %rdx
movq %r14, %rdi
movl %r12d, %esi
callq 0x2340
testq %rax, %rax
je 0x7bf8
movq %r14, %rdi
callq 0x2090
movslq %eax, %r13
movq %r13, %rdi
callq 0x2280
movq (%rbx), %rcx
movq %rax, (%rcx,%rbp)
movq (%rbx), %rax
movq (%rax,%rbp), %rdi
decl %r13d
movslq %r13d, %r13
movq %r14, %rsi
movq %r13, %rdx
callq 0x2160
movq (%rbx), %rax
movq (%rax,%rbp), %rax
movb $0x0, (%rax,%r13)
movq 0x18(%rbx), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax,%rbp,4)
andq $0x0, 0x10(%rax,%rbp,4)
addq $0x8, %rbp
jmp 0x7b8f
movq 0x20(%rbx), %rdi
callq 0x2190
leaq 0x1dab87(%rip), %rsi    # 0x1e278f
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x1f2a85(%rip), %r12    # 0x1fa6a1
movq %r14, %rdi
movq %r12, %rsi
callq 0x2210
movq %rax, 0x20(%rbx)
movq 0x24b3ae(%rip), %r13    # 0x252fe0
movq (%r13), %rdi
leaq 0x1dab62(%rip), %rsi    # 0x1e279f
movq %r14, %rdx
xorl %eax, %eax
callq 0x22b0
leaq 0x1dab75(%rip), %rsi    # 0x1e27c3
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
movq %r14, %rdi
movq %r12, %rsi
callq 0x2210
movq %rax, 0x28(%rbx)
movq (%r13), %rdi
leaq 0x1dab5d(%rip), %rsi    # 0x1e27d2
movq %r14, %rdx
xorl %eax, %eax
callq 0x22b0
leaq 0x1dab64(%rip), %rsi    # 0x1e27ea
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
movq %r14, %rdi
movq %r12, %rsi
callq 0x2210
movq %rax, 0x30(%rbx)
movq (%r13), %rdi
leaq 0x1dab4c(%rip), %rsi    # 0x1e27f9
movq %r14, %rdx
xorl %eax, %eax
callq 0x22b0
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2220