// File: /workspace/github_cpp_makefile_star2_O1/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: dump_GFF_per_region_intervals(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, char*, char*, char*, char*)
void dump_GFF_per_region_intervals(vector<t_annot_region*>* regions, char* gff_fp, char* source_name, char* interval_parent_feature_str, char* interval_child_feature_str)
{
	FILE* f_gff = open_f(gff_fp, "w");
	for(int i_reg = 0; i_reg < (int)regions->size(); i_reg++)
	{
		char cur_transcript_name[1000];
		if(regions->at(i_reg)->name == NULL ||
			strcmp(regions->at(i_reg)->name, ".") == 0)
		{
			sprintf(cur_transcript_name, "transcript_%d", i_reg);
		}
		else
		{
			sprintf(cur_transcript_name, "%s", regions->at(i_reg)->name);
		}

		if(interval_parent_feature_str != NULL)
		{
			fprintf(f_gff, "%s\t%s\t%s\t%d\t%d\t.\t%c\t.\t%s\n", regions->at(i_reg)->chrom, source_name, interval_parent_feature_str, 
				regions->at(i_reg)->start, regions->at(i_reg)->end, regions->at(i_reg)->strand, cur_transcript_name);
		}

		vector<t_annot_region*>* exons = regions->at(i_reg)->intervals;

		for(int i_int = 0; i_int < (int)exons->size(); i_int++)
		{
			fprintf(f_gff, "%s\t%s\t%s\t%d\t%d\t.\t%c\t.\t%s\n", exons->at(i_int)->chrom, source_name, interval_child_feature_str,
				exons->at(i_int)->start, exons->at(i_int)->end, exons->at(i_int)->strand, cur_transcript_name);
		} // i_int loop.
	} // i_reg loop.
	fclose(f_gff);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movq %r8, %rbx
movq %rcx, 0x10(%rsp)
movq %rdx, %r15
movq %rsi, %rax
movq %rdi, %r14
leaq 0x14725(%rip), %rsi     # 0x2baae
movq %rax, %rdi
callq 0x26387
movq %rax, %r13
movq (%r14), %rax
movq 0x8(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x1753a
xorl %esi, %esi
movq %r14, 0x18(%rsp)
cmpq %rsi, %rdx
jbe 0x17565
movq %rsi, 0x8(%rsp)
movq (%rax,%rsi,8), %rax
movq 0x18(%rax), %r12
testq %r12, %r12
je 0x173f3
movq %r12, %rdi
leaq 0x167c8(%rip), %rsi     # 0x2db9e
callq 0x2240
testl %eax, %eax
je 0x173f3
leaq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x2150
movq 0x8(%rsp), %r12
jmp 0x1740e
leaq 0x20(%rsp), %rdi
leaq 0x1759a(%rip), %rsi     # 0x2e999
movq 0x8(%rsp), %r12
movl %r12d, %edx
xorl %eax, %eax
callq 0x2080
cmpq $0x0, 0x10(%rsp)
je 0x17472
movq (%r14), %rax
movq 0x8(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r12, %rdx
jbe 0x17554
movq (%rax,%r12,8), %rax
movq (%rax), %rdx
movl 0xc(%rax), %r9d
movl 0x20(%rax), %r10d
movsbl 0x8(%rax), %r11d
subq $0x8, %rsp
movq %r13, %rdi
leaq 0x17558(%rip), %rsi     # 0x2e9a7
movq %r15, %rcx
movq 0x18(%rsp), %r8
xorl %eax, %eax
leaq 0x28(%rsp), %r12
pushq %r12
movq 0x18(%rsp), %r12
pushq %r11
pushq %r10
callq 0x2250
addq $0x20, %rsp
movq (%r14), %rax
movq 0x8(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r12, %rdx
jbe 0x17554
movq (%rax,%r12,8), %rax
movq 0x30(%rax), %r14
movq (%r14), %rax
movq 0x8(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x1750c
xorl %r12d, %r12d
cmpq %r12, %rdx
jbe 0x17554
movq (%rax,%r12,8), %rax
movq (%rax), %rdx
movl 0xc(%rax), %r9d
movl 0x20(%rax), %r10d
movsbl 0x8(%rax), %r11d
subq $0x8, %rsp
movq %r13, %rdi
leaq 0x174d6(%rip), %rsi     # 0x2e9a7
movq %r15, %rcx
movq %rbx, %r8
xorl %eax, %eax
leaq 0x28(%rsp), %rbp
pushq %rbp
pushq %r11
pushq %r10
callq 0x2250
addq $0x20, %rsp
incq %r12
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
movq %rcx, %rdx
sarq $0x3, %rdx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r12
jl 0x174a6
movq 0x8(%rsp), %rsi
incq %rsi
movq 0x18(%rsp), %r14
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
movq %rcx, %rdx
sarq $0x3, %rdx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %rsi
jl 0x173b1
movq %r13, %rdi
callq 0x2170
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1637b(%rip), %rdi     # 0x2d8d6
movq %r12, %rsi
xorl %eax, %eax
callq 0x2270
leaq 0x1636a(%rip), %rdi     # 0x2d8d6
jmp 0x1755e