// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x10a0
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0x10a0
movl %eax, -0x34(%rbp)
leaq 0x9b8d(%rip), %rdi      # 0x110a0
callq 0x10a0
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x3c, %ecx
movb %al, -0x39(%rbp)
jne 0x7546
movq -0x10(%rbp), %rax
movl -0x30(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3e, %eax
sete %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x1c(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl -0x38(%rbp), %ecx
subl -0x34(%rbp), %ecx
cmpl %ecx, %eax
jg 0x7762
movslq -0x24(%rbp), %rax
leaq 0x9b2c(%rip), %rdi      # 0x110a0
addq %rax, %rdi
movq -0x8(%rbp), %rsi
movslq -0x34(%rbp), %rdx
callq 0x1060
cmpl $0x0, %eax
je 0x758e
jmp 0x7754
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x28(%rbp)
movb %al, -0x3a(%rbp)
jne 0x75b3
movl -0x2c(%rbp), %eax
cmpl -0x34(%rbp), %eax
setl %al
movb %al, -0x3a(%rbp)
movb -0x3a(%rbp), %al
testb $0x1, %al
jne 0x75bc
jmp 0x75de
movq -0x18(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl -0x24(%rbp), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
orl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x759c
cmpl $0x0, -0x28(%rbp)
je 0x75e9
jmp 0x7754
movl -0x30(%rbp), %eax
subl -0x34(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %ecx
shll %ecx
movl -0x20(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jle 0x7670
leaq 0x9a94(%rip), %rdi      # 0x110a0
callq 0x10a0
movslq -0x20(%rbp), %rcx
addq %rcx, %rax
addq $0x1, %rax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x24(%rbp), %eax
jle 0x766e
movl -0x28(%rbp), %eax
subl -0x20(%rbp), %eax
movslq %eax, %rcx
leaq 0x9a69(%rip), %rax      # 0x110a0
movb (%rax,%rcx), %dl
movslq -0x28(%rbp), %rcx
leaq 0x9a5b(%rip), %rax      # 0x110a0
movb %dl, (%rax,%rcx)
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
subl -0x20(%rbp), %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %dl
movq -0x18(%rbp), %rax
movslq -0x28(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x28(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x761f
jmp 0x7670
cmpl $0x0, -0x20(%rbp)
jge 0x76f0
movl -0x24(%rbp), %eax
movl %eax, -0x28(%rbp)
movslq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq 0x9a15(%rip), %rdi      # 0x110a0
callq 0x10a0
movq %rax, %rcx
movq -0x48(%rbp), %rax
movslq -0x20(%rbp), %rdx
addq %rdx, %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jae 0x76ee
movl -0x28(%rbp), %eax
subl -0x20(%rbp), %eax
movslq %eax, %rcx
leaq 0x99e9(%rip), %rax      # 0x110a0
movb (%rax,%rcx), %dl
movslq -0x28(%rbp), %rcx
leaq 0x99db(%rip), %rax      # 0x110a0
movb %dl, (%rax,%rcx)
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
subl -0x20(%rbp), %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %dl
movq -0x18(%rbp), %rax
movslq -0x28(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x767c
jmp 0x76f0
movl -0x1c(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl -0x30(%rbp), %ecx
subl -0x1c(%rbp), %ecx
cmpl %ecx, %eax
jge 0x774b
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movb $0x1, (%rax,%rcx)
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movb (%rax,%rcx), %dl
movslq -0x24(%rbp), %rcx
leaq 0x997b(%rip), %rax      # 0x110a0
movb %dl, (%rax,%rcx)
leaq 0x9971(%rip), %rdi      # 0x110a0
callq 0x10a0
movl %eax, -0x38(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x76f6
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x7558
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)