// File: /workspace/github_c_makefile_star2_O0/LemonBoy[P]autobahn/xdiff/xhistogram.c
// Function: scanA
static int scanA(struct histindex *index, int line1, int count1)
{
	unsigned int ptr, tbl_idx;
	unsigned int chain_len;
	struct record **rec_chain, *rec;

	for (ptr = LINE_END(1); line1 <= ptr; ptr--) {
		tbl_idx = TABLE_HASH(index, 1, ptr);
		rec_chain = index->records + tbl_idx;
		rec = *rec_chain;

		chain_len = 0;
		while (rec) {
			if (CMP(index, 1, rec->ptr, 1, ptr)) {
				/*
				 * ptr is identical to another element. Insert
				 * it onto the front of the existing element
				 * chain.
				 */
				NEXT_PTR(index, ptr) = rec->ptr;
				rec->ptr = ptr;
				/* cap rec->cnt at MAX_CNT */
				rec->cnt = XDL_MIN(MAX_CNT, rec->cnt + 1);
				LINE_MAP(index, ptr) = rec;
				goto continue_scan;
			}

			rec = rec->next;
			chain_len++;
		}

		if (chain_len == index->max_chain_length)
			return -1;

		/*
		 * This is the first time we have ever seen this particular
		 * element in the sequence. Construct a new chain for it.
		 */
		if (!(rec = xdl_cha_alloc(&index->rcha)))
			return -1;
		rec->ptr = ptr;
		rec->cnt = 1;
		rec->next = *rec_chain;
		*rec_chain = rec;
		LINE_MAP(index, ptr) = rec;

continue_scan:
		; /* no op */
	}

	return 0;
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movl %esi, 0x34(%rsp)
movl %edx, 0x30(%rsp)
movl 0x34(%rsp), %eax
addl 0x30(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x2c(%rsp)
movl 0x34(%rsp), %eax
cmpl 0x2c(%rsp), %eax
ja 0xb2ce
movq 0x38(%rsp), %rax
movq 0x70(%rax), %rax
movq 0x60(%rax), %rax
movl 0x2c(%rsp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
movq 0x18(%rax), %rax
movq 0x38(%rsp), %rcx
movq 0x70(%rcx), %rcx
movq 0x60(%rcx), %rcx
movl 0x2c(%rsp), %edx
subl $0x1, %edx
movl %edx, %edx
movq (%rcx,%rdx,8), %rcx
movq 0x18(%rcx), %rdx
movq 0x38(%rsp), %rcx
movl 0x50(%rcx), %ecx
shrq %cl, %rdx
movq %rdx, %rcx
addq %rcx, %rax
movq 0x38(%rsp), %rcx
movl 0x50(%rcx), %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
subq $0x1, %rcx
andq %rcx, %rax
movl %eax, 0x28(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rax
movl 0x28(%rsp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x10(%rsp)
movl $0x0, 0x24(%rsp)
cmpq $0x0, 0x10(%rsp)
je 0xb229
movq 0x38(%rsp), %rax
movq 0x78(%rax), %rdi
movq 0x38(%rsp), %rax
movq 0x70(%rax), %rax
movq 0x60(%rax), %rax
movq 0x10(%rsp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rsi
movq 0x38(%rsp), %rax
movq 0x70(%rax), %rax
movq 0x60(%rax), %rax
movl 0x2c(%rsp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
callq 0xb7e0
cmpl $0x0, %eax
je 0xb20b
movq 0x10(%rsp), %rax
movl (%rax), %edx
movq 0x38(%rsp), %rax
movq 0x48(%rax), %rax
movl 0x2c(%rsp), %ecx
movq 0x38(%rsp), %rsi
subl 0x64(%rsi), %ecx
movl %ecx, %ecx
movl %edx, (%rax,%rcx,4)
movl 0x2c(%rsp), %ecx
movq 0x10(%rsp), %rax
movl %ecx, (%rax)
movq 0x10(%rsp), %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jae 0xb1cb
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0xc(%rsp)
jmp 0xb1da
movq 0x10(%rsp), %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %ecx
movq 0x10(%rsp), %rax
movl %ecx, 0x4(%rax)
movq 0x10(%rsp), %rdx
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
movl 0x2c(%rsp), %ecx
movq 0x38(%rsp), %rsi
subl 0x64(%rsi), %ecx
movl %ecx, %ecx
movq %rdx, (%rax,%rcx,8)
jmp 0xb2bc
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0xb126
movl 0x24(%rsp), %eax
movq 0x38(%rsp), %rcx
cmpl 0x5c(%rcx), %eax
jne 0xb244
movl $0xffffffff, 0x44(%rsp) # imm = 0xFFFFFFFF
jmp 0xb2d6
movq 0x38(%rsp), %rdi
addq $0x10, %rdi
callq 0x6e80
movq %rax, 0x10(%rsp)
cmpq $0x0, %rax
jne 0xb267
movl $0xffffffff, 0x44(%rsp) # imm = 0xFFFFFFFF
jmp 0xb2d6
movl 0x2c(%rsp), %ecx
movq 0x10(%rsp), %rax
movl %ecx, (%rax)
movq 0x10(%rsp), %rax
movl $0x1, 0x4(%rax)
movq 0x18(%rsp), %rax
movq (%rax), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rcx, (%rax)
movq 0x10(%rsp), %rdx
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
movl 0x2c(%rsp), %ecx
movq 0x38(%rsp), %rsi
subl 0x64(%rsi), %ecx
movl %ecx, %ecx
movq %rdx, (%rax,%rcx,8)
jmp 0xb2be
movl 0x2c(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0xb080
movl $0x0, 0x44(%rsp)
movl 0x44(%rsp), %eax
addq $0x48, %rsp
retq
nop