// File: /workspace/github_cpp_makefile_star2_O2/yuansliu[P]HiRGC/hirgc.cpp
// Function: readTarFile(char*)
void readTarFile(char *tarFile) {// processing target file; recording all auxiliary information  
	
	FILE *fp = fopen(tarFile, "r");
	if (NULL == fp) {
		printf("fail to open file %s\n", tarFile);
		return;
	}
	char ch[1024], chr;
	
	int _tar_seq_len = 0;
	other_char_len = 0, n_vec_len = 0;
	pos_vec_len = line_break_len = 0;

	int letters_len = 0, n_letters_len = 0, index, ch_len;
	bool flag = true, n_flag = false; // first is upper case //first is not N

	// fscanf(fp, "%s", meta_data); //meta_data
	fgets(meta_data, 1024, fp);

	while (fscanf(fp, "%s", ch) != EOF) {
		ch_len = strlen(ch);

		for (int i = 0; i < ch_len; i++) {
			chr = ch[i];
			if (islower(chr)) {
				if (flag) { //previous is upper case
					flag = false; //change status of switch
					pos_vec[pos_vec_len].begin = (letters_len);
					letters_len = 0;
				}
				chr = toupper(chr);
			} else {
				if (isupper(chr)) {
					if (!flag) {
						flag = true;
						pos_vec[pos_vec_len].length = (letters_len);
						pos_vec_len++;
						letters_len = 0;
					}
				}
			}
			letters_len++;

			//ch is an upper letter
			if (chr != 'N') {
				index = agctIndex(chr);
				if (index^4) {
					// tar_seq_code[tar_seq_len++] = code_rule[index];
					tar_seq_code[_tar_seq_len++] = index;
				} else {
					other_char_vec[other_char_len].pos = _tar_seq_len;
					other_char_vec[other_char_len].ch = chr-'A';
					other_char_len++;
				}
			}

			if (!n_flag) {
				if (chr == 'N') {
					n_vec[n_vec_len].begin = n_letters_len;
					n_letters_len = 0;
					n_flag = true;
				}
			} else {//n_flag = true
				if (chr != 'N'){
					n_vec[n_vec_len].length = n_letters_len;
					n_vec_len++;
					n_letters_len = 0;
					n_flag = false;
				}
			}
			n_letters_len++;

		}
		line_break_vec[line_break_len++] = ch_len;
	}

	if (!flag) {
		pos_vec[pos_vec_len].length = (letters_len);
		pos_vec_len++;
	}
	
	if (n_flag) {
		n_vec[n_vec_len].length = (n_letters_len);
		n_vec_len++;
	}

	for (int i = other_char_len-1; i > 0; i--) {
		other_char_vec[i].pos -= other_char_vec[i-1].pos;
	}
	fclose(fp);
	tar_seq_len = _tar_seq_len;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x448, %rsp            # imm = 0x448
movq %rdi, %r14
leaq 0x27ad(%rip), %rsi      # 0x5050
callq 0x2180
testq %rax, %rax
je 0x2b4c
movq %rax, %r13
andl $0x0, 0x58f5(%rip)      # 0x81b0
andl $0x0, 0x5902(%rip)      # 0x81c4
andl $0x0, 0x58ff(%rip)      # 0x81c8
andl $0x0, 0x58f0(%rip)      # 0x81c0
movq 0x58a1(%rip), %rdi      # 0x8178
movl $0x400, %esi            # imm = 0x400
movq %rax, %rdx
callq 0x2220
movb $0x1, %al
movl %eax, (%rsp)
xorl %r15d, %r15d
leaq 0x40(%rsp), %rax
movl $0x0, 0x4(%rsp)
xorl %r12d, %r12d
xorl %ebx, %ebx
movq %r13, %r14
movq %r13, 0x18(%rsp)
movq %r14, %rdi
leaq 0x279e(%rip), %rsi      # 0x50ae
movq %rax, %r13
movq %rax, %rdx
xorl %eax, %eax
callq 0x2280
cmpl $-0x1, %eax
je 0x2acc
movq %r13, %rdi
callq 0x20c0
movq 0x584b(%rip), %rcx      # 0x8180
movq %rcx, 0x8(%rsp)
movq 0x585f(%rip), %rcx      # 0x81a0
movq %rcx, 0x30(%rsp)
movq 0x5843(%rip), %rcx      # 0x8190
movq %rcx, 0x28(%rsp)
movq 0x582f(%rip), %rcx      # 0x8188
movq %rcx, 0x10(%rsp)
testl %eax, %eax
movl $0x0, %ecx
movq %rax, 0x20(%rsp)
cmovgl %eax, %ecx
movq %rcx, 0x38(%rsp)
xorl %r14d, %r14d
cmpq %r14, 0x38(%rsp)
je 0x2a9e
movb 0x40(%rsp,%r14), %r13b
movsbl %r13b, %ebp
movl %ebp, %edi
callq 0x21c0
testl %eax, %eax
je 0x2a26
testb $0x1, (%rsp)
je 0x29b8
movslq 0x581b(%rip), %rax      # 0x81c0
movq 0x8(%rsp), %rcx
movl %r12d, (%rcx,%rax,8)
xorl %r12d, %r12d
movl $0x0, (%rsp)
movl %ebp, %edi
callq 0x2290
movl %eax, %r13d
movsbl %r13b, %ebp
cmpb $0x4e, %r13b
jne 0x29ef
testb $0x1, %r15b
jne 0x2a91
movslq 0x57e7(%rip), %rax      # 0x81c4
movq 0x10(%rsp), %rcx
movl %ebx, (%rcx,%rax,8)
movb $0x1, %r15b
xorl %ebx, %ebx
jmp 0x2a91
movsbl %r13b, %edi
callq 0x274c
cmpl $0x4, %eax
jne 0x2a5b
movslq 0x57ac(%rip), %rax      # 0x81b0
movl 0x4(%rsp), %ecx
movq 0x28(%rsp), %rdx
movl %ecx, (%rdx,%rax,8)
addl $-0x41, %ebp
movslq 0x5796(%rip), %rax      # 0x81b0
movl %ebp, 0x4(%rdx,%rax,8)
incl 0x578c(%rip)            # 0x81b0
jmp 0x2a70
movl %ebp, %edi
callq 0x20f0
testl %eax, %eax
je 0x29c6
testb $0x1, (%rsp)
jne 0x29c6
movslq 0x5782(%rip), %rax      # 0x81c0
movq 0x8(%rsp), %rcx
movl %r12d, 0x4(%rcx,%rax,8)
incl 0x5772(%rip)            # 0x81c0
movb $0x1, %al
movl %eax, (%rsp)
xorl %r12d, %r12d
jmp 0x29c6
movl 0x4(%rsp), %edx
movslq %edx, %rcx
incl %edx
movl %edx, 0x4(%rsp)
movq 0x30(%rsp), %rdx
movl %eax, (%rdx,%rcx,4)
testb $0x1, %r15b
je 0x2a91
movslq 0x5747(%rip), %rax      # 0x81c4
movq 0x10(%rsp), %rcx
movl %ebx, 0x4(%rcx,%rax,8)
incl 0x5738(%rip)            # 0x81c4
xorl %ebx, %ebx
xorl %r15d, %r15d
incl %r12d
incl %ebx
incq %r14
jmp 0x2975
movq 0x56f3(%rip), %rax      # 0x8198
movslq 0x571c(%rip), %rcx      # 0x81c8
leal 0x1(%rcx), %edx
movl %edx, 0x5713(%rip)      # 0x81c8
movq 0x20(%rsp), %rdx
movl %edx, (%rax,%rcx,4)
movq 0x18(%rsp), %r14
leaq 0x40(%rsp), %rax
jmp 0x2906
testb $0x1, (%rsp)
jne 0x2aeb
movq 0x56a7(%rip), %rax      # 0x8180
movslq 0x56e0(%rip), %rcx      # 0x81c0
movl %r12d, 0x4(%rax,%rcx,8)
incl 0x56d5(%rip)            # 0x81c0
testb $0x1, %r15b
je 0x2b09
movq 0x5690(%rip), %rax      # 0x8188
movslq 0x56c5(%rip), %rcx      # 0x81c4
movl %ebx, 0x4(%rax,%rcx,8)
incl 0x56bb(%rip)            # 0x81c4
movl 0x56a1(%rip), %eax      # 0x81b0
movq 0x567a(%rip), %rcx      # 0x8190
cmpl $0x1, %eax
jle 0x2b28
movl -0x10(%rcx,%rax,8), %edx
subl %edx, -0x8(%rcx,%rax,8)
decq %rax
jmp 0x2b16
movq %r14, %rdi
callq 0x2160
movl 0x4(%rsp), %eax
movl %eax, 0x567e(%rip)      # 0x81b8
addq $0x448, %rsp            # imm = 0x448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2517(%rip), %rdi      # 0x506a
movq %r14, %rsi
xorl %eax, %eax
addq $0x448, %rsp            # imm = 0x448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2040