// File: /workspace/github_c_makefile_star2_O1/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 0x793b(%rip), %rax      # 0xda38
movq (%rax), %rax
movq 0x28(%rax), %rbx
movq (%rbx), %rax
cmpq %rbx, %rax
je 0x6163
leaq 0x7935(%rip), %rcx      # 0xda48
movq (%rcx), %rcx
movq 0x18(%rcx), %rdx
xorl %r13d, %r13d
xorl %ebp, %ebp
xorl %r9d, %r9d
xorl %r15d, %r15d
xorl %r8d, %r8d
cmpq %rdx, %rax
jne 0x614d
movq 0x20(%rcx), %rsi
leaq (%rsi,%r13), %r8
movslq 0x14(%rax), %rdi
movl $0xa, %r9d
cmpq %rdi, %rsi
je 0x614a
movzbl 0x18(%rax,%rsi), %r9d
movl %ebp, %r15d
incl %ebp
movslq 0x14(%rax), %rsi
addq %rsi, %r13
incq %r13
movq (%rax), %rax
cmpq %rbx, %rax
jne 0x6128
jmp 0x6171
xorl %r8d, %r8d
xorl %r15d, %r15d
xorl %r9d, %r9d
xorl %ebp, %ebp
xorl %r13d, %r13d
movq %r9, 0x10(%rsp)
leaq 0x78cb(%rip), %rax      # 0xda48
movq (%rax), %r14
movq 0x18(%r14), %r12
cmpq %rbx, %r12
cmoveq %r13, %r8
movq %r8, 0x20(%rsp)
xorl %edi, %edi
callq 0x622a
movl %eax, 0x4(%rsp)
movslq 0x20(%r14), %rax
movq %rax, 0x8(%rsp)
movq %r12, 0x18(%rsp)
movslq 0x14(%r12), %rax
movq %rax, 0x20(%r14)
xorl %edi, %edi
callq 0x622a
movq 0x20(%rsp), %r9
movl %eax, %r8d
movq 0x8(%rsp), %rax
movq %rax, 0x20(%r14)
testq %r13, %r13
movl $0x0, %r10d
je 0x61e1
imulq $0x64, %r9, %rax
cqto
idivq %r13
movq %rax, %r10
cmpq %rbx, 0x18(%rsp)
cmovel %ebp, %r15d
incl %r15d
incl %ebp
subq $0x8, %rsp
leaq 0x322c(%rip), %rdi      # 0x9426
movl %r15d, %esi
movl %ebp, %edx
movl 0xc(%rsp), %ecx
xorl %eax, %eax
pushq 0x18(%rsp)
pushq %r10
pushq %r13
callq 0x43cc
addq $0x20, %rsp
movl $0x1, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq