// File: /workspace/github_c_makefile_star2_O0/LemonBoy[P]autobahn/xdiff/xemit.c
// Function: xdl_emit_diff
int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
		  xdemitconf_t const *xecfg) {
	long s1, s2, e1, e2, lctx;
	xdchange_t *xch, *xche;
	long funclineprev = -1;
	struct func_line func_line = { 0 };

	for (xch = xscr; xch; xch = xche->next) {
		xche = xdl_get_hunk(&xch, xecfg);
		if (!xch)
			break;

		s1 = XDL_MAX(xch->i1 - xecfg->ctxlen, 0);
		s2 = XDL_MAX(xch->i2 - xecfg->ctxlen, 0);

		if (xecfg->flags & XDL_EMIT_FUNCCONTEXT) {
			long fs1, i1 = xch->i1;

			/* Appended chunk? */
			if (i1 >= xe->xdf1.nrec) {
				char dummy[1];
				long i2 = xch->i2;

				/*
				 * We don't need additional context if
				 * a whole function was added, possibly
				 * starting with empty lines.
				 */
				while (i2 < xe->xdf2.nrec &&
				       is_empty_rec(&xe->xdf2, i2))
					i2++;
				if (i2 < xe->xdf2.nrec &&
				    match_func_rec(&xe->xdf2, xecfg, i2,
						   dummy, sizeof(dummy)) >= 0)
					goto post_context_calculation;

				/*
				 * Otherwise get more context from the
				 * pre-image.
				 */
				i1 = xe->xdf1.nrec - 1;
			}

			fs1 = get_func_line(xe, xecfg, NULL, i1, -1);
			if (fs1 < 0)
				fs1 = 0;
			if (fs1 < s1) {
				s2 -= s1 - fs1;
				s1 = fs1;
			}
		}

 post_context_calculation:
		lctx = xecfg->ctxlen;
		lctx = XDL_MIN(lctx, xe->xdf1.nrec - (xche->i1 + xche->chg1));
		lctx = XDL_MIN(lctx, xe->xdf2.nrec - (xche->i2 + xche->chg2));

		e1 = xche->i1 + xche->chg1 + lctx;
		e2 = xche->i2 + xche->chg2 + lctx;

		if (xecfg->flags & XDL_EMIT_FUNCCONTEXT) {
			long fe1 = get_func_line(xe, xecfg, NULL,
						 xche->i1 + xche->chg1,
						 xe->xdf1.nrec);
			while (fe1 > 0 && is_empty_rec(&xe->xdf1, fe1 - 1))
				fe1--;
			if (fe1 < 0)
				fe1 = xe->xdf1.nrec;
			if (fe1 > e1) {
				e2 += fe1 - e1;
				e1 = fe1;
			}

			/*
			 * Overlap with next change?  Then include it
			 * in the current hunk and start over to find
			 * its new end.
			 */
			if (xche->next) {
				long l = XDL_MIN(xche->next->i1,
						 xe->xdf1.nrec - 1);
				if (l - xecfg->ctxlen <= e1 ||
				    get_func_line(xe, xecfg, NULL, l, e1) < 0) {
					xche = xche->next;
					goto post_context_calculation;
				}
			}
		}

		/*
		 * Emit current hunk header.
		 */

		if (xecfg->flags & XDL_EMIT_FUNCNAMES) {
			get_func_line(xe, xecfg, &func_line,
				      s1 - 1, funclineprev);
			funclineprev = s1 - 1;
		}
		if (xdl_emit_hunk_hdr(s1 + 1, e1 - s1, s2 + 1, e2 - s2,
				      func_line.buf, func_line.len, ecb) < 0)
			return -1;

		/*
		 * Emit pre-context.
		 */
		for (; s2 < xch->i2; s2++)
			if (xdl_emit_record(&xe->xdf2, s2, " ", ecb) < 0)
				return -1;

		for (s1 = xch->i1, s2 = xch->i2;; xch = xch->next) {
			/*
			 * Merge previous with current change atom.
			 */
			for (; s1 < xch->i1 && s2 < xch->i2; s1++, s2++)
				if (xdl_emit_record(&xe->xdf2, s2, " ", ecb) < 0)
					return -1;

			/*
			 * Removes lines from the first file.
			 */
			for (s1 = xch->i1; s1 < xch->i1 + xch->chg1; s1++)
				if (xdl_emit_record(&xe->xdf1, s1, "-", ecb) < 0)
					return -1;

			/*
			 * Adds lines from the second file.
			 */
			for (s2 = xch->i2; s2 < xch->i2 + xch->chg2; s2++)
				if (xdl_emit_record(&xe->xdf2, s2, "+", ecb) < 0)
					return -1;

			if (xch == xche)
				break;
			s1 = xch->i1 + xch->chg1;
			s2 = xch->i2 + xch->chg2;
		}

		/*
		 * Emit post-context.
		 */
		for (s2 = xche->i2 + xche->chg2; s2 < e2; s2++)
			if (xdl_emit_record(&xe->xdf2, s2, " ", ecb) < 0)
				return -1;
	}

	return 0;
}

