// File: /workspace/github_c_makefile_star2_O2/lh3[P]fermi-lite/htab.c
// Function: bfc_ch_insert
int bfc_ch_insert(bfc_ch_t *ch, const uint64_t x[2], int is_high, int forced)
{
	int absent;
	uint64_t key;
	cnthash_t *h;
	khint_t k;
	h = get_subhash(ch, x, &key);
	if (__sync_lock_test_and_set(&h->lock, 1)) {
		if (forced) // then wait until the hash table is unlocked by the thread using it
			while (__sync_lock_test_and_set(&h->lock, 1))
				while (h->lock); // lock
		else return -1;
	}
	k = kh_put(cnt, h, key, &absent);
	if (absent) {
		if (is_high) kh_key(h, k) |= 1<<8;
	} else {
		if ((kh_key(h, k) & 0xff) != 0xff) ++kh_key(h, k);
		if (is_high && (kh_key(h, k) >> 8 & 0x3f) != 0x3f) kh_key(h, k) += 1<<8;
	}
	__sync_lock_release(&h->lock); // unlock
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %r14d
movl %edx, %ebp
movq %rsp, %rdx
callq 0x12064
movq %rax, %rbx
pushq $0x1
popq %r15
movl %r15d, %eax
xchgl %eax, 0xc(%rbx)
testl %eax, %eax
je 0x11ea7
testl %r14d, %r14d
je 0x11eca
movl %r15d, %eax
xchgl %eax, 0xc(%rbx)
testl %eax, %eax
je 0x11ea7
cmpl $0x0, 0xc(%rbx)
jne 0x11e9f
jmp 0x11e95
movq (%rsp), %r14
movl (%rbx), %esi
movl %esi, %eax
shrl $0x2, %eax
movl %esi, %ecx
shrl %ecx
addl %eax, %ecx
cmpl %ecx, 0x8(%rbx)
jb 0x11ee8
movl 0x4(%rbx), %eax
addl %eax, %eax
cmpl %eax, %esi
jbe 0x11ed2
decl %esi
jmp 0x11ed4
pushq $-0x1
popq %rax
jmp 0x12055
incl %esi
movq %rbx, %rdi
callq 0x12322
movl (%rbx), %esi
movl %esi, %edx
testl %eax, %eax
js 0x1203a
leal -0x1(%rsi), %r8d
movq %r14, %r9
shrq $0xe, %r9
movl %r9d, %edi
andl %r8d, %edi
movq 0x10(%rbx), %rax
movl %edi, %ecx
shrl $0x4, %ecx
movl (%rax,%rcx,4), %edx
leal (%rdi,%rdi), %ecx
shrl %cl, %edx
testb $0x2, %dl
je 0x11f13
movl %edi, %edx
jmp 0x11f90
movl %edi, %r10d
movl %esi, %edx
movl %r10d, %ecx
shrl $0x4, %ecx
movl (%rax,%rcx,4), %r11d
leal (%r10,%r10), %ecx
andl $0x1e, %ecx
movl %r11d, %r12d
shrl %cl, %r12d
testb $0x2, %r12b
jne 0x11f70
testb $0x1, %r12b
jne 0x11f4f
movq 0x18(%rbx), %r12
movl %r10d, %r13d
movq (%r12,%r13,8), %r12
shrq $0xe, %r12
cmpq %r9, %r12
je 0x11f70
btl %ecx, %r11d
cmovbl %r10d, %edx
addl %r15d, %r10d
andl %r8d, %r10d
incl %r15d
cmpl %edi, %r10d
jne 0x11f18
movb $0x1, %cl
movl %esi, %r8d
cmpl %esi, %edx
je 0x11f80
jmp 0x11f90
shrl %cl, %r11d
testb $0x2, %r11b
sete %cl
movl %edx, %r8d
movl %r10d, %edi
cmpl %esi, %r8d
cmovel %edi, %r8d
testb %cl, %cl
cmovnel %edi, %r8d
movl %r8d, %edx
movl %edx, %esi
shrl $0x4, %esi
movl (%rax,%rsi,4), %edi
leal (%rdx,%rdx), %ecx
andl $0x1e, %ecx
movl %edi, %r10d
shrl %cl, %r10d
testb $0x2, %r10b
jne 0x11ff4
movq 0x18(%rbx), %r8
movl %edx, %r9d
testb $0x1, %r10b
jne 0x12023
movq (%r8,%r9,8), %rax
xorl %edx, %edx
cmpb $-0x1, %al
setne %dl
addq %rdx, %rax
testl %ebp, %ebp
setne %sil
movl %eax, %ecx
notl %ecx
testw $0x3f00, %cx            # imm = 0x3F00
setne %cl
andb %sil, %cl
orb %cl, %dl
cmpb $0x1, %dl
jne 0x1204c
leaq 0x100(%rax), %rdx
testb %cl, %cl
cmoveq %rax, %rdx
movq %rdx, (%r8,%r9,8)
jmp 0x1204c
movq 0x18(%rbx), %r8
movl %edx, %r9d
pushq $0x3
popq %r10
shll %cl, %r10d
movq %r14, (%r8,%r9,8)
notl %r10d
andl %r10d, %edi
movl %edi, (%rax,%rsi,4)
movq 0x4(%rbx), %xmm0
pcmpeqd %xmm1, %xmm1
psubd %xmm1, %xmm0
movq %xmm0, 0x4(%rbx)
jmp 0x1203a
pushq $0x3
popq %r10
shll %cl, %r10d
movq %r14, (%r8,%r9,8)
notl %r10d
andl %r10d, %edi
movl %edi, (%rax,%rsi,4)
incl 0x4(%rbx)
testl %ebp, %ebp
je 0x1204c
movq 0x18(%rbx), %rax
movl %edx, %ecx
orq $0x100, (%rax,%rcx,8)   # imm = 0x100
movl $0x0, 0xc(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq