// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/inter.cpp
// Function: write_ul_hits(mg_gres_a*, mg_dbn_t*, char const*)
void write_ul_hits(mg_gres_a *hits, mg_dbn_t *nn, const char *fn)
{
	char *buf = (char*)calloc(strlen(fn) + 25, 1);
    sprintf(buf, "%s.ul.aln.bin", fn);
    FILE* fp = fopen(buf, "w");
	uint32_t i;

    fwrite(&hits->n, sizeof(hits->n), 1, fp);
	for (i = 0; i < hits->n; i++) {
		fwrite(&hits->a[i].qid, sizeof(hits->a[i].qid), 1, fp);
		fwrite(&hits->a[i].qlen, sizeof(hits->a[i].qlen), 1, fp);
		fwrite(&hits->a[i].n_gc, sizeof(hits->a[i].n_gc), 1, fp);
		fwrite(&hits->a[i].n_lc, sizeof(hits->a[i].n_lc), 1, fp);
		fwrite(hits->a[i].gc, sizeof(mg_gchain_t), hits->a[i].n_gc, fp);
		fwrite(hits->a[i].lc, sizeof(mg_lres_t), hits->a[i].n_lc, fp);
	}
    // fwrite(hits->a, sizeof(mg_gres_t), hits->n, fp);
	fwrite(&hits->total_pair, sizeof(hits->total_pair), 1, fp);
	fwrite(&hits->total_base, sizeof(hits->total_base), 1, fp);

	fwrite(&(nn->n), sizeof(nn->n), 1, fp);
	fwrite(nn->a, sizeof(uint64_t), nn->n, fp);
	fwrite(&(nn->tl), sizeof(nn->tl), 1, fp);
	fwrite(&(nn->cc.n), sizeof(nn->cc.n), 1, fp);
	fwrite(nn->cc.a, sizeof(char), nn->cc.n, fp);
    // write_dbug(ug, fp);

    fclose(fp);
	fprintf(stderr, "[M::%s::] ==> UL alignments have been written\n", __func__);
    free(buf);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rsi, 0x8(%rsp)
movq %rdi, %r12
movq %rdx, %rdi
callq 0x2090
leaq 0x19(%rax), %rdi
pushq $0x1
popq %r13
movq %r13, %rsi
callq 0x2120
movq %rax, %r14
leaq 0x608d8(%rip), %rsi     # 0x1f63b1
xorl %ebp, %ebp
movq %rax, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x64bb2(%rip), %rsi     # 0x1fa6a1
movq %r14, 0x10(%rsp)
movq %r14, %rdi
callq 0x2210
movq %rax, %r15
pushq $0x8
popq %rsi
movq %r12, %rdi
movq %r13, %rdx
movq %rax, %rcx
callq 0x2410
movl %ebp, %r14d
cmpq %r14, (%r12)
jbe 0x195bca
movq 0x10(%r12), %rax
imulq $0x28, %r14, %rbp
leaq (%rax,%rbp), %rdi
addq $0x18, %rdi
pushq $0x8
popq %rbx
movq %rbx, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x2410
movq 0x10(%r12), %rax
leaq (%rax,%rbp), %rdi
addq $0x20, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x2410
movq 0x10(%r12), %rdi
addq %rbp, %rdi
pushq $0x4
popq %rbx
movq %rbx, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x2410
movq 0x10(%r12), %rax
leaq (%rax,%rbp), %rdi
addq $0x4, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x2410
movq 0x10(%r12), %rax
movq 0x8(%rax,%rbp), %rdi
movslq (%rax,%rbp), %rdx
pushq $0x48
popq %rsi
movq %r15, %rcx
callq 0x2410
movq 0x10(%r12), %rax
movq 0x10(%rax,%rbp), %rdi
movslq 0x4(%rax,%rbp), %rdx
pushq $0x1c
popq %rsi
movq %r15, %rcx
callq 0x2410
leal 0x1(%r14), %ebp
jmp 0x195b10
leaq 0x20(%r12), %rdi
pushq $0x8
popq %r14
pushq $0x1
popq %rbx
movq %r14, %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x2410
addq $0x18, %r12
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x2410
movq 0x8(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x2410
movq (%r12), %rdx
movq 0x10(%r12), %rdi
movq %r14, %rsi
movq %r15, %rcx
callq 0x2410
leaq 0x18(%r12), %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x2410
leaq 0x20(%r12), %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x2410
movq 0x20(%r12), %rdx
movq 0x30(%r12), %rdi
movq %rbx, %rsi
movq %r15, %rcx
callq 0x2410
movq %r15, %rdi
callq 0x2190
movq 0xbd373(%rip), %rax     # 0x252fe0
movq (%rax), %rdi
leaq 0x60748(%rip), %rsi     # 0x1f63bf
leaq 0x60770(%rip), %rdx     # 0x1f63ee
xorl %eax, %eax
callq 0x22b0
movq 0x10(%rsp), %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2220