// File: /workspace/github_c_makefile_star2_O1/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 0xade3
movq %rsi, %rbx
movl %ecx, -0x30(%rbp)
testq %rsi, %rsi
je 0xae02
movq %rdi, %rsi
movl $0xa, %edi
movq %rsi, -0x50(%rbp)
callq 0xa0d0
leaq -0x40(%rbp), %rdi
callq 0xe468
leaq -0x60(%rbp), %rdi
callq 0xe468
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 0xace1
xorl %r12d, %r12d
leaq -0x40(%rbp), %r13
leaq -0x60(%rbp), %rbx
movq %r13, %rdi
movl $0x20, %esi
callq 0xeec5
movq 0x8(%r14), %rsi
movl 0x4(%r14), %edx
movq %r13, %rdi
callq 0xeee9
cmpl $0x0, 0x4(%r14)
js 0xaccf
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq %rbx, %rdi
movl $0x20, %esi
callq 0xe5eb
incl %r15d
cmpl 0x4(%r14), %r15d
jl 0xacb9
incl %r12d
cmpl -0x2c(%rbp), %r12d
jge 0xace1
movq 0x20(%r14), %r14
testq %r14, %r14
jne 0xac8f
movq -0x48(%rbp), %r15
movq 0x8(%r15), %rsi
movl 0x4(%r15), %edx
leaq -0x40(%rbp), %rdi
callq 0xe688
cmpl $0x0, 0x4(%r15)
jle 0xad1a
xorl %r14d, %r14d
leaq -0x60(%rbp), %rbx
movq %rbx, %rdi
movl $0x7e, %esi
callq 0xe5eb
incl %r14d
cmpl 0x4(%r15), %r14d
jl 0xad04
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 0xad6d
movl $0x1, %r15d
leaq -0x40(%rbp), %rbx
movq %rbx, %rdi
movl $0x20, %esi
callq 0xe5eb
movq 0x8(%r14), %rsi
movl 0x4(%r14), %edx
movq %rbx, %rdi
callq 0xe688
cmpl %r12d, %r15d
jge 0xad6d
movq 0x28(%r14), %r14
incl %r15d
testq %r14, %r14
jne 0xad3f
leaq -0x40(%rbp), %rbx
movq 0x8(%rbx), %rdx
testq %rdx, %rdx
leaq 0x24a37(%rip), %r12     # 0x2f7b6
cmoveq %r12, %rdx
leaq 0x23746(%rip), %r14     # 0x2e4d0
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 0xe958
movq %r15, %rdi
callq 0xe958
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 0x23696(%rip), %rdi     # 0x2e480
leaq 0x23693(%rip), %rsi     # 0x2e484
leaq 0x23695(%rip), %rcx     # 0x2e48d
movl $0x16, %edx
callq 0xa0b0
leaq 0x236c1(%rip), %rdi     # 0x2e4ca
leaq 0x23674(%rip), %rsi     # 0x2e484
leaq 0x23676(%rip), %rcx     # 0x2e48d
movl $0x17, %edx
callq 0xa0b0
nopl (%rax)