// File: /workspace/github_c_makefile_star2_O3/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, %eax
movl %edx, %ebx
movslq (%rdi), %rdx
cmpq $0x20, %rdx
jg 0x149d0
leal (%rdx,%rdx), %r8d
subl 0x10(%rdi), %r8d
movq (%rsi), %r9
movl %edx, %ecx
shlq %cl, %r9
movq $-0x1, %r15
movl %r8d, %ecx
shlq %cl, %r15
orq 0x8(%rsi), %r9
notq %r15
andq %r9, %r15
jmp 0x14a0c
movl %edx, %r8d
subl 0x10(%rdi), %r8d
leal (%r8,%rdx), %r10d
movb $0x32, %r11b
movq $-0x1, %r15
movl %r8d, %ecx
shlq %cl, %r15
subb %r8b, %r11b
movq (%rsi), %r9
notq %r15
andq %r9, %r15
cmpl $0x32, %r10d
movzbl %r11b, %ecx
cmovll %edx, %ecx
shlq %cl, %r15
xorq 0x8(%rsi), %r15
movl %r8d, %ecx
shrq %cl, %r9
shlq $0x3, %r9
addq 0x8(%rdi), %r9
movq (%r9), %r14
movl $0x1, %ecx
xchgl %ecx, 0xc(%r14)
testl %ecx, %ecx
je 0x14a41
testl %eax, %eax
je 0x14a63
movl $0x1, %eax
xchgl %eax, 0xc(%r14)
testl %eax, %eax
je 0x14a41
cmpl $0x0, 0xc(%r14)
jne 0x14a38
jmp 0x14a2b
movl (%r14), %esi
movl %esi, %eax
shrl $0x2, %eax
movl %esi, %ecx
shrl %ecx
addl %eax, %ecx
cmpl %ecx, 0x8(%r14)
jb 0x14a84
movl 0x4(%r14), %eax
addl %eax, %eax
cmpl %eax, %esi
jbe 0x14a6d
decl %esi
jmp 0x14a6f
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x14c17
incl %esi
movq %r14, %rdi
callq 0x14f4a
movl (%r14), %esi
movl %esi, %edi
testl %eax, %eax
js 0x14bfb
movq %r15, %rdx
shlq $0xe, %rdx
leal -0x1(%rsi), %r9d
movl %r15d, %r8d
andl %r9d, %r8d
movq 0x10(%r14), %rax
movl %r8d, %ecx
shrl $0x4, %ecx
movl (%rax,%rcx,4), %edi
leal (%r8,%r8), %ecx
shrl %cl, %edi
testb $0x2, %dil
je 0x14ab6
movl %r8d, %edi
jmp 0x14b43
movabsq $0x3ffffffffffff, %rcx  # imm = 0x3FFFFFFFFFFFF
andq %rcx, %r15
movl $0x1, %r11d
movl %r8d, %r10d
movl %esi, %edi
movl %r10d, %ecx
shrl $0x4, %ecx
movl (%rax,%rcx,4), %ebp
leal (%r10,%r10), %ecx
andl $0x1e, %ecx
movl %ebp, %r12d
shrl %cl, %r12d
testb $0x2, %r12b
jne 0x14b24
testb $0x1, %r12b
jne 0x14b04
movq 0x18(%r14), %r12
movl %r10d, %r13d
movq (%r12,%r13,8), %r12
shrq $0xe, %r12
cmpq %r15, %r12
je 0x14b24
btl %ecx, %ebp
cmovbl %r10d, %edi
addl %r11d, %r10d
andl %r9d, %r10d
incl %r11d
cmpl %r8d, %r10d
jne 0x14ace
movb $0x1, %cl
movl %esi, %r9d
cmpl %esi, %edi
je 0x14b33
jmp 0x14b43
shrl %cl, %ebp
testb $0x2, %bpl
sete %cl
movl %edi, %r9d
movl %r10d, %r8d
cmpl %esi, %r9d
cmovel %r8d, %r9d
testb %cl, %cl
cmovnel %r8d, %r9d
movl %r9d, %edi
incq %rdx
movl %edi, %esi
shrl $0x4, %esi
movl (%rax,%rsi,4), %r8d
leal (%rdi,%rdi), %ecx
andl $0x1e, %ecx
movl %r8d, %r11d
shrl %cl, %r11d
testb $0x2, %r11b
jne 0x14bac
movq 0x18(%r14), %r9
movl %edi, %r10d
testb $0x1, %r11b
jne 0x14be0
movq (%r9,%r10,8), %rax
xorl %edx, %edx
cmpb $-0x1, %al
setne %dl
addq %rdx, %rax
testl %ebx, %ebx
setne %sil
movl %eax, %ecx
notl %ecx
testl $0x3f00, %ecx           # imm = 0x3F00
setne %cl
andb %sil, %cl
orb %cl, %dl
cmpb $0x1, %dl
jne 0x14c0d
leaq 0x100(%rax), %rdx
testb %cl, %cl
cmoveq %rax, %rdx
movq %rdx, (%r9,%r10,8)
jmp 0x14c0d
movq 0x18(%r14), %r9
movl %edi, %r10d
movl $0x3, %r11d
shll %cl, %r11d
movq %rdx, (%r9,%r10,8)
notl %r11d
andl %r11d, %r8d
movl %r8d, (%rax,%rsi,4)
movq 0x4(%r14), %xmm0
pcmpeqd %xmm1, %xmm1
psubd %xmm1, %xmm0
movq %xmm0, 0x4(%r14)
jmp 0x14bfb
movl $0x3, %r11d
shll %cl, %r11d
movq %rdx, (%r9,%r10,8)
notl %r11d
andl %r11d, %r8d
movl %r8d, (%rax,%rsi,4)
incl 0x4(%r14)
testl %ebx, %ebx
je 0x14c0d
movq 0x18(%r14), %rax
movl %edi, %ecx
orq $0x100, (%rax,%rcx,8)   # imm = 0x100
movl $0x0, 0xc(%r14)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq