// File: /workspace/github_c_makefile_star2_O3/LemonBoy[P]autobahn/xdiff/xpatience.c
// Function: insert_record
static void insert_record(int line, struct hashmap *map, int pass)
{
	xrecord_t **records = pass == 1 ?
		map->env->xdf1.recs : map->env->xdf2.recs;
	xrecord_t *record = records[line - 1], *other;
	/*
	 * After xdl_prepare_env() (or more precisely, due to
	 * xdl_classify_record()), the "ha" member of the records (AKA lines)
	 * is _not_ the hash anymore, but a linearized version of it.  In
	 * other words, the "ha" member is guaranteed to start with 0 and
	 * the second record's ha can only be 0 or 1, etc.
	 *
	 * So we multiply ha by 2 in the hope that the hashing was
	 * "unique enough".
	 */
	int index = (int)((record->ha << 1) % map->alloc);

	while (map->entries[index].line1) {
		other = map->env->xdf1.recs[map->entries[index].line1 - 1];
		if (map->entries[index].hash != record->ha ||
				!xdl_recmatch(record->ptr, record->size,
					other->ptr, other->size,
					map->xpp->flags)) {
			if (++index >= map->alloc)
				index = 0;
			continue;
		}
		if (pass == 2)
			map->has_matches = 1;
		if (pass == 1 || map->entries[index].line2)
			map->entries[index].line2 = NON_UNIQUE;
		else
			map->entries[index].line2 = line;
		return;
	}
	if (pass == 2)
		return;
	map->entries[index].line1 = line;
	map->entries[index].hash = record->ha;
	if (!map->first)
		map->first = map->entries + index;
	if (map->last) {
		map->last->next = map->entries + index;
		map->entries[index].previous = map->last;
	}
	map->last = map->entries + index;
	map->nr++;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %rbx
cmpl $0x1, %edx
movq 0x8(%rsi), %rcx
movq 0x38(%rsi), %rax
movl $0x60, %edx
movl $0xe8, %esi
cmoveq %rdx, %rsi
movq (%rax,%rsi), %rax
movslq %edi, %rdx
movq %rdx, (%rsp)
movq -0x8(%rax,%rdx,8), %r13
movq 0x18(%r13), %rax
addq %rax, %rax
movslq 0x4(%rbx), %rsi
xorl %r15d, %r15d
xorl %edx, %edx
divq %rsi
movq %rdx, %r14
movslq %r14d, %r12
leaq (%r12,%r12,4), %rax
leaq (%rcx,%rax,8), %rax
movq 0x8(%rax), %rdx
testq %rdx, %rdx
je 0x2e81
movq (%rax), %rax
cmpq 0x18(%r13), %rax
jne 0x2e75
movq 0x38(%rbx), %rax
movq 0x40(%rbx), %r8
movq 0x60(%rax), %rax
movq -0x8(%rax,%rdx,8), %rax
movq 0x8(%r13), %rdi
movq 0x10(%r13), %rsi
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
movq (%r8), %r8
callq 0x4349
testl %eax, %eax
jne 0x2ec2
movl 0x4(%rbx), %esi
movq 0x8(%rbx), %rcx
incl %r14d
cmpl %esi, %r14d
cmovgel %r15d, %r14d
jmp 0x2e24
cmpl $0x2, %ebp
je 0x2f0a
movq (%rsp), %rdx
movq %rdx, 0x8(%rax)
movq 0x18(%r13), %rdx
movq %rdx, (%rax)
cmpq $0x0, 0x10(%rbx)
jne 0x2ea4
movq %rax, 0x10(%rbx)
movq 0x18(%rbx), %rdx
testq %rdx, %rdx
je 0x2eba
movq %rax, 0x18(%rdx)
leaq (%r12,%r12,4), %rsi
movq %rdx, 0x20(%rcx,%rsi,8)
movq %rax, 0x18(%rbx)
incl (%rbx)
jmp 0x2f0a
cmpl $0x2, %ebp
jne 0x2ed1
movq $0x1, 0x20(%rbx)
jmp 0x2edc
cmpl $0x1, %ebp
jne 0x2edc
movq 0x8(%rbx), %rax
jmp 0x2eec
movq 0x8(%rbx), %rax
leaq (%r12,%r12,4), %rcx
cmpq $0x0, 0x10(%rax,%rcx,8)
je 0x2efb
leaq (%r12,%r12,4), %rcx
movq $-0x1, 0x10(%rax,%rcx,8)
jmp 0x2f0a
leaq (%rax,%rcx,8), %rax
addq $0x10, %rax
movq (%rsp), %rcx
movq %rcx, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)