// File: /workspace/github_c_makefile_star2_O3/hughbarney[P]pEmacs/random.c
// Function: showcpos
int showcpos(int f, int n)
{
	LINE *lp;	/* current line */
	long numchars;	/* # of chars in file */
	int numlines;	/* # of lines in file */
	long predchars;	/* # chars preceding point */
	int predlines;	/* # lines preceding point */
	int curchar;	/* character under cursor */
	int ratio;
	int col;
	int savepos;		/* temp save for current offset */
	int ecol;		/* column pos/end of current line */

	/* starting at the beginning of the buffer */
	lp = lforw(curbp->b_linep);

	/* start counting chars and lines */
	numchars = 0;
	numlines = 0;
	predchars = 0;
	predlines = 0;
	curchar = 0;
	while (lp != curbp->b_linep) {
		/* if we are on the current line, record it */
		if (lp == curwp->w_dotp) {
			predlines = numlines;
			predchars = numchars + curwp->w_doto;
			if ((curwp->w_doto) == llength(lp))
				curchar = '\n';
			else
				curchar = lgetc(lp, curwp->w_doto);
		}
		/* on to the next line */
		++numlines;
		numchars += llength(lp) + 1;
		lp = lforw(lp);
	}

	/* if at end of file, record it */
	if (curwp->w_dotp == curbp->b_linep) {
		predlines = numlines;
		predchars = numchars;
	}

	/* Get real column and end-of-line column. */
	col = getccol(FALSE);
	savepos = curwp->w_doto;
	curwp->w_doto = llength(curwp->w_dotp);
	ecol = getccol(FALSE);
	curwp->w_doto = savepos;

	ratio = 0;		/* Ratio before dot. */
	if (numchars != 0)
		ratio = (100L * predchars) / numchars;

	/* summarize and report the info */
	mlwrite("Line %d/%d Col %d/%d Char %d/%d (%d%%) char = 0x%x",
		predlines + 1, numlines + 1, col, ecol,
		predchars, numchars, ratio, curchar);
	return TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
leaq 0x7a83(%rip), %rax      # 0xda38
movq (%rax), %rax
movq 0x28(%rax), %rbx
movq (%rbx), %rax
leaq 0x7a82(%rip), %rcx      # 0xda48
movq (%rcx), %r14
movq 0x18(%r14), %r12
cmpq %rbx, %rax
je 0x601b
xorl %r13d, %r13d
xorl %ebp, %ebp
xorl %edi, %edi
xorl %r15d, %r15d
xorl %esi, %esi
cmpq %r12, %rax
je 0x5fe8
movl 0x14(%rax), %ecx
jmp 0x6006
movq 0x20(%r14), %rdx
leaq (%rdx,%r13), %rsi
movslq 0x14(%rax), %rcx
movl $0xa, %edi
cmpq %rcx, %rdx
je 0x6003
movzbl 0x18(%rax,%rdx), %edi
movl %ebp, %r15d
incl %ebp
movslq %ecx, %rcx
addq %rcx, %r13
incq %r13
movq (%rax), %rax
cmpq %rbx, %rax
jne 0x5fde
jmp 0x6027
xorl %esi, %esi
xorl %r15d, %r15d
xorl %edi, %edi
xorl %ebp, %ebp
xorl %r13d, %r13d
movq %rdi, 0x18(%rsp)
cmpq %rbx, %r12
cmoveq %r13, %rsi
movq %rsi, 0x20(%rsp)
xorl %edi, %edi
callq 0x60cb
movl %eax, 0xc(%rsp)
movslq 0x20(%r14), %rax
movq %rax, 0x10(%rsp)
movslq 0x14(%r12), %rax
movq %rax, 0x20(%r14)
xorl %edi, %edi
callq 0x60cb
movq 0x20(%rsp), %r9
movl %eax, %r8d
movq 0x10(%rsp), %rax
movq %rax, 0x20(%r14)
testq %r13, %r13
movl $0x0, %r10d
je 0x6084
imulq $0x64, %r9, %rax
cqto
idivq %r13
movq %rax, %r10
cmpq %rbx, %r12
cmovel %ebp, %r15d
incl %r15d
incl %ebp
subq $0x8, %rsp
leaq 0x338b(%rip), %rdi      # 0x9426
movl %r15d, %esi
movl %ebp, %edx
movl 0x14(%rsp), %ecx
xorl %eax, %eax
pushq 0x20(%rsp)
pushq %r10
pushq %r13
callq 0x4246
addq $0x20, %rsp
movl $0x1, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq