// File: chhylp123[P]hifiasm/inter.cpp
// Function: init_ug_trans_t(ug_trans_t*, ug_opt_t*, int, int, int, int, double, double, double, double, double, int, int, int, int, ma_ug_t*, asg_t*, bubble_type*, unsigned char)
void init_ug_trans_t(ug_trans_t *opt, ug_opt_t *uopt, int32_t is_HPC, int32_t k, int32_t w, int32_t max_n_chain, 
double bw_thres, double diff_ec_ul, double bw_thres_double, double diff_ec_ul_double, double sec_cutoff, int32_t n_thread, 
int32_t mini_cut, int32_t chain_cut, int32_t keep_unsymm_arc, ma_ug_t *ug, asg_t *sg, bubble_type *bub, uint8_t gen_bub)
{
    int64_t i; uint8_t *bf = NULL;
    memset(opt, 0, sizeof((*opt)));
	opt->uopt = uopt;
    opt->k = k; 
    opt->w = w;
    opt->is_HPC = is_HPC;
    opt->max_n_chain = max_n_chain;
    opt->bw_thres = bw_thres;
	opt->bw_thres_double = bw_thres_double;
    opt->diff_ec_ul = diff_ec_ul;
	opt->diff_ec_ul_double = diff_ec_ul_double;
	opt->sec_cutoff = sec_cutoff;
	opt->mini_cut = mini_cut;
	opt->chain_cut = chain_cut;
	opt->keep_unsymm_arc = keep_unsymm_arc;

    opt->bw = 10000;///2000 in minigraph
    opt->max_gap = 500000;///5000 in minigraph
    opt->ug = ug;
    opt->rg = sg;
    opt->n_thread = ((n_thread>=1)?n_thread:1);

	CALLOC(opt->free_cnt, opt->n_thread);
    CALLOC(opt->hab, opt->n_thread); 
	CALLOC(opt->ll, opt->n_thread);
    for (i = 0; i < opt->n_thread; ++i) {
        opt->hab[i] = ha_ovec_init(0, 0, 1); 
    }

	opt->idx_n.n = opt->idx_n.m = ug->u.n+1;
	MALLOC(opt->idx_n.a, opt->idx_n.n);

	opt->udb.ug = ug;
	if(bub) {
		opt->bub = bub;
	} else if(gen_bub) {
		opt->bub = gen_bubble_chain(sg, ug, uopt, &bf, 0); free(bf);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movb 0x48(%rbp), %al
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movl 0x28(%rbp), %eax
movl 0x20(%rbp), %eax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movl %r9d, -0x20(%rbp)
movsd %xmm0, -0x28(%rbp)
movsd %xmm1, -0x30(%rbp)
movsd %xmm2, -0x38(%rbp)
movsd %xmm3, -0x40(%rbp)
movsd %xmm4, -0x48(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movl $0x110, %edx            # imm = 0x110
callq 0x2100
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movl -0x18(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x34(%rax)
movl -0x1c(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x30(%rax)
movl -0x14(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0xa0(%rax)
movl -0x20(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x60(%rax)
movsd -0x28(%rbp), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, 0x38(%rax)
movsd -0x38(%rbp), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, 0x50(%rax)
movsd -0x30(%rbp), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, 0x40(%rax)
movsd -0x40(%rbp), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, 0x58(%rax)
movsd -0x48(%rbp), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, 0x48(%rax)
movl 0x18(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0xbc(%rax)
movl 0x20(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0xc0(%rax)
movl 0x28(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0xc4(%rax)
movq -0x8(%rbp), %rax
movl $0x2710, 0xa4(%rax)     # imm = 0x2710
movq -0x8(%rbp), %rax
movl $0x7a120, 0xa8(%rax)    # imm = 0x7A120
movq 0x30(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x38(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
cmpl $0x1, 0x10(%rbp)
jl 0x300f6f
movl 0x10(%rbp), %eax
movl %eax, -0x5c(%rbp)
jmp 0x300f79
movl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x300f79
movl -0x5c(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0xb0(%rax)
movq -0x8(%rbp), %rax
movslq 0xb0(%rax), %rdi
movl $0x4, %esi
callq 0x2140
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x100(%rax)
movq -0x8(%rbp), %rax
movslq 0xb0(%rax), %rdi
movl $0x8, %esi
callq 0x2140
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movslq 0xb0(%rax), %rdi
movl $0x68, %esi
callq 0x2140
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x20(%rax)
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x8(%rbp), %rcx
movslq 0xb0(%rcx), %rcx
cmpq %rcx, %rax
jge 0x301034
xorl %esi, %esi
movl $0x1, %edx
movl %esi, %edi
callq 0x14c90
movq %rax, %rdx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x50(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x300ff1
movq 0x30(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x80(%rax)
movq -0x8(%rbp), %rax
movq %rcx, 0x78(%rax)
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rdi
shlq $0x3, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x88(%rax)
movq 0x30(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0xc8(%rax)
cmpq $0x0, 0x40(%rbp)
je 0x301095
movq 0x40(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x28(%rax)
jmp 0x3010c9
cmpb $0x0, 0x48(%rbp)
je 0x3010c7
movq 0x38(%rbp), %rdi
movq 0x30(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq -0x58(%rbp), %rcx
xorl %r8d, %r8d
callq 0x322770
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x58(%rbp), %rdi
callq 0x2210
jmp 0x3010c9
addq $0x60, %rsp
popq %rbp
retq
nop