// File: /workspace/github_c_makefile_star2_O3/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 %edx, -0x2c(%rbp)
testq %rdi, %rdi
je 0xadd7
movq %rsi, %rbx
movl %ecx, -0x30(%rbp)
testq %rsi, %rsi
je 0xadf6
movq %rdi, %rsi
movl $0xa, %edi
movq %rsi, -0x50(%rbp)
callq 0xa0d0
leaq -0x40(%rbp), %rdi
callq 0xe274
leaq -0x60(%rbp), %rdi
callq 0xe274
movq %rbx, -0x48(%rbp)
movq 0x20(%rbx), %r14
cmpl $0x0, -0x2c(%rbp)
setg %al
testq %r14, %r14
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xacd5
xorl %r12d, %r12d
leaq -0x40(%rbp), %r13
leaq -0x60(%rbp), %rbx
movq %r13, %rdi
movl $0x20, %esi
callq 0xece0
movq 0x8(%r14), %rsi
movl 0x4(%r14), %edx
movq %r13, %rdi
callq 0xed04
cmpl $0x0, 0x4(%r14)
js 0xacc3
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq %rbx, %rdi
movl $0x20, %esi
callq 0xe3fa
incl %r15d
cmpl 0x4(%r14), %r15d
jl 0xacad
incl %r12d
cmpl -0x2c(%rbp), %r12d
jge 0xacd5
movq 0x20(%r14), %r14
testq %r14, %r14
jne 0xac83
movq -0x48(%rbp), %r15
movq 0x8(%r15), %rsi
movl 0x4(%r15), %edx
leaq -0x40(%rbp), %rdi
callq 0xe497
cmpl $0x0, 0x4(%r15)
jle 0xad0e
xorl %r14d, %r14d
leaq -0x60(%rbp), %rbx
movq %rbx, %rdi
movl $0x7e, %esi
callq 0xe3fa
incl %r14d
cmpl 0x4(%r15), %r14d
jl 0xacf8
movq 0x28(%r15), %r14
movl -0x30(%rbp), %r12d
testl %r12d, %r12d
setg %al
testq %r14, %r14
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xad61
movl $0x1, %r15d
leaq -0x40(%rbp), %rbx
movq %rbx, %rdi
movl $0x20, %esi
callq 0xe3fa
movq 0x8(%r14), %rsi
movl 0x4(%r14), %edx
movq %rbx, %rdi
callq 0xe497
cmpl %r12d, %r15d
jge 0xad61
movq 0x28(%r14), %r14
incl %r15d
testq %r14, %r14
jne 0xad33
leaq -0x40(%rbp), %rbx
movq 0x8(%rbx), %rdx
testq %rdx, %rdx
leaq 0x23a1f(%rip), %r12     # 0x2e792
cmoveq %r12, %rdx
leaq 0x22742(%rip), %r14     # 0x2d4c0
movq -0x50(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0xa100
leaq -0x60(%rbp), %r15
movq 0x8(%r15), %rdx
testq %rdx, %rdx
cmoveq %r12, %rdx
movq %r13, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0xa100
movq %rbx, %rdi
callq 0xe772
movq %r15, %rdi
callq 0xe772
movl $0xa, %edi
movq %r13, %rsi
callq 0xa0d0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x22692(%rip), %rdi     # 0x2d470
leaq 0x2268f(%rip), %rsi     # 0x2d474
leaq 0x22691(%rip), %rcx     # 0x2d47d
movl $0x16, %edx
callq 0xa0b0
leaq 0x226bd(%rip), %rdi     # 0x2d4ba
leaq 0x22670(%rip), %rsi     # 0x2d474
leaq 0x22672(%rip), %rcx     # 0x2d47d
movl $0x17, %edx
callq 0xa0b0
nopl (%rax)