// File: /workspace/github_cpp_makefile_star2_O3/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, %r13
movq %r13, %rdi
callq 0x2280
movq %rax, %r14
movq 0x29178e(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
leaq 0x22cf13(%rip), %rsi    # 0x23076f
movq %r15, %rdx
xorl %eax, %eax
callq 0x22b0
leaq 0x23bf8a(%rip), %rsi    # 0x23f7f7
movq %r15, %rdi
callq 0x2210
movq %rax, 0x20(%rbx)
andq $0x0, 0x10(%rbx)
movq %r14, %rdi
movl %r13d, %esi
movq %rax, %rdx
callq 0x2340
testq %rax, %rax
je 0x38a1
incq 0x10(%rbx)
movq 0x20(%rbx), %rdx
movq %r14, %rdi
movl %r12d, %esi
jmp 0x3887
movq 0x10(%rbx), %r13
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 %esi, %esi
xorl %edx, %edx
callq 0x21b0
movq 0x20(%rbx), %rdx
movq %r14, %rdi
movl %r12d, %esi
callq 0x2340
testq %rax, %rax
je 0x396e
xorl %ebp, %ebp
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)
movq 0x20(%rbx), %rdx
movq %r14, %rdi
movl %r12d, %esi
callq 0x2340
addq $0x8, %rbp
testq %rax, %rax
jne 0x3907
movq 0x20(%rbx), %rdi
callq 0x2190
leaq 0x22ce11(%rip), %rsi    # 0x23078f
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x244d50(%rip), %r12    # 0x2486e2
movq %r14, %rdi
movq %r12, %rsi
callq 0x2210
movq %rax, 0x20(%rbx)
movq 0x291638(%rip), %r13    # 0x294fe0
movq (%r13), %rdi
leaq 0x22cdec(%rip), %rsi    # 0x23079f
movq %r14, %rdx
xorl %eax, %eax
callq 0x22b0
leaq 0x22cdff(%rip), %rsi    # 0x2307c3
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 0x22cde7(%rip), %rsi    # 0x2307d2
movq %r14, %rdx
xorl %eax, %eax
callq 0x22b0
leaq 0x22cdee(%rip), %rsi    # 0x2307ea
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 0x22cdd6(%rip), %rsi    # 0x2307f9
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