// File: /workspace/github_c_makefile_star2_O1/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, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x10b0
movq %rax, %r12
movq %rbx, 0x60(%rsp)
movq %rbx, %rdi
callq 0x10b0
movq %rax, 0x10(%rsp)
leaq 0x8d12(%rip), %rdi      # 0xe0b0
callq 0x10b0
movq %rax, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
cmpb $0x3c, (%r14)
jne 0x53cd
leal -0x1(%r12), %eax
cltq
xorl %ecx, %ecx
cmpb $0x3e, (%r14,%rax)
sete %cl
movq %rcx, 0x18(%rsp)
movq 0x20(%rsp), %rax
cmpl 0x10(%rsp), %eax
leaq 0x8cd3(%rip), %rdi      # 0xe0b0
jl 0x55bd
movq 0x10(%rsp), %rax
movslq %eax, %r15
movq 0x18(%rsp), %rcx
leal (%rax,%rcx,2), %eax
movl %r12d, %edx
subl %eax, %edx
negl %eax
addl %r12d, %eax
incl %eax
movl %eax, 0x34(%rsp)
movl %edx, 0xc(%rsp)
movslq %edx, %rax
leaq 0x1(%rax), %rdx
subl %ecx, %r12d
movl %ecx, %ecx
movq %rdi, %rsi
subq %rax, %rsi
movq %rsi, 0x40(%rsp)
movq %rbp, %rsi
subq %rax, %rsi
addq %rcx, %r14
movq %r12, 0x58(%rsp)
subq %rcx, %r12
movq %r12, 0x48(%rsp)
xorl %r13d, %r13d
movq %r14, 0x50(%rsp)
movq %rdx, 0x38(%rsp)
movq %rsi, 0x28(%rsp)
movslq %r13d, %rbx
leaq (%rbx,%rdi), %r12
movq %r12, %rdi
movq 0x60(%rsp), %rsi
movq %r15, %rdx
callq 0x1070
testl %eax, %eax
je 0x546d
leaq 0x8c48(%rip), %rdi      # 0xe0b0
jmp 0x55a4
cmpl $0x0, 0x10(%rsp)
leaq 0x8c37(%rip), %rdi      # 0xe0b0
jle 0x54a2
movslq %r13d, %rax
addq %rbp, %rax
movl $0x1, %ecx
movb -0x1(%rax,%rcx), %dl
testb %dl, %dl
jne 0x549a
leaq 0x1(%rcx), %rsi
cmpq %r15, %rcx
movq %rsi, %rcx
jl 0x5486
testb %dl, %dl
jne 0x55a4
cmpl $0x0, 0xc(%rsp)
movq 0x40(%rsp), %r14
jle 0x54ea
leaq 0x8bfb(%rip), %rdi      # 0xe0b0
callq 0x10b0
movq 0x28(%rsp), %rsi
leaq 0x8bea(%rip), %rdi      # 0xe0b0
addl 0x34(%rsp), %eax
cmpl %r13d, %eax
jle 0x54ea
cltq
movslq %r13d, %rcx
movb (%r14,%rax), %dl
movb %dl, (%rdi,%rax)
movb (%rsi,%rax), %dl
movb %dl, (%rbp,%rax)
decq %rax
cmpq %rcx, %rax
jg 0x54d4
cmpl $0x0, 0xc(%rsp)
movq %rbp, %r14
jns 0x5550
leaq 0x8bb5(%rip), %rdi      # 0xe0b0
callq 0x10b0
movq 0x28(%rsp), %rsi
leaq 0x8ba4(%rip), %rdi      # 0xe0b0
addq 0x38(%rsp), %rax
cmpq %rbx, %rax
jbe 0x5550
movq %rbx, %rbp
movq 0x40(%rsp), %rax
movb (%rax,%rbp), %al
movb %al, (%rdi,%rbp)
movb (%rsi,%rbp), %al
movb %al, (%r14,%rbp)
incq %rbp
leaq 0x8b7b(%rip), %rdi      # 0xe0b0
callq 0x10b0
movq 0x28(%rsp), %rsi
leaq 0x8b6a(%rip), %rdi      # 0xe0b0
addq 0x38(%rsp), %rax
cmpq %rbp, %rax
ja 0x5519
movq 0x18(%rsp), %rax
cmpl 0x58(%rsp), %eax
jge 0x559e
movq %r14, %rbp
addq %r14, %rbx
xorl %eax, %eax
movq 0x50(%rsp), %r14
movq 0x48(%rsp), %rdx
movb $0x1, (%rbx,%rax)
movb (%r14,%rax), %cl
movb %cl, (%r12,%rax)
incq %rax
cmpq %rax, %rdx
jne 0x556d
addl %eax, %r13d
leaq 0x8b25(%rip), %rdi      # 0xe0b0
callq 0x10b0
leaq 0x8b19(%rip), %rdi      # 0xe0b0
movq %rax, 0x20(%rsp)
jmp 0x55a1
movq %r14, %rbp
decl %r13d
leal 0x1(%r13), %eax
movq 0x20(%rsp), %rcx
subl 0x10(%rsp), %ecx
cmpl %ecx, %r13d
movl %eax, %r13d
jl 0x5446
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq