// File: /workspace/github_c_makefile_star2_O2/ThomasMadappattu[P]Sandmacs/main.c
// Function: main
int main (int argc, char *argv[])
{
  BUFFER *bp;
  char bname[NBUFN];		/* buffer name of file to read */
  int c, f, n, mflag;
  int ffile;			/* first file flag */
  int carg;			/* current arg to scan */
  int basec;			/* c stripped of meta character */

  /* initialize the editor and process the startup file */
  getwinsize();			/* find out the "real" screen size */
  strncpy (bname, "main", 5);	/* default buffer name */
  edinit (bname);		/* Buffers, windows */
  vtinit ();			/* Displays */
  ffile = TRUE;			/* no file to edit yet */
  update ();			/* let the user know we are here */

  /* scan through the command line and get the files to edit */
  for (carg = 1; carg < argc; ++carg)
    {
      /* set up a buffer for this file */
      makename (bname, argv[carg]);

      /* if this is the first file, read it in */
      if (ffile)
	{
	  bp = curbp;
	  makename (bname, argv[carg]);
	  strncpy (bp->b_bname, bname, NBUFN);
	  strncpy (bp->b_fname, argv[carg], NFILEN);
	  if (readin (argv[carg]) == ABORT)
	    {
	      strncpy (bp->b_bname, "main", 5);
	      strncpy (bp->b_fname, "", 1);
	    }
	  bp->b_dotp = bp->b_linep;
	  bp->b_doto = 0;
	  ffile = FALSE;
	}
      else
	{
	  /* set this to inactive */
	  bp = bfind (bname, TRUE, 0);
	  strncpy (bp->b_fname, argv[carg], NFILEN);
	  bp->b_active = FALSE;
	}
    }

  /* setup to process commands */
  lastflag = 0;			/* Fake last flags */
  curwp->w_flag |= WFMODE;	/* and force an update */

 loop:
  update ();			/* Fix up the screen */
  c = getkey ();
  if (mpresf != FALSE)
    {
      mlerase ();
      update ();
    }
  f = FALSE;
  n = 1;

  /* do META-# processing if needed */

  basec = c & ~META;		/* strip meta char off if there */
  if ((c & META) && ((basec >= '0' && basec <= '9') || basec == '-'))
    {
      f = TRUE;			/* there is a # arg */
      n = 0;			/* start with a zero default */
      mflag = 1;		/* current minus flag */
      c = basec;		/* strip the META */
      while ((c >= '0' && c <= '9') || (c == '-'))
	{
	  if (c == '-')
	    {
	      /* already hit a minus or digit? */
	      if ((mflag == -1) || (n != 0))
		break;
	      mflag = -1;
	    }
	  else
	    n = n * 10 + (c - '0');
	  if ((n == 0) && (mflag == -1)) /* lonely - */
	    mlwrite ("Arg:");
	  else
	    mlwrite ("Arg: %d", n * mflag);

	  c = getkey ();	/* get the next key */
	}
      n = n * mflag;		/* figure in the sign */
    }
  /* do ^U repeat argument processing */

  if (c == (CTRL | 'U'))
    {				/* ^U, start argument */
      f = TRUE;
      n = 4;			/* with argument of 4 */
      mflag = 0;		 /* that can be discarded */
      mlwrite ("Arg: 4");
      while (((c = getkey ()) >= '0')
	     && ((c <= '9') || (c == (CTRL | 'U')) || (c == '-')))
	{
	  if (c == (CTRL | 'U'))
	    n = n * 4;
	  /*
	   * If dash, and start of argument string, set arg.
	   * to -1.  Otherwise, insert it.
	   */
	  else if (c == '-')
	    {
	      if (mflag)
		break;
	      n = 0;
	      mflag = -1;
	    }
	  /*
	   * If first digit entered, replace previous argument
	   * with digit and set sign.  Otherwise, append to arg.
	   */
	  else
	    {
	      if (!mflag)
		{
		  n = 0;
		  mflag = 1;
		}
	      n = 10 * n + c - '0';
	    }
	  mlwrite ("Arg: %d", (mflag >= 0) ? n : (n ? -n : -1));
	}
      /*
       * Make arguments preceded by a minus sign negative and change
       * the special argument "^U -" to an effective "^U -1".
       */
      if (mflag == -1)
	{
	  if (n == 0)
	    n++;
	  n = -n;
	}
    }

  if (c == (CTRL | 'X'))       /* ^X is a prefix */
    c = CTLX | getctl ();
  if (kbdmip != NULL)
    {				 /* Save macro strokes */
      if (c != (CTLX | ')') && kbdmip > &kbdm[NKBDM - 6])
	{
	  ctrlg (FALSE, 0);
	  goto loop;
	}
      if (f != FALSE)
	{
	  *kbdmip++ = (CTRL | 'U');
	  *kbdmip++ = n;
	}
      *kbdmip++ = c;
    }
  execute (c, f, n);	       /* Do it */
  goto loop;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movl %edi, %ebp
xorl %eax, %eax
callq 0x6896
leaq 0x10(%rsp), %r15
movb $0x0, 0x4(%r15)
movl $0x6e69616d, (%r15)     # imm = 0x6E69616D
movq %r15, %rdi
callq 0x54fb
xorl %eax, %eax
callq 0x302e
xorl %eax, %eax
callq 0x3270
movslq %ebp, %rax
movq %rax, 0x8(%rsp)
pushq $0x1
popq %r12
pushq $0x1
popq %r14
xorl %ebp, %ebp
cmpq 0x8(%rsp), %r12
jge 0x530e
movq (%rbx,%r12,8), %rsi
movq %r15, %rdi
callq 0x4628
testb $0x1, %bpl
je 0x5295
movq %r15, %rdi
movl %r14d, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2985
movq %rax, %r13
leaq 0x33(%rax), %rdi
movq (%rbx,%r12,8), %rsi
pushq $0x50
popq %rdx
callq 0x2060
movb $0x0, 0x30(%r13)
jmp 0x5303
movq %r15, %r13
movq 0x7599(%rip), %r15      # 0xc838
movq (%rbx,%r12,8), %rsi
movq %r13, %rdi
callq 0x4628
leaq 0x83(%r15), %rbp
movq %rbp, %rdi
movq %r13, %rsi
pushq $0x10
popq %rdx
callq 0x2060
leaq 0x33(%r15), %r13
movq (%rbx,%r12,8), %rsi
movq %r13, %rdi
pushq $0x50
popq %rdx
callq 0x2060
movq (%rbx,%r12,8), %rdi
callq 0x40b8
cmpl $0x2, %eax
jne 0x52f1
xorl %eax, %eax
movb %al, 0x4(%rbp)
movl $0x6e69616d, (%rbp)     # imm = 0x6E69616D
movb %al, (%r13)
movq 0x28(%r15), %rax
movq %rax, 0x8(%r15)
andq $0x0, 0x10(%r15)
leaq 0x10(%rsp), %r15
incq %r12
movb $0x1, %bpl
jmp 0x524f
andl $0x0, 0x752b(%rip)      # 0xc840
movq 0x752c(%rip), %rax      # 0xc848
orb $0x10, 0x3b(%rax)
leaq 0x3047(%rip), %r15      # 0x836e
leaq 0x6de2(%rip), %rax      # 0xc110
addq $0x1f4, %rax            # imm = 0x1F4
movq %rax, 0x8(%rsp)
leaq 0x3029(%rip), %r12      # 0x8369
xorl %eax, %eax
callq 0x3270
callq 0x562a
movl %eax, %r13d
cmpl $0x0, 0x74de(%rip)      # 0xc834
je 0x5366
xorl %eax, %eax
callq 0x2fc0
xorl %eax, %eax
callq 0x3270
xorl %ebx, %ebx
btl $0x9, %r13d
jb 0x537a
movl %r13d, %eax
movl %r14d, %ebp
jmp 0x540e
movl %r13d, %eax
andl $0xfffffdff, %eax       # imm = 0xFFFFFDFF
leal -0x30(%rax), %ecx
cmpl $0xa, %ecx
setae %cl
cmpl $0x2d, %eax
setne %dl
xorl %ebx, %ebx
movl %r14d, %ebp
testb %cl, %dl
jne 0x549b
xorl %ecx, %ecx
movl %r14d, %ebp
leal -0x30(%rax), %edx
cmpl $0xa, %edx
setae %sil
cmpl $0x2d, %eax
setne %dil
testb %sil, %dil
jne 0x5408
cmpl $0x2d, %eax
jne 0x53cf
testl %ecx, %ecx
jne 0x5408
xorl %ebx, %ebx
pushq $-0x1
popq %r13
cmpl $-0x1, %ebp
jne 0x53d7
jmp 0x5408
imull $0xa, %ecx, %ebx
addl %edx, %ebx
movl %ebp, %r13d
movl %r13d, %eax
notl %eax
orl %ebx, %eax
jne 0x53ec
movq %r12, %rdi
xorl %eax, %eax
callq 0x3e83
jmp 0x53fc
movl %r13d, %esi
imull %ebx, %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x3e83
callq 0x562a
movl %ebx, %ecx
movl %r13d, %ebp
jmp 0x53a3
imull %ecx, %ebp
movl %r14d, %ebx
movl %eax, %r13d
cmpl $0x155, %eax            # imm = 0x155
jne 0x5483
xorl %ebx, %ebx
leaq 0x2f55(%rip), %rdi      # 0x8376
xorl %eax, %eax
callq 0x3e83
pushq $0x4
popq %rbp
callq 0x562a
movl %eax, %r13d
cmpl $0x30, %eax
jl 0x547b
cmpl $0x3a, %r13d
setae %al
cmpl $0x155, %r13d           # imm = 0x155
setne %cl
testb %cl, %al
jne 0x5480
cmpl $0x155, %r13d           # imm = 0x155
jne 0x545b
shll $0x2, %ebp
jmp 0x546d
imull $0xa, %ebp, %eax
testl %ebx, %ebx
cmovel %ebx, %eax
leal (%rax,%r13), %ebp
addl $-0x30, %ebp
movl %r14d, %ebx
movq %r15, %rdi
movl %ebp, %esi
xorl %eax, %eax
callq 0x3e83
jmp 0x542b
movl %r14d, %ebx
jmp 0x549b
movl %r14d, %ebx
cmpl $0x158, %r13d           # imm = 0x158
jne 0x549b
callq 0x5657
movl %eax, %r13d
orl $0x400, %r13d           # imm = 0x400
movq 0x73ae(%rip), %rax      # 0xc850
testq %rax, %rax
je 0x54ea
cmpl $0x429, %r13d           # imm = 0x429
setne %cl
cmpq 0x8(%rsp), %rax
seta %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x54ca
callq 0x5855
jmp 0x5340
testl %ebx, %ebx
je 0x54db
movw $0x155, (%rax)          # imm = 0x155
movw %bp, 0x2(%rax)
addq $0x4, %rax
leaq 0x2(%rax), %rcx
movq %rcx, 0x736a(%rip)      # 0xc850
movw %r13w, (%rax)
movl %r13d, %edi
movl %ebx, %esi
movl %ebp, %edx
callq 0x559c
jmp 0x5340