// File: /workspace/github_c_makefile_star2_O0/michaelforney[P]cproc/pp.c
// Function: define
static void
define(void)
{
	struct token *t;
	enum tokenkind prev;
	struct macro *m;
	struct macroparam *p;
	struct array params = {0}, repl = {0};
	struct mapkey k;
	void **entry;
	size_t i;

	m = xmalloc(sizeof(*m));
	m->name = tokencheck(&tok, TIDENT, "after #define");
	m->hide = false;
	t = arrayadd(&repl, sizeof(*t));
	scan(t);
	if (t->kind == TLPAREN && !t->space) {
		m->kind = MACROFUNC;
		/* read macro parameter names */
		p = NULL;
		while (scan(&tok), tok.kind != TRPAREN) {
			if (p) {
				if (p->flags & PARAMVAR)
					tokencheck(&tok, TRPAREN, "after '...'");
				tokencheck(&tok, TCOMMA, "or ')' after macro parameter");
				scan(&tok);
			}
			p = arrayadd(&params, sizeof(*p));
			p->flags = 0;
			if (tok.kind == TELLIPSIS) {
				p->name = "__VA_ARGS__";
				p->flags |= PARAMVAR;
			} else {
				p->name = tokencheck(&tok, TIDENT, "of macro parameter name or '...'");
			}
		}
		scan(t);  /* first token in replacement list */
	} else {
		m->kind = MACROOBJ;
	}
	m->param = params.val;
	m->nparam = params.len / sizeof(m->param[0]);

	/* read macro body */
	i = macroparam(m, t);
	while (t->kind != TNEWLINE && t->kind != TEOF) {
		if (t->kind == THASHHASH)
			error(&t->loc, "'##' operator is not yet implemented");
		prev = t->kind;
		t = arrayadd(&repl, sizeof(*t));
		scan(t);
		if (t->kind == TIDENT && strcmp(t->lit, "__VA_ARGS__") == 0 && !macrovarargs(m))
			error(&t->loc, "__VA_ARGS__ can only be used in variadic function-like macros");
		if (m->kind != MACROFUNC)
			continue;
		if (i != -1)
			m->param[i].flags |= PARAMTOK;
		i = macroparam(m, t);
		if (prev == THASH) {
			tokencheck(t, TIDENT, "after '#' operator");
			if (i == -1)
				error(&t->loc, "'%s' is not a macro parameter name", t->lit);
			m->param[i].flags |= PARAMSTR;
			i = -1;
		}
	}
	m->token = repl.val;
	m->ntoken = repl.len / sizeof(*t) - 1;
	tok = *t;

	mapkey(&k, m->name, strlen(m->name));
	entry = mapput(&macros, &k);
	if (*entry && !macroequal(m, *entry))
		error(&tok.loc, "redefinition of macro '%s'", m->name);
	*entry = m;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x3110
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x3110
movl $0x40, %edi
callq 0x127c0
movq %rax, -0x18(%rbp)
leaq 0x140a8(%rip), %rdi     # 0x221a8
movl $0x4, %esi
leaq 0xcbdd(%rip), %rdx      # 0x1ace9
callq 0x10f20
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movb $0x0, 0x10(%rax)
leaq -0x50(%rbp), %rdi
movl $0x28, %esi
callq 0x12870
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0xefb0
movq -0x8(%rbp), %rax
cmpl $0x42, (%rax)
jne 0xe252
movq -0x8(%rbp), %rax
testb $0x1, 0x5(%rax)
jne 0xe252
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
movq $0x0, -0x20(%rbp)
leaq 0x14035(%rip), %rdi     # 0x221a8
callq 0xefb0
leaq 0x14029(%rip), %rax     # 0x221a8
cmpl $0x43, (%rax)
je 0xe247
cmpq $0x0, -0x20(%rbp)
je 0xe1da
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0xe1b6
leaq 0x14003(%rip), %rdi     # 0x221a8
movl $0x43, %esi
leaq 0xcb46(%rip), %rdx      # 0x1acf7
callq 0x10f20
leaq 0x13feb(%rip), %rdi     # 0x221a8
movl $0x6e, %esi
leaq 0xcb3a(%rip), %rdx      # 0x1ad03
callq 0x10f20
leaq 0x13fd3(%rip), %rdi     # 0x221a8
callq 0xefb0
leaq -0x38(%rbp), %rdi
movl $0x10, %esi
callq 0x12870
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl $0x0, 0x8(%rax)
leaq 0x13faa(%rip), %rax     # 0x221a8
cmpl $0x62, (%rax)
jne 0xe220
movq -0x20(%rbp), %rax
leaq 0xcb12(%rip), %rcx      # 0x1ad20
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movl 0x8(%rax), %ecx
orl $0x4, %ecx
movl %ecx, 0x8(%rax)
jmp 0xe242
leaq 0x13f81(%rip), %rdi     # 0x221a8
movl $0x4, %esi
leaq 0xcaf9(%rip), %rdx      # 0x1ad2c
callq 0x10f20
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0xe16c
movq -0x8(%rbp), %rdi
callq 0xefb0
jmp 0xe25c
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x30(%rbp), %rcx
shrq $0x4, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0xdc50
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rcx
xorl %eax, %eax
cmpl $0x2, (%rcx)
movb %al, -0x79(%rbp)
je 0xe2a4
movq -0x8(%rbp), %rax
cmpl $0x1, (%rax)
setne %al
movb %al, -0x79(%rbp)
movb -0x79(%rbp), %al
testb $0x1, %al
jne 0xe2b0
jmp 0xe3e3
movq -0x8(%rbp), %rax
cmpl $0x70, (%rax)
jne 0xe2cf
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
leaq 0xca85(%rip), %rsi      # 0x1ad4d
movb $0x0, %al
callq 0x11190
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xc(%rbp)
leaq -0x50(%rbp), %rdi
movl $0x28, %esi
callq 0x12870
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0xefb0
movq -0x8(%rbp), %rax
cmpl $0x4, (%rax)
jne 0xe338
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
leaq 0xca15(%rip), %rsi      # 0x1ad20
callq 0x3160
cmpl $0x0, %eax
jne 0xe338
movq -0x18(%rbp), %rdi
callq 0xe570
testb $0x1, %al
jne 0xe338
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
leaq 0xca41(%rip), %rsi      # 0x1ad72
movb $0x0, %al
callq 0x11190
movq -0x18(%rbp), %rax
cmpl $0x1, (%rax)
je 0xe346
jmp 0xe289
cmpq $-0x1, -0x78(%rbp)
je 0xe369
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
orl $0x1, %ecx
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0xdc50
movq %rax, -0x78(%rbp)
cmpl $0x6f, -0xc(%rbp)
jne 0xe3de
movq -0x8(%rbp), %rdi
movl $0x4, %esi
leaq 0xca20(%rip), %rdx      # 0x1adb0
callq 0x10f20
cmpq $-0x1, -0x78(%rbp)
jne 0xe3ba
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdx
leaq 0xca10(%rip), %rsi      # 0x1adc3
movb $0x0, %al
callq 0x11190
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
orl $0x2, %ecx
movl %ecx, 0x8(%rax)
movq $-0x1, -0x78(%rbp)
jmp 0xe289
movq -0x50(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x48(%rbp), %rax
movl $0x28, %ecx
xorl %edx, %edx
divq %rcx
movq %rax, %rcx
subq $0x1, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x8(%rbp), %rsi
leaq 0x13d91(%rip), %rdi     # 0x221a8
movl $0x28, %edx
callq 0x3190
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x30a0
movq -0x88(%rbp), %rsi
movq %rax, %rdx
leaq -0x68(%rbp), %rdi
callq 0xcf70
leaq 0x13c11(%rip), %rdi     # 0x22068
leaq -0x68(%rbp), %rsi
callq 0xd190
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpq $0x0, (%rax)
je 0xe4a3
movq -0x18(%rbp), %rdi
movq -0x70(%rbp), %rax
movq (%rax), %rsi
callq 0xe5d0
testb $0x1, %al
jne 0xe4a3
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x13d17(%rip), %rdi     # 0x221a8
addq $0x8, %rdi
leaq 0xc94a(%rip), %rsi      # 0x1ade6
movb $0x0, %al
callq 0x11190
movq -0x18(%rbp), %rcx
movq -0x70(%rbp), %rax
movq %rcx, (%rax)
addq $0x90, %rsp
popq %rbp
retq
nopw (%rax,%rax)