// File: 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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x3e8, -0x1c(%rbp)     # imm = 0x3E8
movslq -0x1c(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x20a0
movq %rax, %rcx
movq -0x30(%rbp), %rax
addq $0x32, %rcx
cmpq %rcx, %rax
jae 0xb798
movq -0x10(%rbp), %rdi
callq 0x20a0
addq $0x32, %rax
movl %eax, -0x1c(%rbp)
movslq -0x1c(%rbp), %rdi
shlq $0x0, %rdi
callq 0x2270
movq %rax, -0x28(%rbp)
movq 0x3b8830(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x375d80(%rip), %rsi    # 0x38153e
movb $0x0, %al
callq 0x22a0
movq -0x10(%rbp), %rdi
leaq 0x384c06(%rip), %rsi    # 0x3903d6
callq 0x2200
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x28(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdx
callq 0x2330
cmpq $0x0, %rax
je 0xb818
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
jmp 0xb7ec
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
shlq $0x3, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
shlq $0x5, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
shlq $0x3, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdx
shlq $0x3, %rdx
movl $0xff, %esi
callq 0x2100
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x21b0
movl $0x0, -0x18(%rbp)
movq -0x28(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdx
callq 0x2330
cmpq $0x0, %rax
je 0xb996
movq -0x28(%rbp), %rdi
callq 0x20a0
subq $0x1, %rax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x0, %rdi
callq 0x2270
movq %rax, %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x28(%rbp), %rsi
movslq -0x14(%rbp), %rdx
shlq $0x0, %rdx
callq 0x2180
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq $0x0, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq $0x0, (%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq $0x0, 0x10(%rax)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xb8af
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x21a0
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x375bac(%rip), %rsi    # 0x38155e
movb $0x0, %al
callq 0x2050
movq -0x28(%rbp), %rdi
leaq 0x38da0e(%rip), %rsi    # 0x3993d2
callq 0x2200
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x20(%rax)
movq 0x3b8605(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x28(%rbp), %rdx
leaq 0x375b85(%rip), %rsi    # 0x38156e
movb $0x0, %al
callq 0x22a0
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x375b93(%rip), %rsi    # 0x381592
movb $0x0, %al
callq 0x2050
movq -0x28(%rbp), %rdi
leaq 0x38d9c1(%rip), %rsi    # 0x3993d2
callq 0x2200
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x28(%rax)
movq 0x3b85b8(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x28(%rbp), %rdx
leaq 0x375b6b(%rip), %rsi    # 0x3815a1
movb $0x0, %al
callq 0x22a0
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x375b6d(%rip), %rsi    # 0x3815b9
movb $0x0, %al
callq 0x2050
movq -0x28(%rbp), %rdi
leaq 0x38d974(%rip), %rsi    # 0x3993d2
callq 0x2200
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x30(%rax)
movq 0x3b856b(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x28(%rbp), %rdx
leaq 0x375b45(%rip), %rsi    # 0x3815c8
movb $0x0, %al
callq 0x22a0
movq -0x28(%rbp), %rdi
callq 0x2210
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)