// File: /workspace/github_cpp_makefile_star2_O1/yuansliu[P]HiRGC/hirgc.cpp
// Function: saveOtherData(_IO_FILE*)
void saveOtherData(FILE *fp) { // write auxiliary information to file
	fprintf(fp, "%s\n", meta_data);//identifier
	//------------------------
	writeRunLengthCoding(fp, line_break_len, line_break_vec);//length of shor seuqences
	//------------------------
	fprintf(fp, "%d", pos_vec_len); //intervals of lower-case letters
	for (int i = 0; i < pos_vec_len; i++) {
		fprintf(fp, " %d %d", pos_vec[i].begin, pos_vec[i].length);
	}
	//------------------------
	fprintf(fp, "\n%d", n_vec_len); //intervals of the letter 'N'
	for (int i = 0; i < n_vec_len; i++) {
		fprintf(fp, " %d %d", n_vec[i].begin, n_vec[i].length);
	}
	//------------------------
	fprintf(fp, "\n%d", other_char_len); //other characters
	if (other_char_len > 0) {
		int flag[30];
		for (int i = 0; i < 26; i++) {
			flag[i] = -1;
		}
		vector<int> arr;
	
		for (int i = 0; i < other_char_len; i++) {
			fprintf(fp, " %d", other_char_vec[i].pos);

			int temp = other_char_vec[i].ch;
			if (flag[temp] == -1) {
				arr.push_back(temp);
				flag[temp] = arr.size()-1;
			}
		}

		//save other char information
		int size = arr.size();
		fprintf(fp, " %d", size);
		for (int i = 0; i < size; i++) {
			fprintf(fp, " %d", arr[i]);
		}

		if (size < 10) {
			fprintf(fp, " ");
			for (int i = 0; i < other_char_len; i++) {
				fprintf(fp, "%d", flag[other_char_vec[i].ch]);
			}
		} else {
			int bit_num = ceil(log(size)/log(2));
			int v_num = floor(32.0/bit_num);

			for (int i = 0; i < other_char_len; ) {
				// fprintf(fp, "%d ", flag[other_char_vec[i].ch]);
				unsigned int v = 0;
				for (int j = 0; j < v_num && i < other_char_len; j++, i++) {
					v <<= bit_num;
					v += flag[other_char_vec[i].ch];
				}
				fprintf(fp, " %u", v);
			}
		}
	}
	fprintf(fp, "\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, %rbx
movq 0x5318(%rip), %rdx      # 0x8178
leaq 0x2215(%rip), %rsi      # 0x507c
xorl %eax, %eax
callq 0x21e0
movl 0x5354(%rip), %esi      # 0x81c8
movq 0x531d(%rip), %rdx      # 0x8198
movq %rbx, %rdi
callq 0x2c7b
movl 0x5337(%rip), %edx      # 0x81c0
leaq 0x21ca(%rip), %rsi      # 0x505a
movq %rbx, %rdi
xorl %eax, %eax
callq 0x21e0
cmpl $0x0, 0x531f(%rip)      # 0x81c0
jle 0x2ed9
leaq 0x21a8(%rip), %r14      # 0x5052
xorl %r15d, %r15d
movq 0x52cc(%rip), %rax      # 0x8180
movl (%rax,%r15,8), %edx
movl 0x4(%rax,%r15,8), %ecx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x21e0
incq %r15
movslq 0x52ec(%rip), %rax      # 0x81c0
cmpq %rax, %r15
jl 0x2ead
movl 0x52e5(%rip), %edx      # 0x81c4
leaq 0x2173(%rip), %rsi      # 0x5059
movq %rbx, %rdi
xorl %eax, %eax
callq 0x21e0
cmpl $0x0, 0x52cd(%rip)      # 0x81c4
jle 0x2f2f
leaq 0x2152(%rip), %r14      # 0x5052
xorl %r15d, %r15d
movq 0x527e(%rip), %rax      # 0x8188
movl (%rax,%r15,8), %edx
movl 0x4(%rax,%r15,8), %ecx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x21e0
incq %r15
movslq 0x529a(%rip), %rax      # 0x81c4
cmpq %rax, %r15
jl 0x2f03
movl 0x527b(%rip), %edx      # 0x81b0
leaq 0x211d(%rip), %rsi      # 0x5059
movq %rbx, %rdi
xorl %eax, %eax
callq 0x21e0
cmpl $0x0, 0x5263(%rip)      # 0x81b0
jle 0x31b2
pcmpeqd %xmm0, %xmm0
movdqa %xmm0, 0x90(%rsp)
movdqa %xmm0, 0x80(%rsp)
movdqa %xmm0, 0x70(%rsp)
movdqa %xmm0, 0x60(%rsp)
movdqa %xmm0, 0x50(%rsp)
movdqa %xmm0, 0x40(%rsp)
movq $-0x1, 0xa0(%rsp)
pxor %xmm0, %xmm0
movdqa %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
cmpl $0x0, 0x5209(%rip)      # 0x81b0
jle 0x303c
leaq 0x20a1(%rip), %r14      # 0x5055
leaq 0x10(%rsp), %r15
leaq 0xc(%rsp), %r12
xorl %r13d, %r13d
movq 0x51c8(%rip), %rax      # 0x8190
movl (%rax,%r13,8), %edx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x21e0
movq 0x51b0(%rip), %rax      # 0x8190
movslq 0x4(%rax,%r13,8), %rax
movl %eax, 0xc(%rsp)
cmpl $-0x1, 0x40(%rsp,%rax,4)
jne 0x302d
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x3009
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x3014
movq %r15, %rdi
movq %r12, %rdx
callq 0x43c0
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
shrq $0x2, %rax
decl %eax
movslq 0xc(%rsp), %rcx
movl %eax, 0x40(%rsp,%rcx,4)
incq %r13
movslq 0x5179(%rip), %rax      # 0x81b0
cmpq %rax, %r13
jl 0x2fc1
movq 0x18(%rsp), %r14
subq 0x10(%rsp), %r14
shrq $0x2, %r14
leaq 0x2004(%rip), %rsi      # 0x5055
movq %rbx, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x21e0
testl %r14d, %r14d
jle 0x3095
movl %r14d, %r12d
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
leaq 0x1fe1(%rip), %r15      # 0x5055
xorl %r13d, %r13d
movq 0x10(%rsp), %rax
movl (%rax,%r13,4), %edx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x21e0
incq %r13
cmpq %r13, %r12
jne 0x3077
cmpl $0xa, %r14d
jge 0x30f0
movl $0x20, %edi
movq %rbx, %rsi
callq 0x21a0
cmpl $0x0, 0x5101(%rip)      # 0x81b0
jle 0x31a3
leaq 0x1f9e(%rip), %r14      # 0x505a
xorl %r15d, %r15d
movq 0x50ca(%rip), %rax      # 0x8190
movslq 0x4(%rax,%r15,8), %rax
movl 0x40(%rsp,%rax,4), %edx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x21e0
incq %r15
movslq 0x50ca(%rip), %rax      # 0x81b0
cmpq %rax, %r15
jl 0x30bf
jmp 0x31a3
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
callq 0x2110
divsd 0x1f03(%rip), %xmm0     # 0x5008
callq 0x2050
movapd %xmm0, 0x30(%rsp)
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm1
movsd 0x1ef0(%rip), %xmm0     # 0x5010
divsd %xmm1, %xmm0
callq 0x2250
movl 0x5081(%rip), %ecx      # 0x81b0
testl %ecx, %ecx
jle 0x31a3
cvttsd2si 0x30(%rsp), %ebp
cvttsd2si %xmm0, %r15d
leaq 0x1f18(%rip), %r14      # 0x505d
xorl %r12d, %r12d
testl %r15d, %r15d
jle 0x3189
movq 0x503c(%rip), %rax      # 0x8190
movslq %r12d, %r8
movslq %ecx, %rsi
incq %r8
xorl %edx, %edx
movl $0x1, %edi
movl %ebp, %ecx
shll %cl, %edx
movslq -0x4(%rax,%r8,8), %rcx
addl 0x40(%rsp,%rcx,4), %edx
incl %r12d
cmpl %r15d, %edi
jge 0x318b
leaq 0x1(%r8), %rcx
incl %edi
cmpq %rsi, %r8
movq %rcx, %r8
jl 0x3164
jmp 0x318b
xorl %edx, %edx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x21e0
movl 0x5012(%rip), %ecx      # 0x81b0
cmpl %ecx, %r12d
jl 0x3148
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x31b2
callq 0x2150
movl $0xa, %edi
movq %rbx, %rsi
callq 0x21a0
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x31e3
callq 0x2150
movq %rbx, %rdi
callq 0x2260