// File: /workspace/github_c_makefile_star2_O2/Ihsoh[P]ilang/common.c
// Function: cmn_print_code_by_token
void cmn_print_code_by_token(
	FILE *out,
	LexerToken *token,
	int n_prev,
	int n_succ
) {
	assert(out);
	assert(token);

	fputc('\n', out);

	ResizableString rstr_line_code;
	ResizableString rstr_line_wavy_line;

	rstr_init(&rstr_line_code);
	rstr_init(&rstr_line_wavy_line);

	LexerToken *t = NULL;

	t = token->prev;
	for (int i = 0; i < n_prev && t != NULL; i++, t = t->prev) {
		rstr_prepend_with_char(&rstr_line_code, ' ');
		rstr_prepend_with_raw(&rstr_line_code, t->content, t->len);

		for (int j = 0; j < t->len + 1; j++) {
			rstr_append_with_char(&rstr_line_wavy_line, ' ');
		}
	}

	rstr_append_with_raw(&rstr_line_code, token->content, token->len);
	for (int i = 0; i < token->len; i++) {
		rstr_append_with_char(&rstr_line_wavy_line, '~');
	}

	t = token->next;
	for (int i = 0; i < n_succ && t != NULL; i++, t = t->next) {
		rstr_append_with_char(&rstr_line_code, ' ');
		rstr_append_with_raw(&rstr_line_code, t->content, t->len);
	}

	fprintf(out, "\t%s\n", RSTR_CSTR(&rstr_line_code));
	fprintf(out, "\t%s\n", RSTR_CSTR(&rstr_line_wavy_line));

	rstr_free(&rstr_line_code);
	rstr_free(&rstr_line_wavy_line);

	fputc('\n', out);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, -0x30(%rbp)
movl %edx, -0x2c(%rbp)
testq %rdi, %rdi
je 0xac26
movq %rsi, %r13
testq %rsi, %rsi
je 0xac3f
movq %rdi, %rsi
pushq $0xa
popq %rdi
movq %rsi, -0x50(%rbp)
callq 0xa0d0
leaq -0x48(%rbp), %rdi
callq 0xde1c
leaq -0x60(%rbp), %rbx
movq %rbx, %rdi
callq 0xde1c
xorl %eax, %eax
pushq $0x20
popq %r14
movq %r13, %r15
cmpl -0x2c(%rbp), %eax
jge 0xab46
movq 0x20(%r15), %r15
testq %r15, %r15
je 0xab46
movl %eax, -0x34(%rbp)
leaq -0x48(%rbp), %r12
movq %r12, %rdi
movl %r14d, %esi
callq 0xe814
movq 0x8(%r15), %rsi
movl 0x4(%r15), %edx
movq %r12, %rdi
callq 0xe835
xorl %r12d, %r12d
cmpl 0x4(%r15), %r12d
jg 0xab3f
movq %rbx, %rdi
movl %r14d, %esi
callq 0xdf81
incl %r12d
jmp 0xab29
movl -0x34(%rbp), %eax
incl %eax
jmp 0xaaf6
movq 0x8(%r13), %rsi
movl 0x4(%r13), %edx
leaq -0x48(%rbp), %rdi
callq 0xe00f
xorl %r15d, %r15d
leaq -0x60(%rbp), %rbx
pushq $0x7e
popq %r14
cmpl 0x4(%r13), %r15d
jge 0xab78
movq %rbx, %rdi
movl %r14d, %esi
callq 0xdf81
incl %r15d
jmp 0xab62
xorl %r15d, %r15d
leaq -0x48(%rbp), %rbx
pushq $0x20
popq %r14
cmpl -0x30(%rbp), %r15d
jge 0xabb2
movq 0x28(%r13), %r13
testq %r13, %r13
je 0xabb2
movq %rbx, %rdi
movl %r14d, %esi
callq 0xdf81
movq 0x8(%r13), %rsi
movl 0x4(%r13), %edx
movq %rbx, %rdi
callq 0xe00f
incl %r15d
jmp 0xab83
leaq -0x48(%rbp), %rbx
movq 0x8(%rbx), %rdx
testq %rdx, %rdx
leaq 0x22bce(%rip), %r12     # 0x2d792
cmoveq %r12, %rdx
leaq 0x218f1(%rip), %r14     # 0x2c4c0
movq -0x50(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0xa0f0
leaq -0x60(%rbp), %r15
movq 0x8(%r15), %rdx
testq %rdx, %rdx
cmoveq %r12, %rdx
movq %r13, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0xa0f0
movq %rbx, %rdi
callq 0xe2b9
movq %r15, %rdi
callq 0xe2b9
pushq $0xa
popq %rdi
movq %r13, %rsi
callq 0xa0d0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x21843(%rip), %rdi     # 0x2c470
leaq 0x21840(%rip), %rsi     # 0x2c474
leaq 0x21842(%rip), %rcx     # 0x2c47d
pushq $0x16
jmp 0xac56
leaq 0x21874(%rip), %rdi     # 0x2c4ba
leaq 0x21827(%rip), %rsi     # 0x2c474
leaq 0x21829(%rip), %rcx     # 0x2c47d
pushq $0x17
popq %rdx
callq 0xa0b0