// File: /workspace/github_cpp_makefile_star2_O1/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 %r14
movq %r14, %rsi
callq 0x2120
movq %rax, %r15
leaq 0x211b30(%rip), %rsi    # 0x238219
movq %rax, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x215d01(%rip), %rsi    # 0x23c3fe
movq %r15, 0x10(%rsp)
movq %r15, %rdi
callq 0x2210
movq %rax, %r15
pushq $0x8
popq %rsi
movq %r12, %rdi
movq %r14, %rdx
movq %rax, %rcx
callq 0x2410
cmpq $0x0, (%r12)
je 0x267e6
pushq $0x1
popq %r14
xorl %eax, %eax
pushq $0x1
popq %rbp
movq 0x10(%r12), %rcx
imulq $0x28, %rax, %r13
leaq (%rcx,%r13), %rdi
addq $0x18, %rdi
pushq $0x8
popq %rbx
movq %rbx, %rsi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x2410
movq 0x10(%r12), %rax
leaq (%rax,%r13), %rdi
addq $0x20, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x2410
movq 0x10(%r12), %rdi
addq %r13, %rdi
pushq $0x4
popq %rbx
movq %rbx, %rsi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x2410
movq 0x10(%r12), %rax
leaq (%rax,%r13), %rdi
addq $0x4, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x2410
movq 0x10(%r12), %rax
movq 0x8(%rax,%r13), %rdi
movslq (%rax,%r13), %rdx
pushq $0x48
popq %rsi
movq %r15, %rcx
callq 0x2410
movq 0x10(%r12), %rax
movq 0x10(%rax,%r13), %rdi
movslq 0x4(%rax,%r13), %rdx
pushq $0x1c
popq %rsi
movq %r15, %rcx
callq 0x2410
movl %r14d, %eax
incl %r14d
cmpq %rax, (%r12)
ja 0x26732
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 0x263757(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
leaq 0x211994(%rip), %rsi    # 0x238227
leaq 0x2119bc(%rip), %rdx    # 0x238256
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