// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, 0x30(%rsp)
movq %rdx, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdi, %r12
movq 0x80(%rsp), %rax
movl (%rax), %ebx
movl 0x4(%rax), %r15d
movl 0x8(%rax), %r14d
movq (%r9), %rdx
movq %r9, 0x28(%rsp)
movq 0x10(%r9), %rdi
xorl %esi, %esi
callq 0x20e0
movq %r12, 0x18(%rsp)
movq 0xc0(%r12), %rax
movq 0x10(%rax), %rax
leaq (%rbx,%rbx,4), %rcx
movq %rcx, 0x8(%rsp)
cmpl 0x10(%rax,%rcx,8), %r15d
jae 0x16adc1
movq 0x8(%rsp), %rcx
leaq (%rax,%rcx,8), %rbx
addq $0x10, %rbx
leaq 0x20(%rsp), %r12
leaq 0x14(%rsp), %rbp
movq 0x8(%rsp), %rcx
leaq (%rax,%rcx,8), %r13
addq $0x18, %r13
movq (%r13), %rax
movq (%rax,%r15,8), %rsi
shrq $0x21, %rsi
movq $0x0, (%rsp)
movq 0x18(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r12, %r8
movq %rbp, %r9
callq 0x13df01
movl 0x14(%rsp), %eax
cmpq %rax, %r14
jb 0x16ad6c
incq %r15
movl (%rbx), %eax
movl $0x0, %r14d
cmpq %rax, %r15
jb 0x16ad29
jmp 0x16adc1
movq 0x20(%rsp), %rax
movl (%rax,%r14,4), %eax
shrl %eax
movq 0x30(%rsp), %rcx
cmpb $0x0, (%rcx,%rax)
je 0x16add5
movq 0x80(%rsp), %rax
cmpl %r15d, 0xc(%rax)
jne 0x16ad96
cmpl %r14d, 0x10(%rax)
je 0x16adc1
incq %r14
movq 0x18(%rsp), %rax
movq 0xc0(%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rsp), %rcx
leaq (%rax,%rcx,8), %rbx
addq $0x10, %rbx
movl (%rbx), %ecx
cmpq %rcx, %r15
jb 0x16ad1c
callq 0x1f2b2
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x80(%rsp), %r13
movl 0x4(%r13), %ebp
movq 0x18(%rsp), %rax
movq 0xc0(%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rsp), %rcx
cmpl 0x10(%rax,%rcx,8), %ebp
jae 0x16adc6
movl 0x8(%r13), %r15d
movq 0x8(%rsp), %rcx
leaq (%rax,%rcx,8), %r14
addq $0x10, %r14
leaq 0x14(%rsp), %r12
movq 0x8(%rsp), %rcx
leaq (%rax,%rcx,8), %rbx
addq $0x18, %rbx
movq (%rbx), %rax
movq (%rax,%rbp,8), %rsi
shrq $0x21, %rsi
movq $0x0, (%rsp)
movq 0x18(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
leaq 0x20(%rsp), %r8
movq %r12, %r9
callq 0x13df01
movl 0x14(%rsp), %eax
cmpq %rax, %r15
jb 0x16ae67
incq %rbp
movl (%r14), %eax
movl $0x0, %r15d
cmpq %rax, %rbp
jb 0x16ae1f
jmp 0x16adc6
movq 0x20(%rsp), %rax
movl (%rax,%r15,4), %edx
shrl %edx
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rax
cmpb $0x1, (%rax,%rdx)
je 0x16aec4
movq 0x30(%rsp), %rax
movb $0x1, %cl
movb %cl, (%rax,%rdx)
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rax
movb %cl, (%rax,%rdx)
movq 0x40(%rsp), %rsi
movq 0x50(%rsi), %rax
movb (%rax,%rdx), %al
xorl %ecx, %ecx
subb %al, %cl
movsbl %cl, %ecx
movq 0x38(%rsp), %rdi
callq 0x16a6bf
cmpl %ebp, 0xc(%r13)
jne 0x16aec4
cmpl %r15d, 0x10(%r13)
je 0x16adc6
incq %r15
movq 0x18(%rsp), %rax
movq 0xc0(%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rsp), %rcx
leaq (%rax,%rcx,8), %r14
addq $0x10, %r14
movl (%r14), %ecx
cmpq %rcx, %rbp
jb 0x16ae12
jmp 0x16adc6