// File: /workspace/github_c_makefile_star2_O2/hughbarney[P]pEmacs/display.c
// Function: mlreplyt
int mlreplyt (char *prompt, char *buf, int nbuf, char eolchar)
{
  int cpos, i, c;

  cpos = 0;

  if (kbdmop != NULL)
    {
      while ((c = *kbdmop++) != '\0')
	buf[cpos++] = c;
      buf[cpos] = 0;
      if (buf[0] == 0)
	return (FALSE);
      return (TRUE);
    }
  mlwrite (prompt);

  for (;;)
    {
      /* get a character from the user. if it is a <ret> change it to a <NL> */
      c = (*term.t_getchar) ();
      if (c == 0x0d)
	c = '\n';

      if (c == eolchar)
	{
	  buf[cpos++] = 0;

	  if (kbdmip != NULL)
	    {
	      if (kbdmip + cpos > &kbdm[NKBDM - 3])
		{
		  ctrlg (FALSE, 0);
		  (*term.t_flush) ();
		  return (ABORT);
		}
	      for (i = 0; i < cpos; ++i)
		*kbdmip++ = buf[i];
	    }
	  (*term.t_putchar) ('\r');
	  ttcol = 0;
	  (*term.t_flush) ();

	  if (buf[0] == 0)
	    return (FALSE);

	  return (TRUE);

	}
      else if (c == 0x07)
	{			     /* Bell, abort */
	  (*term.t_putchar) ('^');
	  (*term.t_putchar) ('G');
	  ttcol += 2;
	  ctrlg (FALSE, 0);
	  (*term.t_flush) ();
	  return (ABORT);
	}
      else if (c == 0x7F || c == 0x08)
	{			       /* rubout/erase */
	  if (cpos != 0)
	    {
	      (*term.t_putchar) ('\b');
	      (*term.t_putchar) (' ');
	      (*term.t_putchar) ('\b');
	      --ttcol;

	      if (buf[--cpos] < 0x20)
		{
		  (*term.t_putchar) ('\b');
		  (*term.t_putchar) (' ');
		  (*term.t_putchar) ('\b');
		  --ttcol;
		}
	      if (buf[cpos] == '\n')
		{
		  (*term.t_putchar) ('\b');
		  (*term.t_putchar) ('\b');
		  (*term.t_putchar) (' ');
		  (*term.t_putchar) (' ');
		  (*term.t_putchar) ('\b');
		  (*term.t_putchar) ('\b');
		  --ttcol;
		  --ttcol;
		}
	      (*term.t_flush) ();
	    }
	}
      else if (c == 0x15)
	{				 /* C-U, kill */
	  while (cpos != 0)
	    {
	      (*term.t_putchar) ('\b');
	      (*term.t_putchar) (' ');
	      (*term.t_putchar) ('\b');
	      --ttcol;
	      if (buf[--cpos] < 0x20)
		{
		  (*term.t_putchar) ('\b');
		  (*term.t_putchar) (' ');
		  (*term.t_putchar) ('\b');
		  --ttcol;
		}
	    }
	  (*term.t_flush) ();
	}
      else
	{
	  if (cpos < nbuf - 1)
	    {
	      buf[cpos++] = c;
	      if ((c < ' ') && (c != '\n'))
		{
		  (*term.t_putchar) ('^');
		  ++ttcol;
		  c ^= 0x40;
		}
	      if (c != '\n')
		(*term.t_putchar) (c);
	      else
		{		/* put out <NL> for <ret> */
		  (*term.t_putchar) ('<');
		  (*term.t_putchar) ('N');
		  (*term.t_putchar) ('L');
		  (*term.t_putchar) ('>');
		  ttcol += 3;
		}
	      ++ttcol;
	      (*term.t_flush) ();
	    }
	}
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %rbx
leaq 0x8b6a(%rip), %rax      # 0xca60
movq (%rax), %rdx
testq %rdx, %rdx
je 0x3f2d
xorl %ecx, %ecx
leaq 0x2(%rdx), %rsi
movq %rsi, (%rax)
movzwl (%rdx), %edx
testw %dx, %dx
je 0x3f1a
movb %dl, (%rbx,%rcx)
incq %rcx
movq (%rax), %rdx
jmp 0x3f00
movl %ecx, %eax
movb $0x0, (%rbx,%rax)
xorl %eax, %eax
cmpb $0x0, (%rbx)
setne %al
jmp 0x41d6
movl %ecx, %r14d
xorl %eax, %eax
callq 0x3dec
movsbl %r14b, %eax
movl %eax, 0x4(%rsp)
decl %ebp
movl %ebp, (%rsp)
leaq 0x890d(%rip), %r12      # 0xc858
pushq $0x8
popq %r14
xorl %r13d, %r13d
movl %r13d, %r15d
xorl %eax, %eax
callq *0x20(%r12)
cmpl $0xd, %eax
movl %eax, %r13d
pushq $0xa
popq %rcx
cmovel %ecx, %r13d
cmpl 0x4(%rsp), %r13d
je 0x4153
cmpl $0x7, %eax
je 0x41a6
cmpl $0x8, %eax
je 0x4009
cmpl $0x7f, %eax
je 0x4009
movslq %r15d, %rbp
cmpl $0x15, %eax
je 0x40c3
cmpl (%rsp), %r15d
jge 0x3f55
movb %r13b, (%rbx,%rbp)
cmpl $0x20, %r13d
setge %al
cmpl $0xa, %r13d
sete %cl
orb %al, %cl
jne 0x3fc7
pushq $0x5e
popq %rdi
xorl %eax, %eax
callq *0x28(%r12)
incl 0x8191(%rip)            # 0xc154
xorl $0x40, %r13d
movq 0x28(%r12), %rcx
cmpl $0xa, %r13d
jne 0x412c
pushq $0x3c
popq %rdi
xorl %eax, %eax
callq *%rcx
pushq $0x4e
popq %rdi
xorl %eax, %eax
callq *0x28(%r12)
pushq $0x4c
popq %rdi
xorl %eax, %eax
callq *0x28(%r12)
pushq $0x3e
popq %rdi
xorl %eax, %eax
callq *0x28(%r12)
movl 0x8153(%rip), %eax      # 0xc154
addl $0x3, %eax
jmp 0x4139
movl $0x0, %r13d
testl %r15d, %r15d
je 0x3f52
movl %r14d, %edi
xorl %eax, %eax
callq *0x28(%r12)
pushq $0x20
popq %rbp
movl %ebp, %edi
xorl %eax, %eax
callq *0x28(%r12)
movl %r14d, %edi
xorl %eax, %eax
callq *0x28(%r12)
decl 0x8116(%rip)            # 0xc154
movslq %r15d, %rax
leaq -0x1(%rax), %r13
cmpb $0x1f, -0x1(%rbx,%rax)
jg 0x4147
movl %r14d, %edi
xorl %eax, %eax
callq *0x28(%r12)
movl %ebp, %edi
xorl %eax, %eax
callq *0x28(%r12)
movl %r14d, %edi
xorl %eax, %eax
callq *0x28(%r12)
decl 0x80e1(%rip)            # 0xc154
cmpb $0xa, (%rbx,%r13)
jne 0x4147
movl %r14d, %edi
xorl %eax, %eax
callq *0x28(%r12)
movl %r14d, %edi
xorl %eax, %eax
callq *0x28(%r12)
movl %ebp, %edi
xorl %eax, %eax
callq *0x28(%r12)
movl %ebp, %edi
xorl %eax, %eax
callq *0x28(%r12)
movl %r14d, %edi
xorl %eax, %eax
callq *0x28(%r12)
movl %r14d, %edi
xorl %eax, %eax
callq *0x28(%r12)
movl 0x8096(%rip), %eax      # 0xc154
addl $-0x2, %eax
jmp 0x4141
pushq $0x20
popq %r13
movq %rbp, %r15
subq $0x1, %r15
jb 0x4127
movl %r14d, %edi
xorl %eax, %eax
callq *0x28(%r12)
movl %r13d, %edi
xorl %eax, %eax
callq *0x28(%r12)
movl %r14d, %edi
xorl %eax, %eax
callq *0x28(%r12)
decl 0x8060(%rip)            # 0xc154
cmpb $0x1f, -0x1(%rbx,%rbp)
movq %r15, %rbp
jg 0x40c7
movl %r14d, %edi
xorl %eax, %eax
callq *0x28(%r12)
movl %r13d, %edi
xorl %eax, %eax
callq *0x28(%r12)
movl %r14d, %edi
xorl %eax, %eax
callq *0x28(%r12)
decl 0x8032(%rip)            # 0xc154
movq %r15, %rbp
jmp 0x40c7
xorl %r13d, %r13d
jmp 0x4147
movl %r13d, %edi
xorl %eax, %eax
callq *%rcx
movl 0x801b(%rip), %eax      # 0xc154
incl %r15d
incl %eax
movl %r15d, %r13d
movl %eax, 0x800d(%rip)      # 0xc154
xorl %eax, %eax
callq *0x30(%r12)
jmp 0x3f52
movslq %r15d, %rax
movb $0x0, (%rbx,%rax)
leaq 0x88df(%rip), %rcx      # 0xca40
movq (%rcx), %rdx
testq %rdx, %rdx
je 0x41e5
leaq (%rdx,%rax,2), %rsi
addq $0x2, %rsi
movl $0x1fa, %edi            # imm = 0x1FA
addq 0x7e63(%rip), %rdi      # 0xbfe0
cmpq %rdi, %rsi
ja 0x41c1
pushq $0x2
popq %rsi
xorl %edi, %edi
cmpq %rax, %rdi
jg 0x41e5
movsbl (%rbx,%rdi), %r8d
leaq (%rdx,%rsi), %r9
movq %r9, (%rcx)
movw %r8w, (%rdx,%rdi,2)
incq %rdi
addq $0x2, %rsi
jmp 0x4187
pushq $0x5e
popq %rdi
xorl %eax, %eax
callq *0x28(%r12)
pushq $0x47
popq %rdi
xorl %eax, %eax
callq *0x28(%r12)
addl $0x2, 0x7f93(%rip)      # 0xc154
xorl %edi, %edi
xorl %esi, %esi
xorl %eax, %eax
callq 0x5694
xorl %eax, %eax
callq *0x30(%r12)
pushq $0x2
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0xd
popq %rdi
xorl %eax, %eax
callq *0x28(%r12)
andl $0x0, 0x7f5e(%rip)      # 0xc154
xorl %eax, %eax
callq *0x30(%r12)
jmp 0x3f20