// File: /workspace/github_cpp_makefile_star2_O3/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 0x2718(%rip), %rsi      # 0x5050
callq 0x2190
testq %rax, %rax
je 0x2c20
movq %rax, %r12
xorl %r15d, %r15d
movl %r15d, 0x585d(%rip)     # 0x81b0
movl %r15d, 0x586a(%rip)     # 0x81c4
movl %r15d, 0x5867(%rip)     # 0x81c8
movl %r15d, 0x5858(%rip)     # 0x81c0
movq 0x5809(%rip), %rdi      # 0x8178
movl $0x400, %esi            # imm = 0x400
movq %rax, %rdx
callq 0x2210
leaq 0x272b(%rip), %rsi      # 0x50ae
leaq 0x40(%rsp), %rdx
movq %r12, %rdi
xorl %eax, %eax
callq 0x2280
cmpl $-0x1, %eax
je 0x2bd7
movb $0x1, %al
movl %eax, 0x4(%rsp)
leaq 0x40(%rsp), %r13
movl $0x0, (%rsp)
xorl %ebx, %ebx
xorl %r14d, %r14d
xorl %r15d, %r15d
movq %r12, 0x18(%rsp)
movq %r13, %rdi
callq 0x20b0
testl %eax, %eax
movq %rax, 0x20(%rsp)
jle 0x2b53
movq 0x57aa(%rip), %rcx      # 0x8180
movq %rcx, 0x8(%rsp)
movq 0x57be(%rip), %rcx      # 0x81a0
movq %rcx, 0x30(%rsp)
movq 0x57a2(%rip), %rcx      # 0x8190
movq %rcx, 0x28(%rsp)
movq 0x578e(%rip), %rcx      # 0x8188
movq %rcx, 0x10(%rsp)
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x38(%rsp)
xorl %r12d, %r12d
movb 0x40(%rsp,%r12), %r13b
movsbl %r13b, %ebp
movl %ebp, %edi
callq 0x21c0
testl %eax, %eax
je 0x2a8e
testb $0x1, 0x4(%rsp)
je 0x2a42
movslq 0x5792(%rip), %rax      # 0x81c0
movq 0x8(%rsp), %rcx
movl %r14d, (%rcx,%rax,8)
xorl %r14d, %r14d
movl $0x0, 0x4(%rsp)
movl %ebp, %edi
callq 0x2290
movl %eax, %r13d
movsbl %r13b, %ebp
movzbl %r13b, %eax
cmpl $0x46, %eax
jle 0x2a77
cmpl $0x47, %eax
je 0x2ac2
cmpl $0x4e, %eax
je 0x2b0f
cmpl $0x54, %eax
jne 0x2b2d
movl $0x3, %ecx
jmp 0x2ac7
xorl %ecx, %ecx
cmpl $0x41, %eax
je 0x2ac7
cmpl $0x43, %eax
jne 0x2b2d
movl $0x1, %ecx
jmp 0x2ac7
movl %ebp, %edi
callq 0x20f0
testl %eax, %eax
je 0x2a50
testb $0x1, 0x4(%rsp)
jne 0x2a50
movslq 0x5719(%rip), %rax      # 0x81c0
movq 0x8(%rsp), %rcx
movl %r14d, 0x4(%rcx,%rax,8)
incl 0x5709(%rip)            # 0x81c0
movb $0x1, %al
movl %eax, 0x4(%rsp)
xorl %r14d, %r14d
jmp 0x2a50
movl $0x2, %ecx
movslq %r15d, %rax
incl %r15d
movq 0x30(%rsp), %rdx
movl %ecx, (%rdx,%rax,4)
testb $0x1, (%rsp)
je 0x2afa
movslq 0x56e2(%rip), %rax      # 0x81c4
movq 0x10(%rsp), %rcx
movl %ebx, 0x4(%rcx,%rax,8)
incl 0x56d3(%rip)            # 0x81c4
xorl %ebx, %ebx
movl $0x0, (%rsp)
incl %r14d
incl %ebx
incq %r12
cmpq %r12, 0x38(%rsp)
jne 0x2a0c
jmp 0x2b53
testb $0x1, (%rsp)
jne 0x2afa
movslq 0x56a8(%rip), %rax      # 0x81c4
movq 0x10(%rsp), %rcx
movl %ebx, (%rcx,%rax,8)
movb $0x1, %al
movl %eax, (%rsp)
xorl %ebx, %ebx
jmp 0x2afa
movslq 0x567c(%rip), %rax      # 0x81b0
movq 0x28(%rsp), %rcx
movl %r15d, (%rcx,%rax,8)
addl $-0x41, %ebp
movslq 0x5669(%rip), %rax      # 0x81b0
movl %ebp, 0x4(%rcx,%rax,8)
incl 0x565f(%rip)            # 0x81b0
jmp 0x2ad5
movq 0x563e(%rip), %rax      # 0x8198
movslq 0x5667(%rip), %rcx      # 0x81c8
leal 0x1(%rcx), %edx
movl %edx, 0x565e(%rip)      # 0x81c8
movq 0x20(%rsp), %rdx
movl %edx, (%rax,%rcx,4)
movq 0x18(%rsp), %r12
movq %r12, %rdi
leaq 0x252d(%rip), %rsi      # 0x50ae
leaq 0x40(%rsp), %r13
movq %r13, %rdx
xorl %eax, %eax
callq 0x2280
cmpl $-0x1, %eax
jne 0x29ba
testb $0x1, 0x4(%rsp)
jne 0x2bb9
movq 0x55d9(%rip), %rax      # 0x8180
movslq 0x5612(%rip), %rcx      # 0x81c0
movl %r14d, 0x4(%rax,%rcx,8)
incl 0x5607(%rip)            # 0x81c0
testb $0x1, (%rsp)
je 0x2bd7
movq 0x55c2(%rip), %rax      # 0x8188
movslq 0x55f7(%rip), %rcx      # 0x81c4
movl %ebx, 0x4(%rax,%rcx,8)
incl 0x55ed(%rip)            # 0x81c4
movslq 0x55d2(%rip), %rax      # 0x81b0
cmpq $0x2, %rax
jl 0x2bff
movq 0x55a5(%rip), %rcx      # 0x8190
incq %rax
movl -0x18(%rcx,%rax,8), %edx
subl %edx, -0x10(%rcx,%rax,8)
decq %rax
cmpq $0x2, %rax
ja 0x2bee
movq %r12, %rdi
callq 0x2160
movl %r15d, 0x55aa(%rip)     # 0x81b8
addq $0x448, %rsp            # imm = 0x448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2443(%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