// File: /workspace/github_c_makefile_star2_O3/mist64[P]cbm6502asm/src/line.c
// Function: macsubst
void macsubst(char *parm, char *arg, char *subbed) { /* substitute macro args for parms */
	int angleb, dif, i, j, k, la, lp, ll;
	la = strlen(arg);
	lp = strlen(parm);
	ll = strlen(line);
	angleb = (arg[0] == '<') && (arg[la - 1] == '>'); /* is arg in <> ? */
	for (i = 0; i <= ll - lp; i++) {
		if (strncmp(&line[i], parm, lp)) /* search for parms */
			continue;                /* no match */
		for (k = j = 0; !j && k < lp; k++)
			j |= subbed[k + i]; /* test if part of recent subs */
		if (j) continue;            /* don't replace if part of sub */
		dif = la - lp;              /* length diff of parm and arg */
		dif -= 2 * angleb;          /* 2 less if angle brackets */
		if (dif > 0)
			for (j = strlen(line) + dif + 1; j > i;
			     j--) { /* arg is longer than parm */
				line[j] = line[j - dif]; /* shift line */
				subbed[j] =
				        subbed[j - dif]; /* and sub'd flags */
			}
		if (dif < 0)
			for (j = i; j < strlen(line) + dif + 1;
			     j++) { /* parm is longer than arg */
				line[j] = line[j - dif]; /* shift line */
				subbed[j] =
				        subbed[j - dif]; /* and sub's flags */
			}

		for (j = angleb; j < la - angleb;
		     i++, j++) {           /* subst arg for parm */
			subbed[i] = 1;     /* substitution made */
			line[i] = arg[j];  /* insert arg */
			ll = strlen(line); /* line length may have changed */
		}
		i--; /* will be incremented by for */
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, %rbp
movq %rsi, %r13
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x10b0
movq %rax, %r14
movq %rbx, 0x60(%rsp)
movq %rbx, %rdi
callq 0x10b0
movq %rax, 0x10(%rsp)
leaq 0x8c8a(%rip), %rdi      # 0xe0b0
callq 0x10b0
movq %rax, 0x28(%rsp)
movq $0x0, 0x18(%rsp)
cmpb $0x3c, (%r13)
jne 0x5456
leal -0x1(%r14), %eax
cltq
xorl %ecx, %ecx
cmpb $0x3e, (%r13,%rax)
sete %cl
movq %rcx, 0x18(%rsp)
movq 0x28(%rsp), %rax
cmpl 0x10(%rsp), %eax
leaq 0x8c4a(%rip), %rdi      # 0xe0b0
jl 0x5654
movq 0x10(%rsp), %rax
movslq %eax, %r15
movq 0x18(%rsp), %rcx
leal (%rax,%rcx,2), %eax
movl %r14d, %edx
subl %eax, %edx
negl %eax
addl %r14d, %eax
incl %eax
movl %eax, 0x34(%rsp)
movl %edx, 0xc(%rsp)
movslq %edx, %rax
leaq 0x1(%rax), %rdx
subl %ecx, %r14d
movl %ecx, %ecx
movq %rdi, %rsi
subq %rax, %rsi
movq %rsi, 0x40(%rsp)
movq %rbp, %rsi
subq %rax, %rsi
movq %rsi, 0x20(%rsp)
addq %rcx, %r13
movq %r14, 0x58(%rsp)
subq %rcx, %r14
movq %r14, 0x48(%rsp)
xorl %r14d, %r14d
movq %r13, 0x50(%rsp)
movq %rdx, 0x38(%rsp)
movslq %r14d, %rbx
leaq (%rbx,%rdi), %r12
movq %r12, %rdi
movq 0x60(%rsp), %rsi
movq %r15, %rdx
callq 0x1070
testl %eax, %eax
je 0x54f6
leaq 0x8bbf(%rip), %rdi      # 0xe0b0
jmp 0x563b
cmpl $0x0, 0x10(%rsp)
leaq 0x8bae(%rip), %rdi      # 0xe0b0
jle 0x5529
leaq (%rbx,%rbp), %rax
movl $0x1, %ecx
movb -0x1(%rax,%rcx), %dl
testb %dl, %dl
jne 0x5521
leaq 0x1(%rcx), %rsi
cmpq %r15, %rcx
movq %rsi, %rcx
jl 0x550d
testb %dl, %dl
jne 0x563b
cmpl $0x0, 0xc(%rsp)
movq 0x40(%rsp), %r13
jle 0x557f
leaq 0x8b74(%rip), %rdi      # 0xe0b0
callq 0x10b0
movq 0x20(%rsp), %rdx
leaq 0x8b63(%rip), %rdi      # 0xe0b0
addl 0x34(%rsp), %eax
cmpl %r14d, %eax
movq %r13, %rcx
movq %rbp, %r13
jle 0x55e6
cltq
movq %r13, %rbp
movq %rcx, %r13
movb (%r13,%rax), %cl
movb %cl, (%rdi,%rax)
movb (%rdx,%rax), %cl
movb %cl, (%rbp,%rax)
decq %rax
cmpq %rbx, %rax
jg 0x5568
cmpl $0x0, 0xc(%rsp)
movq %rbp, %r13
jns 0x55e6
leaq 0x8b20(%rip), %rdi      # 0xe0b0
callq 0x10b0
movq 0x20(%rsp), %rcx
leaq 0x8b0f(%rip), %rdi      # 0xe0b0
addq 0x38(%rsp), %rax
cmpq %rbx, %rax
jbe 0x55e6
movq %rbx, %rbp
movq 0x40(%rsp), %rax
movb (%rax,%rbp), %al
movb %al, (%rdi,%rbp)
movb (%rcx,%rbp), %al
movb %al, (%r13,%rbp)
incq %rbp
leaq 0x8ae5(%rip), %rdi      # 0xe0b0
callq 0x10b0
movq 0x20(%rsp), %rcx
leaq 0x8ad4(%rip), %rdi      # 0xe0b0
addq 0x38(%rsp), %rax
cmpq %rbp, %rax
ja 0x55ae
movq 0x18(%rsp), %rax
cmpl 0x58(%rsp), %eax
jge 0x5635
movq %r13, %rbp
addq %r13, %rbx
xorl %eax, %eax
movq 0x50(%rsp), %r13
movq 0x48(%rsp), %rdx
movb $0x1, (%rbx,%rax)
movb (%r13,%rax), %cl
movb %cl, (%r12,%rax)
incq %rax
cmpq %rax, %rdx
jne 0x5603
addl %eax, %r14d
leaq 0x8a8e(%rip), %rdi      # 0xe0b0
callq 0x10b0
leaq 0x8a82(%rip), %rdi      # 0xe0b0
movq %rax, 0x28(%rsp)
jmp 0x5638
movq %r13, %rbp
decl %r14d
leal 0x1(%r14), %eax
movq 0x28(%rsp), %rcx
subl 0x10(%rsp), %ecx
cmpl %ecx, %r14d
movl %eax, %r14d
jl 0x54cf
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq