// File: /workspace/github_c_makefile_star2_O0/michaelforney[P]cproc/pp.c
// Function: expandfunc
static void
expandfunc(struct macro *m)
{
	struct macroparam *p;
	struct macroarg *arg;
	struct array str, tok;
	size_t i, depth, paren;
	struct token *t;

	/* read macro arguments */
	paren = 0;
	depth = macrodepth;
	tok = (struct array){0};
	arg = xreallocarray(NULL, m->nparam, sizeof(*arg));
	t = rawnext();
	for (i = 0; i < m->nparam; ++i) {
		p = &m->param[i];
		if (p->flags & PARAMSTR) {
			str = (struct array){0};
			arrayaddbuf(&str, "\"", 1);
		}
		arg[i].ntoken = 0;
		for (;;) {
			if (t->kind == TEOF)
				error(&t->loc, "EOF when reading macro parameters");
			if (macrodepth <= depth) {
				/* adjust current macro depth, in case it got shallower */
				depth = macrodepth;
				if (paren == 0 && (t->kind == TRPAREN || t->kind == TCOMMA && !(p->flags & PARAMVAR)))
					break;
				switch (t->kind) {
				case TLPAREN: ++paren; break;
				case TRPAREN: --paren; break;
				}
				if (p->flags & PARAMSTR)
					stringize(&str, t);
			}
			if (p->flags & PARAMTOK && !expand(t)) {
				arrayaddbuf(&tok, t, sizeof(*t));
				++arg[i].ntoken;
			}
			t = rawnext();
		}
		if (p->flags & PARAMSTR) {
			arrayaddbuf(&str, "\"", 2);
			arg[i].str = (struct token){
				.kind = TSTRINGLIT,
				.lit = str.val,
			};
		}
		if (t->kind == TRPAREN)
			break;
		t = rawnext();
	}
	if (i + 1 < m->nparam)
		error(&t->loc, "not enough arguments for macro '%s'", m->name);
	if (t->kind != TRPAREN)
		error(&t->loc, "too many arguments for macro '%s'", m->name);
	for (i = 0, t = tok.val; i < m->nparam; ++i) {
		arg[i].token = t;
		t += arg[i].ntoken;
	}
	m->arg = arg;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq $0x0, -0x60(%rbp)
movq 0x13812(%rip), %rax     # 0x220d0
movq %rax, -0x58(%rbp)
leaq -0x80(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x3110
movq -0x80(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
xorl %eax, %eax
movl %eax, %edi
movl $0x38, %edx
callq 0x12760
movq %rax, -0x18(%rbp)
callq 0xd5d0
movq %rax, -0x68(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jae 0xeb70
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x50(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xe996
leaq -0x98(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x3110
movq -0x98(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x20(%rbp)
leaq -0x30(%rbp), %rdi
leaq 0xc482(%rip), %rsi      # 0x1ae0e
movl $0x1, %edx
callq 0x12990
movq -0x18(%rbp), %rax
imulq $0x38, -0x50(%rbp), %rcx
addq %rcx, %rax
movq $0x0, 0x8(%rax)
movq -0x68(%rbp), %rax
cmpl $0x1, (%rax)
jne 0xe9c9
movq -0x68(%rbp), %rdi
addq $0x8, %rdi
leaq 0xc44e(%rip), %rsi      # 0x1ae10
movb $0x0, %al
callq 0x11190
movq 0x13700(%rip), %rax     # 0x220d0
cmpq -0x58(%rbp), %rax
ja 0xea6a
movq 0x136ef(%rip), %rax     # 0x220d0
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0xea12
movq -0x68(%rbp), %rax
cmpl $0x43, (%rax)
je 0xea0d
movq -0x68(%rbp), %rax
cmpl $0x6e, (%rax)
jne 0xea12
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0xea12
jmp 0xeabe
movq -0x68(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xc4(%rbp)
subl $0x42, %eax
je 0xea32
jmp 0xea25
movl -0xc4(%rbp), %eax
subl $0x43, %eax
je 0xea40
jmp 0xea4c
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0xea4c
movq -0x60(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xea68
movq -0x68(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xec40
jmp 0xea6a
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xeab0
movq -0x68(%rbp), %rdi
callq 0xd610
testb $0x1, %al
jne 0xeab0
movq -0x68(%rbp), %rsi
leaq -0x48(%rbp), %rdi
movl $0x28, %edx
callq 0x12990
movq -0x18(%rbp), %rax
imulq $0x38, -0x50(%rbp), %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rax)
callq 0xd5d0
movq %rax, -0x68(%rbp)
jmp 0xe9aa
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xeb4b
leaq -0x30(%rbp), %rdi
leaq 0xc336(%rip), %rsi      # 0x1ae0e
movl $0x2, %edx
callq 0x12990
movq -0x18(%rbp), %rax
imulq $0x38, -0x50(%rbp), %rcx
addq %rcx, %rax
addq $0x10, %rax
movq %rax, -0xd0(%rbp)
movl $0x7, -0xc0(%rbp)
movb $0x0, -0xbc(%rbp)
movb $0x0, -0xbb(%rbp)
leaq -0xc0(%rbp), %rdi
addq $0x8, %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x3110
movq -0xd0(%rbp), %rdi
movq -0x30(%rbp), %rax
movq %rax, -0xa0(%rbp)
leaq -0xc0(%rbp), %rsi
movl $0x28, %edx
callq 0x3190
movq -0x68(%rbp), %rax
cmpl $0x43, (%rax)
jne 0xeb56
jmp 0xeb70
callq 0xd5d0
movq %rax, -0x68(%rbp)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0xe915
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq -0x8(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jae 0xeba0
movq -0x68(%rbp), %rdi
addq $0x8, %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0xc299(%rip), %rsi      # 0x1ae32
movb $0x0, %al
callq 0x11190
movq -0x68(%rbp), %rax
cmpl $0x43, (%rax)
je 0xebc7
movq -0x68(%rbp), %rdi
addq $0x8, %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0xc296(%rip), %rsi      # 0x1ae56
movb $0x0, %al
callq 0x11190
movq $0x0, -0x50(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x50(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jae 0xec22
movq -0x68(%rbp), %rcx
movq -0x18(%rbp), %rax
imulq $0x38, -0x50(%rbp), %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
imulq $0x38, -0x50(%rbp), %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
imulq $0x28, %rax, %rax
addq -0x68(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0xebd7
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x28(%rax)
addq $0xd0, %rsp
popq %rbp
retq
nopw (%rax,%rax)