// File: /workspace/github_c_makefile_star2_O1/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 0x142ba
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 0x142f6
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 0x1432b
testl %eax, %eax
je 0x1434d
movl $0x1, %eax
xchgl %eax, 0xc(%r14)
testl %eax, %eax
je 0x1432b
cmpl $0x0, 0xc(%r14)
jne 0x14322
jmp 0x14315
movl (%r14), %esi
movl %esi, %eax
shrl $0x2, %eax
movl %esi, %ecx
shrl %ecx
addl %eax, %ecx
cmpl %ecx, 0x8(%r14)
jb 0x14369
movl 0x4(%r14), %eax
addl %eax, %eax
cmpl %eax, %esi
jbe 0x14357
decl %esi
jmp 0x14359
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x144fd
incl %esi
movq %r14, %rdi
callq 0x1483f
testl %eax, %eax
js 0x14403
movq %r15, %rsi
shlq $0xe, %rsi
movl (%r14), %edi
leal -0x1(%rdi), %r10d
movl %r15d, %eax
andl %r10d, %eax
movq 0x10(%r14), %rdx
movl %eax, %ecx
shrl $0x4, %ecx
movl (%rdx,%rcx,4), %r8d
leal (%rax,%rax), %ecx
shrl %cl, %r8d
testb $0x2, %r8b
jne 0x14432
movabsq $0x3ffffffffffff, %rcx  # imm = 0x3FFFFFFFFFFFF
andq %rcx, %r15
movl $0x1, %r11d
movl %eax, %r9d
movl %edi, %r8d
movl %r9d, %ecx
shrl $0x4, %ecx
movl (%rdx,%rcx,4), %ebp
leal (%r9,%r9), %ecx
andl $0x1e, %ecx
movl %ebp, %r12d
shrl %cl, %r12d
testb $0x2, %r12b
jne 0x1440b
testb $0x1, %r12b
jne 0x143e9
movq 0x18(%r14), %r12
movl %r9d, %r13d
movq (%r12,%r13,8), %r12
shrq $0xe, %r12
cmpq %r15, %r12
je 0x1440b
btl %ecx, %ebp
cmovbl %r9d, %r8d
addl %r11d, %r9d
andl %r10d, %r9d
incl %r11d
movl %r8d, %ecx
cmpl %eax, %r9d
jne 0x143b3
jmp 0x1440d
movl (%r14), %eax
jmp 0x144a2
movl %edi, %ecx
movl %ecx, %eax
cmpl %edi, %ecx
jne 0x14432
movl %r9d, %eax
shrl $0x4, %eax
movl (%rdx,%rax,4), %eax
leal (%r9,%r9), %ecx
shrl %cl, %eax
cmpl %edi, %r8d
cmovel %r9d, %r8d
testb $0x2, %al
cmovel %r9d, %r8d
movl %r8d, %eax
incq %rsi
movl %eax, %edi
shrl $0x4, %edi
movl (%rdx,%rdi,4), %r8d
leal (%rax,%rax), %ecx
andl $0x1e, %ecx
movl %r8d, %r10d
shrl %cl, %r10d
testb $0x2, %r10b
jne 0x1447d
movb $0x1, %r9b
testb $0x1, %r10b
je 0x144a5
movq 0x18(%r14), %r9
movl %eax, %r10d
movl $0x3, %r11d
shll %cl, %r11d
movq %rsi, (%r9,%r10,8)
notl %r11d
andl %r11d, %r8d
movl %r8d, (%rdx,%rdi,4)
incl 0x4(%r14)
jmp 0x144a2
movq 0x18(%r14), %r9
movl $0x3, %r10d
shll %cl, %r10d
movl %eax, %ecx
movq %rsi, (%r9,%rcx,8)
notl %r10d
andl %r10d, %r8d
movl %r8d, (%rdx,%rdi,4)
incl 0x4(%r14)
incl 0x8(%r14)
xorl %r9d, %r9d
testb %r9b, %r9b
je 0x144e1
movq 0x18(%r14), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rdx
cmpb $-0x1, %dl
je 0x144c0
incq %rdx
movq %rdx, (%rcx,%rax,8)
testl %ebx, %ebx
je 0x144f3
movq (%rcx,%rax,8), %rdx
movl %edx, %esi
notl %esi
testl $0x3f00, %esi           # imm = 0x3F00
je 0x144f3
addq $0x100, %rdx            # imm = 0x100
movq %rdx, (%rcx,%rax,8)
jmp 0x144f3
testl %ebx, %ebx
je 0x144f3
movq 0x18(%r14), %rcx
movl %eax, %eax
orq $0x100, (%rcx,%rax,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