// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/inter.cpp
// Function: write_all_ul_t(all_ul_t*, char*, ma_ug_t*)
int32_t write_all_ul_t(all_ul_t *x, char* file_name, ma_ug_t *ug)
{
	char* gfa_name = NULL; MALLOC(gfa_name, strlen(file_name)+50);
	sprintf(gfa_name, "%s.ul.ovlp.bin", file_name);
	FILE* fp = fopen(gfa_name, "w"); free(gfa_name);
	if (!fp) return 0;
	uint64_t k; ul_vec_t *p = NULL;

	if(ug) write_dbug(ug, fp);

	fwrite(&x->nid.n, sizeof(x->nid.n), 1, fp);
	for (k = 0; k < x->nid.n; k++) {
		fwrite(&x->nid.a[k].n, sizeof(x->nid.a[k].n), 1, fp);
		fwrite(x->nid.a[k].a, sizeof((*(x->nid.a[k].a))), x->nid.a[k].n, fp);
	}

	fwrite(&x->ridx.idx.n, sizeof(x->ridx.idx.n), 1, fp);
	fwrite(x->ridx.idx.a, sizeof((*(x->ridx.idx.a))), x->ridx.idx.n, fp);

	fwrite(&x->ridx.occ.n, sizeof(x->ridx.occ.n), 1, fp);
	fwrite(x->ridx.occ.a, sizeof((*(x->ridx.occ.a))), x->ridx.occ.n, fp);

	fwrite(&x->n, sizeof(x->n), 1, fp);
	for (k = 0; k < x->n; k++) {
		p = &(x->a[k]);
		fwrite(&p->dd, sizeof(p->dd), 1, fp);
		fwrite(&p->rlen, sizeof(p->rlen), 1, fp);

		fwrite(&p->r_base.n, sizeof(p->r_base.n), 1, fp);
		fwrite(p->r_base.a, sizeof((*(p->r_base.a))), p->r_base.n, fp);

		fwrite(&p->bb.n, sizeof(p->bb.n), 1, fp);
		fwrite(p->bb.a, sizeof((*(p->bb.a))), p->bb.n, fp);

		fwrite(&p->N_site.n, sizeof(p->N_site.n), 1, fp);
		fwrite(p->N_site.a, sizeof((*(p->N_site.a))), p->N_site.n, fp);
	}

	fprintf(stderr, "[M::%s] Index has been written.\n", __func__);
	fclose(fp);
	if(asm_opt.bin_only) exit(0);
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x2090
leaq 0x32(%rax), %rdi
callq 0x2280
movq %rax, %r12
leaq 0x612c4(%rip), %rsi     # 0x1fbac5
xorl %ebp, %ebp
movq %rax, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x5fe8a(%rip), %rsi     # 0x1fa6a1
movq %r12, %rdi
callq 0x2210
movq %rax, %r14
movq %r12, %rdi
callq 0x2220
testq %r14, %r14
jne 0x19a840
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, 0x8(%rsp)
testq %r15, %r15
je 0x19a855
movq %r15, %rdi
movq %r14, %rsi
callq 0x873f8
pushq $0x8
popq %r15
pushq $0x1
popq %r12
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x2410
xorl %ebx, %ebx
pushq $0x4
popq %r13
jmp 0x19a8af
movq 0x10(%rbp), %rdi
addq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x2410
movq 0x10(%rbp), %rax
movq -0x8(%rax,%r15), %rdi
movl (%rax,%r15), %edx
movq %r12, %rsi
movq %r14, %rcx
callq 0x2410
incq %rbx
addq $0x10, %r15
cmpq (%rbp), %rbx
jb 0x19a87b
leaq 0x18(%rbp), %rdi
pushq $0x8
popq %rbx
pushq $0x1
popq %r15
movq %rbx, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2410
movq 0x18(%rbp), %rdx
movq 0x28(%rbp), %rdi
pushq $0x4
popq %rsi
movq %r14, %rcx
callq 0x2410
leaq 0x30(%rbp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2410
movq 0x30(%rbp), %rdx
movq 0x40(%rbp), %rdi
movq %rbx, %rsi
movq %r14, %rcx
callq 0x2410
leaq 0x50(%rbp), %rdi
movq %rdi, 0x10(%rsp)
movq %rbx, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2410
pushq $0x40
popq %rbx
xorl %ecx, %ecx
pushq $0x1
popq %r12
jmp 0x19a9f3
movq 0x8(%rsp), %rax
movq 0x48(%rax), %r13
leaq (%rbx,%r13), %rax
movq %rax, 0x18(%rsp)
leaq (%rbx,%r13), %rbp
addq $-0x40, %rbp
movsbl 0x50(%rbp), %edi
movq %r14, %rsi
movq %rcx, 0x20(%rsp)
callq 0x2270
leaq (%rbx,%r13), %r15
addq $-0x28, %r15
movq %r15, %rdi
pushq $0x4
popq %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x2410
movq %rbp, %rdi
pushq $0x8
popq %rbp
movq %rbp, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x2410
movq -0x18(%r15), %rdx
movq -0x8(%r15), %rdi
movq %r12, %rsi
movq %r14, %rcx
callq 0x2410
leaq (%rbx,%r13), %r15
addq $-0x20, %r15
movq %r15, %rdi
movq %rbp, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x2410
movq (%r15), %rdx
movq 0x10(%r15), %rdi
pushq $0x24
popq %rsi
movq %r14, %rcx
callq 0x2410
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x2410
movq 0x18(%r15), %rdi
movq 0x20(%r15), %rdx
pushq $0x4
popq %rsi
movq %r14, %rcx
callq 0x2410
movq 0x20(%rsp), %rcx
incq %rcx
addq $0x58, %rbx
movq 0x10(%rsp), %rax
cmpq (%rax), %rcx
jb 0x19a92b
movq 0xb85d8(%rip), %rax     # 0x252fe0
movq (%rax), %rdi
leaq 0x51750(%rip), %rsi     # 0x1ec162
leaq 0x5bda8(%rip), %rdx     # 0x1f67c1
xorl %eax, %eax
callq 0x22b0
movq %r14, %rdi
callq 0x2190
leaq 0xb8d29(%rip), %rax     # 0x253758
cmpb $0x0, 0x24e(%rax)
jne 0x19aa40
pushq $0x1
popq %rbp
jmp 0x19a82f
xorl %edi, %edi
callq 0x2250