// File: /workspace/github_cpp_makefile_star2_O1/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 0x286799(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
leaq 0x220f0e(%rip), %rsi    # 0x22475f
movq %r15, %rdx
xorl %eax, %eax
callq 0x22b0
leaq 0x22fd45(%rip), %rsi    # 0x2335a7
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 0x3896
incq 0x10(%rbx)
movq 0x20(%rbx), %rdx
movq %r14, %rdi
movl %r12d, %esi
jmp 0x387c
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)
andq $0x0, 0x8(%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 0x3968
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 0x3901
movq 0x20(%rbx), %rdi
callq 0x2190
leaq 0x220e07(%rip), %rsi    # 0x22477f
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x238a72(%rip), %r12    # 0x23c3fe
movq %r14, %rdi
movq %r12, %rsi
callq 0x2210
movq %rax, 0x20(%rbx)
movq 0x28663e(%rip), %r13    # 0x289fe0
movq (%r13), %rdi
leaq 0x220de2(%rip), %rsi    # 0x22478f
movq %r14, %rdx
xorl %eax, %eax
callq 0x22b0
leaq 0x220df5(%rip), %rsi    # 0x2247b3
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 0x220ddd(%rip), %rsi    # 0x2247c2
movq %r14, %rdx
xorl %eax, %eax
callq 0x22b0
leaq 0x220de4(%rip), %rsi    # 0x2247da
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 0x220dcc(%rip), %rsi    # 0x2247e9
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