// File: 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:
subq $0x108, %rsp            # imm = 0x108
movq %rdi, 0x100(%rsp)
movq 0x100(%rsp), %rdi
movq 0x78fa(%rip), %rdx      # 0xb188
leaq 0x47d9(%rip), %rsi      # 0x806e
movb $0x0, %al
callq 0x2200
movq 0x100(%rsp), %rdi
movl 0x792e(%rip), %esi      # 0xb1d8
movq 0x78f7(%rip), %rdx      # 0xb1a8
callq 0x36c0
movq 0x100(%rsp), %rdi
movl 0x790c(%rip), %edx      # 0xb1d0
leaq 0x477f(%rip), %rsi      # 0x804a
movb $0x0, %al
callq 0x2200
movl $0x0, 0xfc(%rsp)
movl 0xfc(%rsp), %eax
cmpl 0x78e6(%rip), %eax      # 0xb1d0
jge 0x393a
movq 0x100(%rsp), %rdi
movq 0x7895(%rip), %rax      # 0xb190
movslq 0xfc(%rsp), %rcx
movl (%rax,%rcx,8), %edx
movq 0x7883(%rip), %rax      # 0xb190
movslq 0xfc(%rsp), %rcx
movl 0x4(%rax,%rcx,8), %ecx
leaq 0x4722(%rip), %rsi      # 0x8042
movb $0x0, %al
callq 0x2200
movl 0xfc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xfc(%rsp)
jmp 0x38dd
movq 0x100(%rsp), %rdi
movl 0x788c(%rip), %edx      # 0xb1d4
leaq 0x46fa(%rip), %rsi      # 0x8049
movb $0x0, %al
callq 0x2200
movl $0x0, 0xf8(%rsp)
movl 0xf8(%rsp), %eax
cmpl 0x7866(%rip), %eax      # 0xb1d4
jge 0x39be
movq 0x100(%rsp), %rdi
movq 0x7819(%rip), %rax      # 0xb198
movslq 0xf8(%rsp), %rcx
movl (%rax,%rcx,8), %edx
movq 0x7807(%rip), %rax      # 0xb198
movslq 0xf8(%rsp), %rcx
movl 0x4(%rax,%rcx,8), %ecx
leaq 0x469e(%rip), %rsi      # 0x8042
movb $0x0, %al
callq 0x2200
movl 0xf8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf8(%rsp)
jmp 0x3961
movq 0x100(%rsp), %rdi
movl 0x77f4(%rip), %edx      # 0xb1c0
leaq 0x4676(%rip), %rsi      # 0x8049
movb $0x0, %al
callq 0x2200
cmpl $0x0, 0x77df(%rip)      # 0xb1c0
jle 0x3ce7
movl $0x0, 0x7c(%rsp)
cmpl $0x1a, 0x7c(%rsp)
jge 0x3a13
movslq 0x7c(%rsp), %rax
movl $0xffffffff, 0x80(%rsp,%rax,4) # imm = 0xFFFFFFFF
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
jmp 0x39ef
leaq 0x60(%rsp), %rdi
callq 0x51b0
movl $0x0, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
cmpl 0x7791(%rip), %eax      # 0xb1c0
jge 0x3adb
movq 0x100(%rsp), %rdi
movq 0x775c(%rip), %rax      # 0xb1a0
movslq 0x5c(%rsp), %rcx
movl (%rax,%rcx,8), %edx
leaq 0x45f2(%rip), %rsi      # 0x8045
movb $0x0, %al
callq 0x2200
movq 0x773f(%rip), %rax      # 0xb1a0
movslq 0x5c(%rsp), %rcx
movl 0x4(%rax,%rcx,8), %eax
movl %eax, 0x58(%rsp)
movslq 0x58(%rsp), %rax
cmpl $-0x1, 0x80(%rsp,%rax,4)
jne 0x3ac9
leaq 0x60(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x51c0
jmp 0x3a8e
leaq 0x60(%rsp), %rdi
callq 0x5250
subq $0x1, %rax
movl %eax, %ecx
movslq 0x58(%rsp), %rax
movl %ecx, 0x80(%rsp,%rax,4)
jmp 0x3ac9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x5270
jmp 0x3d05
jmp 0x3acb
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x3a25
leaq 0x60(%rsp), %rdi
callq 0x5250
movl %eax, 0x48(%rsp)
movq 0x100(%rsp), %rdi
movl 0x48(%rsp), %edx
leaq 0x4549(%rip), %rsi      # 0x8045
movb $0x0, %al
callq 0x2200
movl $0x0, 0x44(%rsp)
movl 0x44(%rsp), %eax
cmpl 0x48(%rsp), %eax
jge 0x3b53
movq 0x100(%rsp), %rax
movq %rax, 0x20(%rsp)
movslq 0x44(%rsp), %rsi
leaq 0x60(%rsp), %rdi
callq 0x5230
movq 0x20(%rsp), %rdi
movl (%rax), %edx
leaq 0x4506(%rip), %rsi      # 0x8045
movb $0x0, %al
callq 0x2200
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0x3b0b
cmpl $0xa, 0x48(%rsp)
jge 0x3bc4
movq 0x100(%rsp), %rdi
leaq 0x44e4(%rip), %rsi      # 0x804d
movb $0x0, %al
callq 0x2200
movl $0x0, 0x40(%rsp)
movl 0x40(%rsp), %eax
cmpl 0x763e(%rip), %eax      # 0xb1c0
jge 0x3bbf
movq 0x100(%rsp), %rdi
movq 0x760d(%rip), %rax      # 0xb1a0
movslq 0x40(%rsp), %rcx
movslq 0x4(%rax,%rcx,8), %rax
movl 0x80(%rsp,%rax,4), %edx
leaq 0x449f(%rip), %rsi      # 0x804a
movb $0x0, %al
callq 0x2200
movl 0x40(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x40(%rsp)
jmp 0x3b78
jmp 0x3cdd
movl 0x48(%rsp), %edi
callq 0x52d0
movsd %xmm0, 0x18(%rsp)
jmp 0x3bd5
movl $0x2, %edi
callq 0x52d0
movsd %xmm0, 0x10(%rsp)
jmp 0x3be7
movsd 0x10(%rsp), %xmm1
movsd 0x18(%rsp), %xmm0
divsd %xmm1, %xmm0
callq 0x2050
cvttsd2si %xmm0, %eax
movl %eax, 0x3c(%rsp)
cvtsi2sdl 0x3c(%rsp), %xmm1
movsd 0x43f6(%rip), %xmm0     # 0x8008
divsd %xmm1, %xmm0
callq 0x2270
cvttsd2si %xmm0, %eax
movl %eax, 0x38(%rsp)
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
cmpl 0x758b(%rip), %eax      # 0xb1c0
jge 0x3cdb
movl $0x0, 0x30(%rsp)
movl $0x0, 0x2c(%rsp)
movl 0x2c(%rsp), %ecx
xorl %eax, %eax
cmpl 0x38(%rsp), %ecx
movb %al, 0xf(%rsp)
jge 0x3c6c
movl 0x34(%rsp), %eax
cmpl 0x755b(%rip), %eax      # 0xb1c0
setl %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x3c76
jmp 0x3cbc
movl 0x3c(%rsp), %ecx
movl 0x30(%rsp), %eax
shll %cl, %eax
movl %eax, 0x30(%rsp)
movq 0x7515(%rip), %rax      # 0xb1a0
movslq 0x34(%rsp), %rcx
movslq 0x4(%rax,%rcx,8), %rax
movl 0x80(%rsp,%rax,4), %eax
addl 0x30(%rsp), %eax
movl %eax, 0x30(%rsp)
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x3c4b
movq 0x100(%rsp), %rdi
movl 0x30(%rsp), %edx
leaq 0x4380(%rip), %rsi      # 0x804f
movb $0x0, %al
callq 0x2200
jmp 0x3c2b
jmp 0x3cdd
leaq 0x60(%rsp), %rdi
callq 0x5270
movq 0x100(%rsp), %rdi
leaq 0x44c3(%rip), %rsi      # 0x81b9
movb $0x0, %al
callq 0x2200
addq $0x108, %rsp            # imm = 0x108
retq
movq 0x50(%rsp), %rdi
callq 0x2280
nop