// File: gersteinlab[P]MUSIC/src/ms_genome_sequence_tools.cpp
// Function: get_reverse_strand_RNA(char*, int, int)
char* get_reverse_strand_RNA(char* cur_aln_line, int i_nuc_min, int i_nuc_max)
{
	char* reverse_RNA = new char[i_nuc_max - i_nuc_min + 2];
	memset(reverse_RNA, 0, sizeof(char) * (i_nuc_max - i_nuc_min + 2));

	int i_rna_nuc = 0;
	for(int i_nuc = i_nuc_min; i_nuc <= i_nuc_max; i_nuc++)
	{
		if(cur_aln_line[i_nuc] == 'T')
		{
			reverse_RNA[i_rna_nuc] = 'U';
			i_rna_nuc++;
		}
		else if(cur_aln_line[i_nuc] == 't')
		{
			reverse_RNA[i_rna_nuc] = 'u';
			i_rna_nuc++;
		}
		else if(cur_aln_line[i_nuc] == 'A' || cur_aln_line[i_nuc] == 'a' ||
			cur_aln_line[i_nuc] == 'C' || cur_aln_line[i_nuc] == 'c' ||
			cur_aln_line[i_nuc] == 'G' || cur_aln_line[i_nuc] == 'g' ||
			cur_aln_line[i_nuc] == '-')
		{
			reverse_RNA[i_rna_nuc] = cur_aln_line[i_nuc];
			i_rna_nuc++;
		}
		else
		{
			printf("Found %c in the alignment line @ %s(%d):\n%s\n",  cur_aln_line[i_nuc], __FILE__, __LINE__, cur_aln_line);
			//exit(0);
			reverse_RNA[i_rna_nuc] = cur_aln_line[i_nuc];
			i_rna_nuc++;
		}
	} // i_nuc loop.

	return(reverse_RNA);
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movl %esi, 0x1c(%rsp)
movl %edx, 0x18(%rsp)
movl 0x18(%rsp), %eax
subl 0x1c(%rsp), %eax
addl $0x2, %eax
movslq %eax, %rdi
callq 0x2040
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rdi
movl 0x18(%rsp), %eax
subl 0x1c(%rsp), %eax
addl $0x2, %eax
movslq %eax, %rdx
shlq $0x0, %rdx
xorl %esi, %esi
callq 0x2110
movl $0x0, 0xc(%rsp)
movl 0x1c(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x8(%rsp), %eax
cmpl 0x18(%rsp), %eax
jg 0x3e04b
movq 0x20(%rsp), %rax
movslq 0x8(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x54, %eax
jne 0x3df06
movq 0x10(%rsp), %rax
movslq 0xc(%rsp), %rcx
movb $0x55, (%rax,%rcx)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x3e039
movq 0x20(%rsp), %rax
movslq 0x8(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x74, %eax
jne 0x3df37
movq 0x10(%rsp), %rax
movslq 0xc(%rsp), %rcx
movb $0x75, (%rax,%rcx)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x3e037
movq 0x20(%rsp), %rax
movslq 0x8(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x41, %eax
je 0x3dfbc
movq 0x20(%rsp), %rax
movslq 0x8(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x61, %eax
je 0x3dfbc
movq 0x20(%rsp), %rax
movslq 0x8(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x43, %eax
je 0x3dfbc
movq 0x20(%rsp), %rax
movslq 0x8(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x63, %eax
je 0x3dfbc
movq 0x20(%rsp), %rax
movslq 0x8(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x47, %eax
je 0x3dfbc
movq 0x20(%rsp), %rax
movslq 0x8(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x67, %eax
je 0x3dfbc
movq 0x20(%rsp), %rax
movslq 0x8(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2d, %eax
jne 0x3dfe3
movq 0x20(%rsp), %rax
movslq 0x8(%rsp), %rcx
movb (%rax,%rcx), %dl
movq 0x10(%rsp), %rax
movslq 0xc(%rsp), %rcx
movb %dl, (%rax,%rcx)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x3e035
movq 0x20(%rsp), %rax
movslq 0x8(%rsp), %rcx
movsbl (%rax,%rcx), %esi
movq 0x20(%rsp), %r8
leaq 0x18788(%rip), %rdi     # 0x56785
leaq 0x187ae(%rip), %rdx     # 0x567b2
movl $0x239, %ecx            # imm = 0x239
movb $0x0, %al
callq 0x2050
movq 0x20(%rsp), %rax
movslq 0x8(%rsp), %rcx
movb (%rax,%rcx), %dl
movq 0x10(%rsp), %rax
movslq 0xc(%rsp), %rcx
movb %dl, (%rax,%rcx)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x3e037
jmp 0x3e039
jmp 0x3e03b
movl 0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8(%rsp)
jmp 0x3dec7
movq 0x10(%rsp), %rax
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)