// File: chhylp123[P]hifiasm/rcut.cpp
// Function: mc_set_bp_spin(bubble_type*, mc_match_t*, mc_svaux_t*, mc_bp_t*, unsigned char*, bits_p*, mc_bp_res*)
void mc_set_bp_spin(bubble_type* bub, mc_match_t *ma, mc_svaux_t *b_aux, mc_bp_t* bp,
uint8_t *lock, bits_p *vis, mc_bp_res *res)
{
	uint32_t uid, val = 0, c_bid, c_uid;
	mc_bp_iter i;
	i.chain_id = res->chain_id;
	i.bid = res->f_bid;
	i.uid = res->f_uid;
	memset(vis->a, 0, vis->n);
	while (1)
    {
        uid = next_uid(&i, bub, &c_bid, &c_uid);
        if(uid == (uint32_t)-1) break;
		if(lock[uid] == 0)
		{
			val = 1;
			break;
		}
        if(c_bid == res->l_bid && c_uid == res->l_uid) break;
    }

	if(val == 0)
	{
		fprintf(stderr, "ERROR-1\n");
		return;
	}

	i.bid = res->f_bid;
	i.uid = res->f_uid;
	while (1)
	{
		uid = next_uid(&i, bub, &c_bid, &c_uid);
        if(uid == (uint32_t)-1) break;
        if(vis->a[uid] == 1) continue;
        lock[uid] = 1;
        vis->a[uid] = 1;
		mc_set_spin(ma, b_aux, uid, -b_aux->s[uid]);
        if(c_bid == res->l_bid && c_uid == res->l_uid) break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl $0x0, -0x38(%rbp)
movq 0x10(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x58(%rbp)
movq 0x10(%rbp), %rax
movl 0x4(%rax), %eax
movq %rax, -0x50(%rbp)
movq 0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rdx
xorl %esi, %esi
callq 0x2100
movq -0x8(%rbp), %rsi
leaq -0x58(%rbp), %rdi
leaq -0x3c(%rbp), %rdx
leaq -0x40(%rbp), %rcx
callq 0x22d230
movl %eax, -0x34(%rbp)
cmpl $-0x1, -0x34(%rbp)
jne 0x21dd71
jmp 0x21dda6
movq -0x28(%rbp), %rax
movl -0x34(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x21dd8a
movl $0x1, -0x38(%rbp)
jmp 0x21dda6
movl -0x3c(%rbp), %eax
movq 0x10(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jne 0x21dda4
movl -0x40(%rbp), %eax
movq 0x10(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jne 0x21dda4
jmp 0x21dda6
jmp 0x21dd51
cmpl $0x0, -0x38(%rbp)
jne 0x21ddc9
movq 0x1a622d(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x16ac95(%rip), %rsi    # 0x388a52
movb $0x0, %al
callq 0x22a0
jmp 0x21de74
movq 0x10(%rbp), %rax
movl 0x4(%rax), %eax
movq %rax, -0x50(%rbp)
movq 0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rsi
leaq -0x58(%rbp), %rdi
leaq -0x3c(%rbp), %rdx
leaq -0x40(%rbp), %rcx
callq 0x22d230
movl %eax, -0x34(%rbp)
cmpl $-0x1, -0x34(%rbp)
jne 0x21ddff
jmp 0x21de74
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x1, %eax
jne 0x21de15
jmp 0x21dddf
movq -0x28(%rbp), %rax
movl -0x34(%rbp), %ecx
movb $0x1, (%rax,%rcx)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
movb $0x1, (%rax,%rcx)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x34(%rbp), %edx
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rax
movl -0x34(%rbp), %ecx
movsbl (%rax,%rcx), %ecx
xorl %eax, %eax
subl %ecx, %eax
movsbl %al, %ecx
callq 0x21d470
movl -0x3c(%rbp), %eax
movq 0x10(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jne 0x21de6f
movl -0x40(%rbp), %eax
movq 0x10(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jne 0x21de6f
jmp 0x21de74
jmp 0x21dddf
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)