// File: /workspace/github_c_makefile_star2_O0/MikeGray-APH[P]LibLouisAPH/source/compile.c
// Function: do_macro
static int do_macro(void)
{
	unichar line[INPUT_LINE_MAX], *args[MACRO_ARGUMENTS_MAX];
	int args_lens[MACRO_ARGUMENTS_MAX], args_cnt;
	struct macro *macro;
	int i, j, off, crs, arg;

	macro = token_find_macro();
	if(!macro)
	{
		log_message(LOG_ERROR, "%s:%d  macro %#S not found", table_file_names[include_depth], table_file_lines[include_depth], &token_crs[1], token_len - 1);
		return 0;
	}

	if(macro_depth + 1 >= MACRO_DEPTH_MAX)
	{
		log_message(LOG_ERROR, "%s:%d  macro %#S too deep", table_file_names[include_depth], table_file_lines[include_depth], &token_crs[1], token_len - 1);
		return 0;
	}

	if(macro->processing)
	{
		log_message(LOG_ERROR, "%s:%d  recursive macro @%s, defined at %s:%d", table_file_names[include_depth], table_file_lines[include_depth], macro->ctag, macro->file_name, macro->file_line);
		return 0;
	}
	macro->processing = 1;

	memset(args,      0, MACRO_ARGUMENTS_MAX * sizeof(unichar*));
	memset(args_lens, 0, MACRO_ARGUMENTS_MAX * sizeof(int));
	args_cnt = 0;

	while(token_parse())
	{
		if(token_crs[0] == u'#' && token_len == 1)
			break;

		args[args_cnt] = token_crs;
		args_lens[args_cnt] = token_len;

		args_cnt++;
		if(args_cnt >= MACRO_ARGUMENTS_MAX)
		{
			macro->processing = 0;
			log_message(LOG_ERROR, "%s:%d  too many args for macro @%s, defined at %s:%d", table_file_names[include_depth], table_file_lines[include_depth], macro->ctag, macro->file_name, macro->file_line);
			return 0;
		}
	}

	for(i = 0; i < macro->lines_cnt; i++)
	{
		DB_MEMSET(line, 0, INPUT_LINE_MAX * sizeof(unichar))

		/*   convert args   */
		off =
		crs = 0;
		while(off < INPUT_LINE_MAX - 1)
		{
			if(!macro->lines[i][off])
				break;
			else if(macro->lines[i][off] == u'$')
			{
				if(off + 1 >= INPUT_LINE_MAX)
				{
					line[crs++] = macro->lines[i][off++];
					continue;
				}

				off++;
				if(macro->lines[i][off] >= u'1' && macro->lines[i][off] <= u'9')
				{
					arg = 8 - (u'9' - macro->lines[i][off]);
					if(arg >= args_cnt)
					{
						macro->processing = 0;
						log_message(LOG_ERROR, "%s:%d  $%d over argument count %d for macro @%s, defined at %s:%d", table_file_names[include_depth], table_file_lines[include_depth], arg + 1, args_cnt, macro->ctag, macro->file_name, macro->file_line);
						return 0;
					}
					if(args_lens[arg] + crs >= INPUT_LINE_MAX - 2)
					{
						macro->processing = 0;
						log_message(LOG_ERROR, "%s:%d  $%d caused buffer overflow for macro @%s, defined at %s:%d", table_file_names[include_depth], table_file_lines[include_depth], arg + 1, macro->ctag, macro->file_name, macro->file_line);
						return 0;
					}
					for(j = 0; j < args_lens[arg]; j++)
						line[crs++] = args[arg][j];
					off++;
					continue;
				}
				else
					line[crs++] = u'$';

				/*   fall through to just copy character after offset   */
			}
			else if(crs < INPUT_LINE_MAX - 2)
				line[crs++] = macro->lines[i][off++];
			else
				break;
		}

		/*   add two NULL characters for parseing   */
		line[crs] =
		line[crs + 1] = 0;

		if(!token_init(line))
			continue;

		macro_depth++;
		token_compile();
		macro_depth--;
	}

	macro->processing = 0;
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20d0, %rsp           # imm = 0x20D0
callq 0x90c0
movq %rax, -0x20a0(%rbp)
cmpq $0x0, -0x20a0(%rbp)
jne 0x6409
movslq 0x1dde0(%rip), %rcx     # 0x24198
leaq 0x1de01(%rip), %rax     # 0x241c0
movq (%rax,%rcx,8), %rdx
movslq 0x1ddce(%rip), %rcx     # 0x24198
leaq 0x1ddcf(%rip), %rax     # 0x241a0
movl (%rax,%rcx,4), %ecx
movq 0x1fe2d(%rip), %r8      # 0x26208
addq $0x2, %r8
movl 0x1fe1a(%rip), %r9d     # 0x26200
subl $0x1, %r9d
movl $0x6, %edi
leaq 0x18078(%rip), %rsi     # 0x1e46e
movb $0x0, %al
callq 0xf610
movl $0x0, -0x4(%rbp)
jmp 0x6a67
movl 0x1dd85(%rip), %eax     # 0x24194
addl $0x1, %eax
cmpl $0x8, %eax
jl 0x646f
movslq 0x1dd7a(%rip), %rcx     # 0x24198
leaq 0x1dd9b(%rip), %rax     # 0x241c0
movq (%rax,%rcx,8), %rdx
movslq 0x1dd68(%rip), %rcx     # 0x24198
leaq 0x1dd69(%rip), %rax     # 0x241a0
movl (%rax,%rcx,4), %ecx
movq 0x1fdc7(%rip), %r8      # 0x26208
addq $0x2, %r8
movl 0x1fdb4(%rip), %r9d     # 0x26200
subl $0x1, %r9d
movl $0x6, %edi
leaq 0x1802d(%rip), %rsi     # 0x1e489
movb $0x0, %al
callq 0xf610
movl $0x0, -0x4(%rbp)
jmp 0x6a67
movq -0x20a0(%rbp), %rax
cmpl $0x0, 0x28(%rax)
je 0x64e1
movslq 0x1dd15(%rip), %rcx     # 0x24198
leaq 0x1dd36(%rip), %rax     # 0x241c0
movq (%rax,%rcx,8), %rdx
movslq 0x1dd03(%rip), %rcx     # 0x24198
leaq 0x1dd04(%rip), %rax     # 0x241a0
movl (%rax,%rcx,4), %ecx
movq -0x20a0(%rbp), %rax
movq 0x8(%rax), %r8
movq -0x20a0(%rbp), %rax
movq 0x30(%rax), %r9
movq -0x20a0(%rbp), %rax
movl 0x38(%rax), %eax
movl $0x6, %edi
leaq 0x17fd8(%rip), %rsi     # 0x1e4a3
movl %eax, (%rsp)
movb $0x0, %al
callq 0xf610
movl $0x0, -0x4(%rbp)
jmp 0x6a67
movq -0x20a0(%rbp), %rax
movl $0x1, 0x28(%rax)
leaq -0x2060(%rbp), %rdi
xorl %esi, %esi
movl $0x50, %edx
callq 0x1100
leaq -0x2090(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x1100
movl $0x0, -0x2094(%rbp)
callq 0x6190
cmpl $0x0, %eax
je 0x6604
movq 0x1fcd4(%rip), %rax     # 0x26208
movzwl (%rax), %eax
cmpl $0x23, %eax
jne 0x654a
cmpl $0x1, 0x1fcbd(%rip)     # 0x26200
jne 0x654a
jmp 0x6604
movq 0x1fcb7(%rip), %rcx     # 0x26208
movslq -0x2094(%rbp), %rax
movq %rcx, -0x2060(%rbp,%rax,8)
movl 0x1fc9a(%rip), %ecx     # 0x26200
movslq -0x2094(%rbp), %rax
movl %ecx, -0x2090(%rbp,%rax,4)
movl -0x2094(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2094(%rbp)
cmpl $0xa, -0x2094(%rbp)
jl 0x65ff
movq -0x20a0(%rbp), %rax
movl $0x0, 0x28(%rax)
movslq 0x1dbf7(%rip), %rcx     # 0x24198
leaq 0x1dc18(%rip), %rax     # 0x241c0
movq (%rax,%rcx,8), %rdx
movslq 0x1dbe5(%rip), %rcx     # 0x24198
leaq 0x1dbe6(%rip), %rax     # 0x241a0
movl (%rax,%rcx,4), %ecx
movq -0x20a0(%rbp), %rax
movq 0x8(%rax), %r8
movq -0x20a0(%rbp), %rax
movq 0x30(%rax), %r9
movq -0x20a0(%rbp), %rax
movl 0x38(%rax), %eax
movl $0x6, %edi
leaq 0x17ee7(%rip), %rsi     # 0x1e4d0
movl %eax, (%rsp)
movb $0x0, %al
callq 0xf610
movl $0x0, -0x4(%rbp)
jmp 0x6a67
jmp 0x651f
movl $0x0, -0x20a4(%rbp)
movl -0x20a4(%rbp), %eax
movq -0x20a0(%rbp), %rcx
cmpl 0x24(%rcx), %eax
jge 0x6a52
leaq -0x2010(%rbp), %rdi
xorl %esi, %esi
movl $0x2000, %edx           # imm = 0x2000
callq 0x1100
movl $0x0, -0x20b0(%rbp)
movl $0x0, -0x20ac(%rbp)
cmpl $0xfff, -0x20ac(%rbp)   # imm = 0xFFF
jge 0x69e2
movq -0x20a0(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x20a4(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x20ac(%rbp), %rcx
cmpw $0x0, (%rax,%rcx,2)
jne 0x6684
jmp 0x69e2
movq -0x20a0(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x20a4(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x20ac(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x24, %eax
jne 0x6980
movl -0x20ac(%rbp), %eax
addl $0x1, %eax
cmpl $0x1000, %eax           # imm = 0x1000
jl 0x670c
movq -0x20a0(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x20a4(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x20ac(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x20ac(%rbp)
movslq %ecx, %rcx
movw (%rax,%rcx,2), %cx
movl -0x20b0(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x20b0(%rbp)
cltq
movw %cx, -0x2010(%rbp,%rax,2)
jmp 0x664b
movl -0x20ac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20ac(%rbp)
movq -0x20a0(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x20a4(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x20ac(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x31, %eax
jl 0x6961
movq -0x20a0(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x20a4(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x20ac(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x39, %eax
jg 0x6961
movq -0x20a0(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x20a4(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x20ac(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
movl $0x39, %ecx
subl %eax, %ecx
movl $0x8, %eax
subl %ecx, %eax
movl %eax, -0x20b4(%rbp)
movl -0x20b4(%rbp), %eax
cmpl -0x2094(%rbp), %eax
jl 0x6845
movq -0x20a0(%rbp), %rax
movl $0x0, 0x28(%rax)
movslq 0x1d9cd(%rip), %rcx     # 0x24198
leaq 0x1d9ee(%rip), %rax     # 0x241c0
movq (%rax,%rcx,8), %rdx
movslq 0x1d9bb(%rip), %rcx     # 0x24198
leaq 0x1d9bc(%rip), %rax     # 0x241a0
movl (%rax,%rcx,4), %ecx
movl -0x20b4(%rbp), %r8d
addl $0x1, %r8d
movl -0x2094(%rbp), %r9d
movq -0x20a0(%rbp), %rax
movq 0x8(%rax), %r11
movq -0x20a0(%rbp), %rax
movq 0x30(%rax), %r10
movq -0x20a0(%rbp), %rax
movl 0x38(%rax), %eax
movl $0x6, %edi
leaq 0x17ce0(%rip), %rsi     # 0x1e505
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movb $0x0, %al
callq 0xf610
movl $0x0, -0x4(%rbp)
jmp 0x6a67
movslq -0x20b4(%rbp), %rax
movl -0x2090(%rbp,%rax,4), %eax
addl -0x20b0(%rbp), %eax
cmpl $0xffe, %eax            # imm = 0xFFE
jl 0x68e7
movq -0x20a0(%rbp), %rax
movl $0x0, 0x28(%rax)
movslq 0x1d91f(%rip), %rcx     # 0x24198
leaq 0x1d940(%rip), %rax     # 0x241c0
movq (%rax,%rcx,8), %rdx
movslq 0x1d90d(%rip), %rcx     # 0x24198
leaq 0x1d90e(%rip), %rax     # 0x241a0
movl (%rax,%rcx,4), %ecx
movl -0x20b4(%rbp), %r8d
addl $0x1, %r8d
movq -0x20a0(%rbp), %rax
movq 0x8(%rax), %r9
movq -0x20a0(%rbp), %rax
movq 0x30(%rax), %r10
movq -0x20a0(%rbp), %rax
movl 0x38(%rax), %eax
movl $0x6, %edi
leaq 0x17c7b(%rip), %rsi     # 0x1e547
movq %r10, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0xf610
movl $0x0, -0x4(%rbp)
jmp 0x6a67
movl $0x0, -0x20a8(%rbp)
movl -0x20a8(%rbp), %eax
movslq -0x20b4(%rbp), %rcx
cmpl -0x2090(%rbp,%rcx,4), %eax
jge 0x694d
movslq -0x20b4(%rbp), %rax
movq -0x2060(%rbp,%rax,8), %rax
movslq -0x20a8(%rbp), %rcx
movw (%rax,%rcx,2), %cx
movl -0x20b0(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x20b0(%rbp)
cltq
movw %cx, -0x2010(%rbp,%rax,2)
movl -0x20a8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20a8(%rbp)
jmp 0x68f1
movl -0x20ac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20ac(%rbp)
jmp 0x664b
movl -0x20b0(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x20b0(%rbp)
cltq
movw $0x24, -0x2010(%rbp,%rax,2)
jmp 0x69db
cmpl $0xffe, -0x20b0(%rbp)   # imm = 0xFFE
jge 0x69d7
movq -0x20a0(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x20a4(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x20ac(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x20ac(%rbp)
movslq %ecx, %rcx
movw (%rax,%rcx,2), %cx
movl -0x20b0(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x20b0(%rbp)
cltq
movw %cx, -0x2010(%rbp,%rax,2)
jmp 0x69d9
jmp 0x69e2
jmp 0x69db
jmp 0x69dd
jmp 0x664b
movl -0x20b0(%rbp), %eax
addl $0x1, %eax
cltq
movw $0x0, -0x2010(%rbp,%rax,2)
movslq -0x20b0(%rbp), %rax
movw $0x0, -0x2010(%rbp,%rax,2)
leaq -0x2010(%rbp), %rdi
callq 0x5770
cmpl $0x0, %eax
jne 0x6a1b
jmp 0x6a3e
movl 0x1d773(%rip), %eax     # 0x24194
addl $0x1, %eax
movl %eax, 0x1d76a(%rip)     # 0x24194
callq 0x5f40
movl 0x1d75f(%rip), %eax     # 0x24194
addl $-0x1, %eax
movl %eax, 0x1d756(%rip)     # 0x24194
movl -0x20a4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20a4(%rbp)
jmp 0x660e
movq -0x20a0(%rbp), %rax
movl $0x0, 0x28(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20d0, %rsp           # imm = 0x20D0
popq %rbp
retq
nopw %cs:(%rax,%rax)