// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/crossassemblers/macro8x/macro8x.c
// Function: copyMacLine
int copyMacLine( int length, int from, int term, int nargs )
{
  char    name[SYMLEN];
  int     ix;
  int     jx;
  int     kx;
  BOOL    bl;

  bl = TRUE;
  for( ix = from; ix < term; ix++ )
  {
    if( !is_blank( line[ix] )) bl = FALSE;
  }
  if( bl || ( length < 0 )) return length;
  if(( length + term - from + 1) >= MAC_MAX_LENGTH ) return -1;
  for( ix = from; ix < term; )
  {
    if( nargs && isalpha( line[ix] ))      /* Start of symbol?                */
    {
      for( jx = ix + 1; jx < term; jx++)   /* Find end of symbol.             */
      {
        if( !isalnum( line[jx] )) break;
      }
      lexemeToName( name, ix, jx );        /* Make into name.                 */
      for( kx = 0; kx < nargs; kx++ )      /* Compare to arguments.           */
      {
        if( strncmp( name, &mac_arg_name[kx + 1][0], SYMLEN ) == 0 )
        {
           mac_buffer[length++] = 'a' + (char) kx;
           for( ix++; ix < jx; ix++ )
           {
             mac_buffer[length++] = 'z';
           }
           break;
        } /* end if strncmp                                                   */
      } /* end for kx                                                         */
      if( kx >= nargs )
      {
        for ( ; ix < jx; )
        {
          mac_buffer[length++] = toupper( line[ix++] );
		}
      }
    } /*end if nargs                                                          */
    else
    {
      mac_buffer[length++] = toupper( line[ix++] );
    } /* end else                                                            */
  } /* end for ix                                                            */
  mac_buffer[length++] = '\n';
  mac_buffer[length] = 0;
  return length;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, %r13d
movl %esi, %r15d
movl %edi, %ebp
movslq %esi, %rax
movl %edx, 0x4(%rsp)
movslq %edx, %rdi
movb $0x1, %cl
leaq 0x8296(%rip), %r12      # 0xe0f0
movabsq $0x4000000100001200, %rdx # imm = 0x4000000100001200
cmpq %rdi, %rax
jge 0x5e83
movzbl (%rax,%r12), %esi
cmpq $0x3e, %rsi
ja 0x5e7f
btq %rsi, %rdx
jae 0x5e7f
incq %rax
jmp 0x5e64
xorl %ecx, %ecx
jmp 0x5e7a
testb %cl, %cl
setne %al
testl %ebp, %ebp
sets %cl
orb %al, %cl
jne 0x6052
movl %ebp, %eax
subl %r15d, %eax
addl 0x4(%rsp), %eax
cmpl $0x1ffe, %eax           # imm = 0x1FFE
jle 0x5ead
pushq $-0x1
popq %rbp
jmp 0x6052
movq %rdi, 0x28(%rsp)
movslq %r13d, %rax
xorl %ecx, %ecx
movq %rax, 0x20(%rsp)
testl %eax, %eax
cmovgl %r13d, %ecx
movq %rcx, 0x30(%rsp)
movq %rbp, %rax
movl %r13d, 0x8(%rsp)
movl %eax, %r14d
cmpl 0x4(%rsp), %r15d
movq %rax, %rbp
jge 0x6042
movslq %r15d, %rbx
testl %r13d, %r13d
je 0x5f33
callq 0x2190
movq (%rax), %rax
movsbq (%rbx,%r12), %r12
testb $0x4, 0x1(%rax,%r12,2)
je 0x5f38
movq %rbp, 0x10(%rsp)
leal 0x1(%r15), %ecx
movl %ecx, 0xc(%rsp)
incq %rbx
movl %r15d, %ebp
movq 0x28(%rsp), %rdx
leaq 0x81d4(%rip), %rsi      # 0xe0f0
cmpq %rdx, %rbx
jge 0x5f63
movsbq (%rbx,%rsi), %rcx
incl %ebp
incq %rbx
testb $0x8, (%rax,%rcx,2)
jne 0x5f1c
jmp 0x5f67
movsbq (%rbx,%r12), %r12
callq 0x2030
movq (%rax), %rax
incl %r15d
movb (%rax,%r12,4), %al
incl %ebp
leaq 0x8830(%rip), %rcx      # 0xe780
movb %al, (%r14,%rcx)
leaq 0x8195(%rip), %r12      # 0xe0f0
movq %rbp, %rax
jmp 0x5ecf
movl 0x4(%rsp), %ebp
leaq 0x19(%rsp), %rdi
movl %r15d, %esi
movl %ebp, %edx
callq 0x3d7d
leaq 0x877a(%rip), %rbx      # 0xe6f7
xorl %r13d, %r13d
movq %r13, %r12
cmpq %r13, 0x30(%rsp)
je 0x5fd9
leaq 0x1(%r12), %r13
leaq 0x19(%rsp), %rdi
movq %rbx, %rsi
pushq $0x7
popq %rdx
callq 0x2070
addq $0x7, %rbx
testl %eax, %eax
jne 0x5f80
addb $0x60, %r13b
leaq 0x87ce(%rip), %rax      # 0xe780
movb %r13b, (%r14,%rax)
movl 0xc(%rsp), %edx
movl %edx, %eax
movl 0x8(%rsp), %r13d
cmpl %ebp, %eax
jge 0x5fe0
leaq 0x87b4(%rip), %rcx      # 0xe780
movb $0x7a, 0x1(%r14,%rcx)
incl %eax
incq %r14
jmp 0x5fc1
movl 0x8(%rsp), %r13d
jmp 0x5ff0
cmpl %edx, %ebp
cmovgl %ebp, %edx
incl %r14d
movl %edx, %r15d
movq %r14, 0x10(%rsp)
cmpq 0x20(%rsp), %r12
leaq 0x80f4(%rip), %r12      # 0xe0f0
movq 0x10(%rsp), %rax
jl 0x5ecf
movslq %r15d, %r15
movslq %ebp, %rbx
movl %eax, %eax
movq %rax, %r14
cmpq %rbx, %r15
jge 0x603a
callq 0x2030
movq (%rax), %rax
movsbq (%r15,%r12), %rcx
incq %r15
movb (%rax,%rcx,4), %al
leaq 0x874f(%rip), %rcx      # 0xe780
movb %al, (%r14,%rcx)
incq %r14
jmp 0x6012
movq %r14, %rax
jmp 0x5ecf
incl %ebp
leaq 0x8735(%rip), %rax      # 0xe780
movw $0xa, (%r14,%rax)
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq