// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movl %ecx, %ebp
movl %edx, %r14d
movl %esi, %r15d
movl %edi, %ebx
movb $0x1, %al
cmpl %edx, %esi
jge 0x6724
movslq %r15d, %rax
movslq %r14d, %rcx
movb $0x1, %dl
leaq 0x79fa(%rip), %rsi      # 0xe0f0
movabsq $0x4000000100001200, %rdi # imm = 0x4000000100001200
movzbl (%rax,%rsi), %r8d
cmpq $0x3e, %r8
ja 0x671b
btq %r8, %rdi
jae 0x671b
incq %rax
cmpq %rax, %rcx
jne 0x6700
jmp 0x671f
xorl %edx, %edx
jmp 0x6711
testb %dl, %dl
setne %al
testl %ebx, %ebx
sets %cl
orb %al, %cl
jne 0x6925
movl %ebx, %ecx
subl %r15d, %ecx
addl %r14d, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl $0x1ffe, %ecx           # imm = 0x1FFE
jg 0x6927
cmpl %r14d, %r15d
jge 0x6914
movslq %ebp, %rax
xorl %r12d, %r12d
movq %rax, 0x18(%rsp)
testl %eax, %eax
cmovgl %ebp, %r12d
leaq 0x7985(%rip), %r13      # 0xe0f0
movl %ebp, 0x10(%rsp)
movl %r14d, 0xc(%rsp)
movslq %r15d, %r14
testl %ebp, %ebp
je 0x678f
callq 0x2190
movq (%rax), %rax
movsbq (%r14,%r13), %rcx
testb $0x4, 0x1(%rax,%rcx,2)
jne 0x67bf
callq 0x2030
movq (%rax), %rax
incl %r15d
movsbq (%r14,%r13), %rcx
movb (%rax,%rcx,4), %al
movl %ebx, %ecx
incl %ebx
leaq 0x7fd3(%rip), %rdx      # 0xe780
movb %al, (%rcx,%rdx)
movl 0xc(%rsp), %r14d
cmpl %r14d, %r15d
jl 0x6774
jmp 0x6914
leal 0x1(%r15), %edi
movl %edi, %r13d
movl 0xc(%rsp), %esi
cmpl %esi, %edi
jge 0x67f6
movslq %edi, %rcx
leaq 0x7918(%rip), %rdx      # 0xe0f0
addq %rdx, %rcx
movl %edi, %r13d
movsbq (%rcx), %rdx
testb $0x8, (%rax,%rdx,2)
je 0x67f6
incl %r13d
incq %rcx
cmpl %r13d, %esi
jne 0x67de
movl %esi, %r13d
movl %edi, 0x14(%rsp)
leaq 0x21(%rsp), %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x3fd8
leaq 0x7ee6(%rip), %rbp      # 0xe6f7
xorl %r14d, %r14d
cmpq %r14, %r12
je 0x6896
incq %r14
movl $0x7, %edx
leaq 0x21(%rsp), %rdi
movq %rbp, %rsi
callq 0x2070
addq $0x7, %rbp
testl %eax, %eax
jne 0x6814
leaq -0x1(%r14), %rax
cmpq 0x18(%rsp), %rax
setge %bpl
movl %ebx, %eax
addb $0x60, %r14b
leaq 0x7f30(%rip), %rcx      # 0xe780
movb %r14b, (%rax,%rcx)
leal 0x1(%rbx), %eax
movl 0x14(%rsp), %edx
cmpl %r13d, %edx
jge 0x68a1
movl %eax, %edi
addq %rcx, %rdi
movl %r13d, %edx
subl %r15d, %edx
addl $-0x2, %edx
incq %rdx
movl $0x7a, %esi
callq 0x20d0
subl %r13d, %r15d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl 0xc(%rsp), %r14d
decl %eax
cmpl %eax, %r15d
jne 0x6888
subl %eax, %ebx
movl %r13d, %r15d
jmp 0x68ab
cmpq 0x18(%rsp), %r14
setge %bpl
jmp 0x68a6
movl %edx, %r15d
movl %eax, %ebx
movl 0xc(%rsp), %r14d
testb %bpl, %bpl
je 0x6904
cmpl %r13d, %r15d
movl 0x10(%rsp), %ebp
jge 0x6908
callq 0x2030
leaq 0x7ebb(%rip), %r9       # 0xe780
movl %ebx, %ebx
movslq %r15d, %rdx
movslq %r13d, %rsi
subq %rdx, %rsi
xorl %ecx, %ecx
leaq 0x7817(%rip), %r13      # 0xe0f0
movq (%rax), %rdi
leaq (%rdx,%rcx), %r8
movsbq (%r13,%r8), %r8
movb (%rdi,%r8,4), %dil
leaq (%rbx,%rcx), %r8
movb %dil, (%r9,%r8)
incq %rcx
cmpq %rcx, %rsi
jne 0x68d9
addl %ecx, %r15d
addl %ecx, %ebx
jmp 0x67b5
movl 0x10(%rsp), %ebp
leaq 0x77e1(%rip), %r13      # 0xe0f0
jmp 0x67b5
movl %ebx, %eax
incl %ebx
leaq 0x7e61(%rip), %rcx      # 0xe780
movw $0xa, (%rax,%rcx)
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq