// File: chhylp123[P]hifiasm/rcut.cpp
// Function: prt_rcut_res(char const*, signed char*, ma_ug_t*, asg_t*)
void prt_rcut_res(const char* fn, int8_t *s, ma_ug_t *ug, asg_t *sg)
{
	uint32_t i, k, flag = AMBIGU; 
	char *buf = (char*)calloc(strlen(fn) + 50, 1);
    sprintf(buf, "%s.rcut.res.log", fn);
    FILE *fp = fopen(buf, "w");
	uint8_t *rs = NULL; MALLOC(rs, sg->n_seq);
	memset(rs, AMBIGU, sg->n_seq*sizeof((*rs)));

    for (i = 0; i < ug->g->n_seq; i++) {
        if(ug->g->seq[i].del) continue;
        flag = AMBIGU;
		if(s[i] == 0) continue;
		flag = (s[i] > 0? FATHER:MOTHER);
        for (k = 0; k < ug->u.a[i].n; k++) rs[ug->u.a[i].a[k]>>33] = flag;
    }

	for (i = 0; i < sg->n_seq; i++) {
		if(rs[i] == AMBIGU) continue;
		fprintf(fp, "%.*s\t%u\n", (int)Get_NAME_LENGTH(R_INF, i), Get_NAME(R_INF, i), rs[i]);
	}

	fclose(fp); free(rs);
    free(buf);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
callq 0x20a0
movq %rax, %rdi
addq $0x32, %rdi
movl $0x1, %esi
callq 0x2140
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq -0x8(%rbp), %rdx
leaq 0x162336(%rip), %rsi    # 0x38e112
movb $0x0, %al
callq 0x2050
movq -0x38(%rbp), %rdi
leaq 0x16d5e4(%rip), %rsi    # 0x3993d2
callq 0x2200
movq %rax, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x20(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %edi
shlq $0x0, %rdi
callq 0x2270
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %edx
shlq $0x0, %rdx
xorl %esi, %esi
callq 0x2100
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
jae 0x22bf1d
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movl -0x24(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x22be7d
jmp 0x22bf0f
movl $0x0, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x22be96
jmp 0x22bf0f
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
movsbl (%rax,%rcx), %edx
movl $0x2, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovgl %ecx, %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x24(%rbp), %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x10(%rcx), %eax
jae 0x22bf0d
movl -0x2c(%rbp), %eax
movb %al, %dl
movq -0x48(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x24(%rbp), %esi
imulq $0x28, %rsi, %rsi
addq %rsi, %rcx
movq 0x18(%rcx), %rcx
movl -0x28(%rbp), %esi
movq (%rcx,%rsi,8), %rcx
shrq $0x21, %rcx
movb %dl, (%rax,%rcx)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x22bebb
jmp 0x22bf0f
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x22be42
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
jae 0x22bfc2
movq -0x48(%rbp), %rax
movl -0x24(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x22bf4e
jmp 0x22bfb4
movq -0x40(%rbp), %rdi
leaq 0x199377(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movl -0x24(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
leaq 0x199360(%rip), %rcx    # 0x3c52d0
movq 0x40(%rcx), %rcx
movl -0x24(%rbp), %edx
subq (%rcx,%rdx,8), %rax
movl %eax, %edx
leaq 0x19934c(%rip), %rax    # 0x3c52d0
movq 0x8(%rax), %rcx
leaq 0x199341(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movl -0x24(%rbp), %esi
addq (%rax,%rsi,8), %rcx
movq -0x48(%rbp), %rax
movl -0x24(%rbp), %esi
movzbl (%rax,%rsi), %r8d
leaq 0x155aaa(%rip), %rsi    # 0x381a57
movb $0x0, %al
callq 0x22a0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x22bf24
movq -0x40(%rbp), %rdi
callq 0x21a0
movq -0x48(%rbp), %rdi
callq 0x2210
movq -0x38(%rbp), %rdi
callq 0x2210
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)