// File: /workspace/github_c_makefile_star2_O3/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 0x7080
leaq 0x10(%rsp), %rdi
movb $0x0, 0x4(%rdi)
movl $0x6e69616d, (%rdi)     # imm = 0x6E69616D
callq 0x5ba2
xorl %eax, %eax
callq 0x31de
xorl %eax, %eax
callq 0x3493
cmpl $0x2, %ebp
jl 0x592c
movl %ebp, %r12d
movl $0x1, %ebp
leaq 0x10(%rsp), %r14
xorl %r15d, %r15d
movq %r12, 0x8(%rsp)
movq (%rbx,%rbp,8), %rsi
movq %r14, %rdi
callq 0x4b72
testb $0x1, %r15b
je 0x58a5
movq %r14, %rdi
movl $0x1, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2a31
movq %rax, %r15
leaq 0x33(%rax), %rdi
movq (%rbx,%rbp,8), %rsi
movl $0x50, %edx
callq 0x2060
movb $0x0, 0x30(%r15)
jmp 0x591d
movq 0x7f9c(%rip), %r13      # 0xd848
movq (%rbx,%rbp,8), %rsi
movq %r14, %rdi
callq 0x4b72
leaq 0x83(%r13), %r15
movl $0x10, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x2060
leaq 0x33(%r13), %r12
movq (%rbx,%rbp,8), %rsi
movl $0x50, %edx
movq %r12, %rdi
callq 0x2060
movq (%rbx,%rbp,8), %rdi
callq 0x45d2
cmpl $0x2, %eax
jne 0x5903
xorl %eax, %eax
movb %al, 0x4(%r15)
movl $0x6e69616d, (%r15)     # imm = 0x6E69616D
movb %al, (%r12)
movq 0x28(%r13), %rax
movq %rax, 0x8(%r13)
movq $0x0, 0x10(%r13)
movq 0x8(%rsp), %r12
leaq 0x10(%rsp), %r14
incq %rbp
movb $0x1, %r15b
cmpq %rbp, %r12
jne 0x5866
movl $0x0, 0x7f1a(%rip)      # 0xd850
movq 0x7f1b(%rip), %rax      # 0xd858
orb $0x10, 0x3b(%rax)
leaq 0x3a26(%rip), %r14      # 0x936e
leaq 0x77d1(%rip), %rbx      # 0xd120
addq $0x1f4, %rbx            # imm = 0x1F4
leaq 0x3a0c(%rip), %r12      # 0x9369
xorl %eax, %eax
callq 0x3493
callq 0x5d03
movl %eax, %ebp
cmpl $0x0, 0x7ed2(%rip)      # 0xd844
je 0x5982
xorl %eax, %eax
callq 0x3108
xorl %eax, %eax
callq 0x3493
btl $0x9, %ebp
jb 0x5996
movl $0x1, %r13d
xorl %r15d, %r15d
jmp 0x5a2f
movl %ebp, %eax
andl $0xfffffdff, %eax       # imm = 0xFFFFFDFF
leal -0x30(%rax), %ecx
cmpl $0xa, %ecx
setae %sil
cmpl $0x2d, %eax
sete %dl
setne %dil
testb %sil, %dil
jne 0x5abd
xorl %r13d, %r13d
movl $0x1, %ebp
testb $0x1, %dl
je 0x59db
testl %r13d, %r13d
jne 0x5a23
cmpl $-0x1, %ebp
je 0x5a23
xorl %r13d, %r13d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x59e4
leal (%r13,%r13,4), %eax
leal (%rcx,%rax,2), %r13d
movl %ebp, %eax
notl %eax
orl %r13d, %eax
jne 0x59f9
movq %r12, %rdi
xorl %eax, %eax
callq 0x4352
jmp 0x5a09
movl %ebp, %esi
imull %r13d, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x4352
callq 0x5d03
leal -0x30(%rax), %ecx
cmpl $0xa, %ecx
setb %sil
cmpl $0x2d, %eax
sete %dl
orb %dl, %sil
jne 0x59c2
imull %ebp, %r13d
movl $0x1, %r15d
movl %eax, %ebp
cmpl $0x155, %ebp            # imm = 0x155
jne 0x5adc
leaq 0x3934(%rip), %rdi      # 0x9376
xorl %eax, %eax
callq 0x4352
callq 0x5d03
movl %eax, %ebp
cmpl $0x30, %eax
jl 0x5ac8
movl $0x4, %r13d
xorl %r15d, %r15d
cmpl $0x3a, %ebp
setae %al
cmpl $0x155, %ebp            # imm = 0x155
setne %cl
testb %cl, %al
jne 0x5ad6
cmpl $0x155, %ebp            # imm = 0x155
jne 0x5a7f
shll $0x2, %r13d
jmp 0x5a9c
addl %r13d, %r13d
testl %r15d, %r15d
leal (%r13,%r13,4), %eax
cmovel %r15d, %eax
leal (%rax,%rbp), %r13d
addl $-0x30, %r13d
movl $0x1, %r15d
movq %r14, %rdi
movl %r13d, %esi
xorl %eax, %eax
callq 0x4352
callq 0x5d03
movl %eax, %ebp
cmpl $0x2f, %eax
jg 0x5a5e
movl $0x1, %r15d
jmp 0x5b10
xorl %r15d, %r15d
movl $0x1, %r13d
jmp 0x5b10
movl $0x1, %r15d
movl $0x4, %r13d
jmp 0x5b10
movl $0x1, %r15d
cmpl $0x158, %ebp            # imm = 0x158
jne 0x5b10
xorl %eax, %eax
leaq 0x7ca3(%rip), %rcx      # 0xd790
callq *0x20(%rcx)
leal -0x61(%rax), %ecx
leal -0x20(%rax), %edx
cmpl $0x1a, %ecx
cmovael %eax, %edx
movl %edx, %ebp
orl $0x140, %ebp            # imm = 0x140
cmpl $0x20, %edx
cmovael %edx, %ebp
orl $0x400, %ebp            # imm = 0x400
movq 0x7d49(%rip), %rax      # 0xd860
testq %rax, %rax
je 0x5b90
cmpl $0x429, %ebp            # imm = 0x429
setne %cl
cmpq %rbx, %rax
seta %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x5b6f
xorl %eax, %eax
leaq 0x7c55(%rip), %rcx      # 0xd790
callq *0x50(%rcx)
cmpq $0x0, 0x7d1a(%rip)      # 0xd860
je 0x5b5c
movw $0x429, 0x75cf(%rip)    # imm = 0x429
movq $0x0, 0x7d04(%rip) # 0xd860
leaq 0x3896(%rip), %rdi      # 0x93f9
xorl %eax, %eax
callq 0x4352
jmp 0x595d
testl %r15d, %r15d
je 0x5b82
movw $0x155, (%rax)          # imm = 0x155
movw %r13w, 0x2(%rax)
addq $0x4, %rax
leaq 0x2(%rax), %rcx
movq %rcx, 0x7cd3(%rip)      # 0xd860
movw %bp, (%rax)
movl %ebp, %edi
movl %r15d, %esi
movl %r13d, %edx
callq 0x5c53
jmp 0x595d