// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, %al
callq 0xa620
leaq -0x30(%rbp), %rdi
leaq 0x5548(%rip), %rsi      # 0xd450
movl $0x5, %edx
callq 0x2060
leaq -0x30(%rbp), %rdi
callq 0x83a0
movb $0x0, %al
callq 0x4040
movl $0x1, -0x44(%rbp)
movb $0x0, %al
callq 0x43e0
movl $0x1, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x8075
leaq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x67b0
cmpl $0x0, -0x44(%rbp)
je 0x8029
movq 0x98ff(%rip), %rax      # 0x11868
movq %rax, -0x18(%rbp)
leaq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x67b0
movq -0x18(%rbp), %rdi
addq $0x83, %rdi
leaq -0x30(%rbp), %rsi
movl $0x10, %edx
callq 0x2060
movq -0x18(%rbp), %rdi
addq $0x33, %rdi
movq -0x10(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movl $0x50, %edx
callq 0x2060
movq -0x10(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x5d30
cmpl $0x2, %eax
jne 0x8004
movq -0x18(%rbp), %rdi
addq $0x83, %rdi
leaq 0x546f(%rip), %rsi      # 0xd450
movl $0x5, %edx
callq 0x2060
movq -0x18(%rbp), %rdi
addq $0x33, %rdi
leaq 0x5732(%rip), %rsi      # 0xd72c
movl $0x1, %edx
callq 0x2060
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x10(%rax)
movl $0x0, -0x44(%rbp)
jmp 0x8065
leaq -0x30(%rbp), %rdi
movl $0x1, %esi
xorl %edx, %edx
movb $0x0, %al
callq 0x32a0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
addq $0x33, %rdi
movq -0x10(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movl $0x50, %edx
callq 0x2060
movq -0x18(%rbp), %rax
movb $0x0, 0x30(%rax)
jmp 0x8067
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x7f37
movl $0x0, 0x97f1(%rip)      # 0x11870
movq 0x97f2(%rip), %rax      # 0x11878
movsbl 0x3b(%rax), %ecx
orl $0x10, %ecx
movb %cl, 0x3b(%rax)
movb $0x0, %al
callq 0x43e0
callq 0x85e0
movl %eax, -0x34(%rbp)
cmpl $0x0, 0x97be(%rip)      # 0x11864
je 0x80b6
movb $0x0, %al
callq 0x3f90
movb $0x0, %al
callq 0x43e0
movl $0x0, -0x38(%rbp)
movl $0x1, -0x3c(%rbp)
movl -0x34(%rbp), %eax
andl $0xfffffdff, %eax       # imm = 0xFFFFFDFF
movl %eax, -0x4c(%rbp)
movl -0x34(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x81a9
cmpl $0x30, -0x4c(%rbp)
jl 0x80ec
cmpl $0x39, -0x4c(%rbp)
jle 0x80f6
cmpl $0x2d, -0x4c(%rbp)
jne 0x81a9
movl $0x1, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x1, -0x40(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x34(%rbp)
cmpl $0x30, -0x34(%rbp)
jl 0x8122
movb $0x1, %al
cmpl $0x39, -0x34(%rbp)
movb %al, -0x4d(%rbp)
jle 0x812c
cmpl $0x2d, -0x34(%rbp)
sete %al
movb %al, -0x4d(%rbp)
movb -0x4d(%rbp), %al
testb $0x1, %al
jne 0x8135
jmp 0x819f
cmpl $0x2d, -0x34(%rbp)
jne 0x8152
cmpl $-0x1, -0x40(%rbp)
je 0x8147
cmpl $0x0, -0x3c(%rbp)
je 0x8149
jmp 0x819f
movl $0xffffffff, -0x40(%rbp) # imm = 0xFFFFFFFF
jmp 0x8161
imull $0xa, -0x3c(%rbp), %eax
movl -0x34(%rbp), %ecx
subl $0x30, %ecx
addl %ecx, %eax
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jne 0x817d
cmpl $-0x1, -0x40(%rbp)
jne 0x817d
leaq 0x52e1(%rip), %rdi      # 0xd455
movb $0x0, %al
callq 0x5970
jmp 0x8192
movl -0x3c(%rbp), %esi
imull -0x40(%rbp), %esi
leaq 0x52cf(%rip), %rdi      # 0xd45a
movb $0x0, %al
callq 0x5970
callq 0x85e0
movl %eax, -0x34(%rbp)
jmp 0x8111
movl -0x3c(%rbp), %eax
imull -0x40(%rbp), %eax
movl %eax, -0x3c(%rbp)
cmpl $0x155, -0x34(%rbp)     # imm = 0x155
jne 0x82da
movl $0x1, -0x38(%rbp)
movl $0x4, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
leaq 0x5290(%rip), %rdi      # 0xd462
movb $0x0, %al
callq 0x5970
callq 0x85e0
movl %eax, %ecx
movl %ecx, -0x34(%rbp)
xorl %eax, %eax
cmpl $0x30, %ecx
movb %al, -0x4e(%rbp)
jl 0x8216
movb $0x1, %al
cmpl $0x39, -0x34(%rbp)
movb %al, -0x4f(%rbp)
jle 0x8210
movb $0x1, %al
cmpl $0x155, -0x34(%rbp)     # imm = 0x155
movb %al, -0x4f(%rbp)
je 0x8210
cmpl $0x2d, -0x34(%rbp)
sete %al
movb %al, -0x4f(%rbp)
movb -0x4f(%rbp), %al
movb %al, -0x4e(%rbp)
movb -0x4e(%rbp), %al
testb $0x1, %al
jne 0x8222
jmp 0x82bb
cmpl $0x155, -0x34(%rbp)     # imm = 0x155
jne 0x8236
movl -0x3c(%rbp), %eax
shll $0x2, %eax
movl %eax, -0x3c(%rbp)
jmp 0x8277
cmpl $0x2d, -0x34(%rbp)
jne 0x8254
cmpl $0x0, -0x40(%rbp)
je 0x8244
jmp 0x82bb
movl $0x0, -0x3c(%rbp)
movl $0xffffffff, -0x40(%rbp) # imm = 0xFFFFFFFF
jmp 0x8275
cmpl $0x0, -0x40(%rbp)
jne 0x8268
movl $0x0, -0x3c(%rbp)
movl $0x1, -0x40(%rbp)
imull $0xa, -0x3c(%rbp), %eax
addl -0x34(%rbp), %eax
subl $0x30, %eax
movl %eax, -0x3c(%rbp)
jmp 0x8277
cmpl $0x0, -0x40(%rbp)
jl 0x8285
movl -0x3c(%rbp), %eax
movl %eax, -0x54(%rbp)
jmp 0x82a5
cmpl $0x0, -0x3c(%rbp)
je 0x8295
xorl %eax, %eax
subl -0x3c(%rbp), %eax
movl %eax, -0x58(%rbp)
jmp 0x829f
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x58(%rbp)
jmp 0x829f
movl -0x58(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %esi
leaq 0x51ab(%rip), %rdi      # 0xd45a
movb $0x0, %al
callq 0x5970
jmp 0x81d9
cmpl $-0x1, -0x40(%rbp)
jne 0x82d8
cmpl $0x0, -0x3c(%rbp)
jne 0x82d0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
xorl %eax, %eax
subl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0x82da
cmpl $0x158, -0x34(%rbp)     # imm = 0x158
jne 0x82f0
callq 0x8640
orl $0x400, %eax            # imm = 0x400
movl %eax, -0x34(%rbp)
cmpq $0x0, 0x9588(%rip)      # 0x11880
je 0x8387
cmpl $0x429, -0x34(%rbp)     # imm = 0x429
je 0x832b
leaq 0x8e32(%rip), %rax      # 0x11140
addq $0x1f4, %rax            # imm = 0x1F4
cmpq %rax, 0x9565(%rip)      # 0x11880
jbe 0x832b
xorl %esi, %esi
movl %esi, %edi
callq 0x89a0
jmp 0x8090
cmpl $0x0, -0x38(%rbp)
je 0x8369
movq 0x9548(%rip), %rax      # 0x11880
movq %rax, %rcx
addq $0x2, %rcx
movq %rcx, 0x953a(%rip)      # 0x11880
movw $0x155, (%rax)          # imm = 0x155
movl -0x3c(%rbp), %eax
movw %ax, %cx
movq 0x9528(%rip), %rax      # 0x11880
movq %rax, %rdx
addq $0x2, %rdx
movq %rdx, 0x951a(%rip)      # 0x11880
movw %cx, (%rax)
movl -0x34(%rbp), %eax
movw %ax, %cx
movq 0x950a(%rip), %rax      # 0x11880
movq %rax, %rdx
addq $0x2, %rdx
movq %rdx, 0x94fc(%rip)      # 0x11880
movw %cx, (%rax)
movl -0x34(%rbp), %edi
movl -0x38(%rbp), %esi
movl -0x3c(%rbp), %edx
callq 0x84d0
jmp 0x8090
nopw (%rax,%rax)