// Assembly:
subq $0x138, %rsp            # imm = 0x138
movq %rdi, 0x128(%rsp)
movq %rsi, 0x120(%rsp)
movq %rdx, 0x118(%rsp)
movq %rcx, 0x110(%rsp)
movq $-0x1, 0xd0(%rsp)
leaq 0x78(%rsp), %rdi
xorl %esi, %esi
movl $0x58, %edx
callq 0x1090
movq 0x120(%rsp), %rax
movq %rax, 0xe0(%rsp)
cmpq $0x0, 0xe0(%rsp)
je 0x52d5
movq 0x110(%rsp), %rsi
leaq 0xe0(%rsp), %rdi
callq 0x4670
movq %rax, 0xd8(%rsp)
cmpq $0x0, 0xe0(%rsp)
jne 0x4950
jmp 0x52d5
movq 0xe0(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x110(%rsp), %rcx
subq (%rcx), %rax
cmpq $0x0, %rax
jle 0x498b
movq 0xe0(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x110(%rsp), %rcx
subq (%rcx), %rax
movq %rax, 0x40(%rsp)
jmp 0x4994
xorl %eax, %eax
movq %rax, 0x40(%rsp)
jmp 0x4994
movq 0x40(%rsp), %rax
movq %rax, 0x108(%rsp)
movq 0xe0(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x110(%rsp), %rcx
subq (%rcx), %rax
cmpq $0x0, %rax
jle 0x49dc
movq 0xe0(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x110(%rsp), %rcx
subq (%rcx), %rax
movq %rax, 0x38(%rsp)
jmp 0x49e5
xorl %eax, %eax
movq %rax, 0x38(%rsp)
jmp 0x49e5
movq 0x38(%rsp), %rax
movq %rax, 0x100(%rsp)
movq 0x110(%rsp), %rax
movq 0x10(%rax), %rax
andq $0x4, %rax
cmpq $0x0, %rax
je 0x4b79
movq 0xe0(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq 0x128(%rsp), %rcx
cmpq 0x38(%rcx), %rax
jl 0x4b00
movq 0xe0(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rcx
movq 0x128(%rsp), %rdx
xorl %eax, %eax
cmpq 0xc0(%rdx), %rcx
movb %al, 0x37(%rsp)
jge 0x4a84
movq 0x128(%rsp), %rdi
addq $0x88, %rdi
movq 0x58(%rsp), %rsi
callq 0x52f0
cmpl $0x0, %eax
setne %al
movb %al, 0x37(%rsp)
movb 0x37(%rsp), %al
testb $0x1, %al
jne 0x4a8e
jmp 0x4a9e
movq 0x58(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x58(%rsp)
jmp 0x4a45
movq 0x58(%rsp), %rax
movq 0x128(%rsp), %rcx
cmpq 0xc0(%rcx), %rax
jge 0x4aeb
movq 0x128(%rsp), %rdi
addq $0x88, %rdi
movq 0x110(%rsp), %rsi
movq 0x58(%rsp), %rdx
leaq 0x67(%rsp), %rcx
movl $0x1, %r8d
callq 0x5390
cmpq $0x0, %rax
jl 0x4aeb
jmp 0x4b7b
movq 0x128(%rsp), %rax
movq 0x38(%rax), %rax
subq $0x1, %rax
movq %rax, 0x68(%rsp)
movq 0x128(%rsp), %rdi
movq 0x110(%rsp), %rsi
movq 0x68(%rsp), %rcx
xorl %eax, %eax
movl %eax, %edx
movq $-0x1, %r8
callq 0x5440
movq %rax, 0x70(%rsp)
cmpq $0x0, 0x70(%rsp)
jge 0x4b3b
movq $0x0, 0x70(%rsp)
movq 0x70(%rsp), %rax
cmpq 0x108(%rsp), %rax
jge 0x4b77
movq 0x108(%rsp), %rcx
subq 0x70(%rsp), %rcx
movq 0x100(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x100(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x108(%rsp)
jmp 0x4b79
jmp 0x4b7b
movq 0x110(%rsp), %rax
movq (%rax), %rax
movq %rax, 0xe8(%rsp)
movq 0xe8(%rsp), %rax
movq 0x128(%rsp), %rcx
movq 0x38(%rcx), %rcx
movq 0xd8(%rsp), %rdx
movq 0x8(%rdx), %rdx
movq 0xd8(%rsp), %rsi
addq 0x18(%rsi), %rdx
subq %rdx, %rcx
cmpq %rcx, %rax
jge 0x4bd1
movq 0xe8(%rsp), %rax
movq %rax, 0x28(%rsp)
jmp 0x4bfd
movq 0x128(%rsp), %rax
movq 0x38(%rax), %rax
movq 0xd8(%rsp), %rcx
movq 0x8(%rcx), %rcx
movq 0xd8(%rsp), %rdx
addq 0x18(%rdx), %rcx
subq %rcx, %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
movq %rax, 0xe8(%rsp)
movq 0xe8(%rsp), %rax
movq 0x128(%rsp), %rcx
movq 0xc0(%rcx), %rcx
movq 0xd8(%rsp), %rdx
movq 0x10(%rdx), %rdx
movq 0xd8(%rsp), %rsi
addq 0x20(%rsi), %rdx
subq %rdx, %rcx
cmpq %rcx, %rax
jge 0x4c50
movq 0xe8(%rsp), %rax
movq %rax, 0x20(%rsp)
jmp 0x4c7f
movq 0x128(%rsp), %rax
movq 0xc0(%rax), %rax
movq 0xd8(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq 0xd8(%rsp), %rdx
addq 0x20(%rdx), %rcx
subq %rcx, %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0xe8(%rsp)
movq 0xd8(%rsp), %rax
movq 0x8(%rax), %rax
movq 0xd8(%rsp), %rcx
addq 0x18(%rcx), %rax
addq 0xe8(%rsp), %rax
movq %rax, 0xf8(%rsp)
movq 0xd8(%rsp), %rax
movq 0x10(%rax), %rax
movq 0xd8(%rsp), %rcx
addq 0x20(%rcx), %rax
addq 0xe8(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq 0x110(%rsp), %rax
movq 0x10(%rax), %rax
andq $0x4, %rax
cmpq $0x0, %rax
je 0x4e9f
movq 0x128(%rsp), %rdi
movq 0x110(%rsp), %rsi
movq 0xd8(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0xd8(%rsp), %rax
addq 0x18(%rax), %rcx
movq 0x128(%rsp), %rax
movq 0x38(%rax), %r8
xorl %eax, %eax
movl %eax, %edx
callq 0x5440
movq %rax, 0x50(%rsp)
xorl %eax, %eax
cmpq $0x0, 0x50(%rsp)
movb %al, 0x1f(%rsp)
jle 0x4d66
movq 0x128(%rsp), %rdi
movq 0x50(%rsp), %rsi
subq $0x1, %rsi
callq 0x52f0
cmpl $0x0, %eax
setne %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0x4d70
jmp 0x4d80
movq 0x50(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x50(%rsp)
jmp 0x4d38
cmpq $0x0, 0x50(%rsp)
jge 0x4d99
movq 0x128(%rsp), %rax
movq 0x38(%rax), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
cmpq 0xf8(%rsp), %rax
jle 0x4dd2
movq 0x50(%rsp), %rax
subq 0xf8(%rsp), %rax
addq 0xf0(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0xf8(%rsp)
movq 0xd8(%rsp), %rax
cmpq $0x0, (%rax)
je 0x4e9d
movq 0xd8(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq 0x128(%rsp), %rcx
movq 0x38(%rcx), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jge 0x4e1e
movq 0xd8(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
jmp 0x4e33
movq 0x128(%rsp), %rax
movq 0x38(%rax), %rax
subq $0x1, %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
movq 0x110(%rsp), %rcx
subq (%rcx), %rax
cmpq 0xf8(%rsp), %rax
jle 0x4e83
movq 0x128(%rsp), %rdi
movq 0x110(%rsp), %rsi
movq 0x48(%rsp), %rcx
movq 0xf8(%rsp), %r8
xorl %eax, %eax
movl %eax, %edx
callq 0x5440
cmpq $0x0, %rax
jge 0x4e9b
movq 0xd8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0xd8(%rsp)
jmp 0x4b7b
jmp 0x4e9d
jmp 0x4e9f
movq 0x110(%rsp), %rax
movq 0x10(%rax), %rax
andq $0x1, %rax
cmpq $0x0, %rax
je 0x4ef7
movq 0x128(%rsp), %rdi
movq 0x110(%rsp), %rsi
movq 0x108(%rsp), %rcx
subq $0x1, %rcx
movq 0xd0(%rsp), %r8
leaq 0x78(%rsp), %rdx
callq 0x5440
movq 0x108(%rsp), %rax
subq $0x1, %rax
movq %rax, 0xd0(%rsp)
movq 0x108(%rsp), %rdi
addq $0x1, %rdi
movq 0xf8(%rsp), %rsi
subq 0x108(%rsp), %rsi
movq 0x100(%rsp), %rdx
addq $0x1, %rdx
movq 0xf0(%rsp), %rcx
subq 0x100(%rsp), %rcx
leaq 0x78(%rsp), %r8
addq $0x8, %r8
movq 0x78(%rsp), %r9
movq 0x118(%rsp), %rax
movq %rax, (%rsp)
callq 0x7bb0
cmpl $0x0, %eax
jge 0x4f63
movl $0xffffffff, 0x134(%rsp) # imm = 0xFFFFFFFF
jmp 0x52e0
jmp 0x4f65
movq 0x100(%rsp), %rax
movq 0xe0(%rsp), %rcx
cmpq 0x10(%rcx), %rax
jge 0x4fd3
movq 0x128(%rsp), %rdi
addq $0x88, %rdi
movq 0x100(%rsp), %rsi
movq 0x118(%rsp), %rcx
leaq 0x7162(%rip), %rdx      # 0xc103
callq 0x5590
cmpl $0x0, %eax
jge 0x4fbb
movl $0xffffffff, 0x134(%rsp) # imm = 0xFFFFFFFF
jmp 0x52e0
jmp 0x4fbd
movq 0x100(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x100(%rsp)
jmp 0x4f65
movq 0xe0(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x108(%rsp)
movq 0xe0(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x100(%rsp)
jmp 0x4ffd
movq 0x108(%rsp), %rcx
movq 0xe0(%rsp), %rdx
xorl %eax, %eax
cmpq 0x8(%rdx), %rcx
movb %al, 0xf(%rsp)
jge 0x5034
movq 0x100(%rsp), %rax
movq 0xe0(%rsp), %rcx
cmpq 0x10(%rcx), %rax
setl %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x503e
jmp 0x50ad
movq 0x128(%rsp), %rdi
addq $0x88, %rdi
movq 0x100(%rsp), %rsi
movq 0x118(%rsp), %rcx
leaq 0x709f(%rip), %rdx      # 0xc103
callq 0x5590
cmpl $0x0, %eax
jge 0x507e
movl $0xffffffff, 0x134(%rsp) # imm = 0xFFFFFFFF
jmp 0x52e0
jmp 0x5080
movq 0x108(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x108(%rsp)
movq 0x100(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x100(%rsp)
jmp 0x4ffd
movq 0xe0(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x108(%rsp)
movq 0x108(%rsp), %rax
movq 0xe0(%rsp), %rcx
movq 0x8(%rcx), %rcx
movq 0xe0(%rsp), %rdx
addq 0x18(%rdx), %rcx
cmpq %rcx, %rax
jge 0x5137
movq 0x128(%rsp), %rdi
movq 0x108(%rsp), %rsi
movq 0x118(%rsp), %rcx
leaq 0x702c(%rip), %rdx      # 0xc131
callq 0x5590
cmpl $0x0, %eax
jge 0x511f
movl $0xffffffff, 0x134(%rsp) # imm = 0xFFFFFFFF
jmp 0x52e0
jmp 0x5121
movq 0x108(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x108(%rsp)
jmp 0x50c1
movq 0xe0(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x100(%rsp)
movq 0x100(%rsp), %rax
movq 0xe0(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq 0xe0(%rsp), %rdx
addq 0x20(%rdx), %rcx
cmpq %rcx, %rax
jge 0x51c8
movq 0x128(%rsp), %rdi
addq $0x88, %rdi
movq 0x100(%rsp), %rsi
movq 0x118(%rsp), %rcx
leaq 0x6fa0(%rip), %rdx      # 0xc136
callq 0x5590
cmpl $0x0, %eax
jge 0x51b0
movl $0xffffffff, 0x134(%rsp) # imm = 0xFFFFFFFF
jmp 0x52e0
jmp 0x51b2
movq 0x100(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x100(%rsp)
jmp 0x514b
movq 0xe0(%rsp), %rax
cmpq 0xd8(%rsp), %rax
jne 0x51dc
jmp 0x5234
movq 0xe0(%rsp), %rax
movq 0x8(%rax), %rax
movq 0xe0(%rsp), %rcx
addq 0x18(%rcx), %rax
movq %rax, 0x108(%rsp)
movq 0xe0(%rsp), %rax
movq 0x10(%rax), %rax
movq 0xe0(%rsp), %rcx
addq 0x20(%rcx), %rax
movq %rax, 0x100(%rsp)
movq 0xe0(%rsp), %rax
movq (%rax), %rax
movq %rax, 0xe0(%rsp)
jmp 0x4ffb
movq 0xd8(%rsp), %rax
movq 0x10(%rax), %rax
movq 0xd8(%rsp), %rcx
addq 0x20(%rcx), %rax
movq %rax, 0x100(%rsp)
movq 0x100(%rsp), %rax
cmpq 0xf0(%rsp), %rax
jge 0x52bb
movq 0x128(%rsp), %rdi
addq $0x88, %rdi
movq 0x100(%rsp), %rsi
movq 0x118(%rsp), %rcx
leaq 0x6e77(%rip), %rdx      # 0xc103
callq 0x5590
cmpl $0x0, %eax
jge 0x52a3
movl $0xffffffff, 0x134(%rsp) # imm = 0xFFFFFFFF
jmp 0x52e0
jmp 0x52a5
movq 0x100(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x100(%rsp)
jmp 0x5254
jmp 0x52bd
movq 0xd8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0xe0(%rsp)
jmp 0x4914
movl $0x0, 0x134(%rsp)
movl 0x134(%rsp), %eax
addq $0x138, %rsp            # imm = 0x138
retq
nop