// File: /workspace/github_cpp_makefile_star2_O1/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, %r13
movq 0x80(%rsp), %rax
movl (%rax), %r15d
movl 0x4(%rax), %r14d
movl 0x8(%rax), %ebx
movq (%r9), %rdx
movq %r9, 0x20(%rsp)
movq 0x10(%r9), %rdi
xorl %esi, %esi
callq 0x20e0
leaq (%r15,%r15,4), %rdx
leaq 0x14(%rsp), %rbp
movq %rdx, 0x18(%rsp)
movq 0xc0(%r13), %rax
movq 0x10(%rax), %rax
movl 0x10(%rax,%rdx,8), %ecx
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpq %rcx, %r14
jae 0x1643fb
movl %esi, 0xc(%rsp)
leaq (%rax,%rdx,8), %r12
movq 0x18(%r12), %rax
movq (%rax,%r14,8), %rsi
shrq $0x21, %rsi
movq $0x0, (%rsp)
movq %r13, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
leaq 0x28(%rsp), %r8
movq %rbp, %r9
callq 0x13812e
movl 0x14(%rsp), %eax
cmpq %rax, %rbx
jb 0x1643e0
incq %r14
movl 0x10(%r12), %eax
movl $0x0, %ebx
cmpq %rax, %r14
jb 0x16438f
xorl %ebx, %ebx
movq 0x18(%rsp), %rdx
movl 0xc(%rsp), %esi
jmp 0x1643fb
movq 0x28(%rsp), %rax
movl (%rax,%rbx,4), %r15d
shrl %r15d
movl %ebx, 0x10(%rsp)
incq %rbx
movl %r14d, %esi
movq 0x18(%rsp), %rdx
cmpl $-0x1, %r15d
je 0x16442d
movl %r15d, %eax
movq 0x30(%rsp), %rcx
cmpb $0x0, (%rcx,%rax)
je 0x164437
movq 0x80(%rsp), %rax
cmpl 0xc(%rax), %esi
jne 0x16436d
movl 0x10(%rsp), %ecx
cmpl 0x10(%rax), %ecx
jne 0x16436d
callq 0x1ff4e
jmp 0x164548
movl %esi, 0xc(%rsp)
movq 0x80(%rsp), %rax
movl 0x4(%rax), %r14d
movl 0x8(%rax), %ebx
leaq 0x14(%rsp), %r12
movq 0x20(%rsp), %rbp
movq 0xc0(%r13), %rax
movq 0x10(%rax), %rax
movl 0x10(%rax,%rdx,8), %ecx
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpq %rcx, %r14
jae 0x1644d9
leaq (%rax,%rdx,8), %rbp
movq 0x18(%rbp), %rax
movq (%rax,%r14,8), %rsi
shrq $0x21, %rsi
movq $0x0, (%rsp)
movq %r13, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
leaq 0x28(%rsp), %r8
movq %r12, %r9
callq 0x13812e
movl 0x14(%rsp), %eax
cmpq %rax, %rbx
jb 0x1644b7
incq %r14
movl 0x10(%rbp), %eax
movl $0x0, %ebx
cmpq %rax, %r14
jb 0x164472
xorl %ebx, %ebx
jmp 0x1644cf
movq 0x28(%rsp), %rax
movl (%rax,%rbx,4), %r15d
shrl %r15d
movl %ebx, 0x10(%rsp)
incq %rbx
movl %r14d, 0xc(%rsp)
movq 0x20(%rsp), %rbp
movq 0x18(%rsp), %rdx
cmpl $-0x1, %r15d
je 0x164548
movq 0x10(%rbp), %rcx
movl %r15d, %eax
cmpb $0x1, (%rcx,%rax)
je 0x164454
movq 0x30(%rsp), %rcx
movb $0x1, %dl
movb %dl, (%rcx,%rax)
movq 0x10(%rbp), %rcx
movb %dl, (%rcx,%rax)
movq 0x40(%rsp), %rsi
movq 0x50(%rsi), %rcx
movb (%rcx,%rax), %al
xorl %ecx, %ecx
subb %al, %cl
movsbl %cl, %ecx
movq 0x38(%rsp), %rdi
movl %r15d, %edx
callq 0x163d25
movq 0x18(%rsp), %rdx
movq 0x80(%rsp), %rax
movl 0xc(%rsp), %ecx
cmpl 0xc(%rax), %ecx
jne 0x164454
movl 0x10(%rsp), %ecx
cmpl 0x10(%rax), %ecx
jne 0x164454
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq