// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/basic-c64.c
// Function: process_line
static void process_line(deark *c, lctx *d, i64 file_pos, i64 mem_pos,
	i64 line_size)
{
	i64 line_num;
	i64 pos;
	u8 b;
	const char *token;
	int in_quote = 0;

	pos = file_pos;
	line_num = de_getu16le(pos);
	de_dbg(c, "line %d at %d, mem pos=%d, size=%d", (int)line_num, (int)file_pos,
		(int)mem_pos, (int)line_size);
	pos += 2;

	dbuf_printf(d->outf, "%d ", (int)line_num);

	while(pos < file_pos+line_size) {
		b = de_getbyte(pos);

		if(in_quote && b!=0x22) {
			// Quoted string data. Don't translate.
			// TODO: Can 0x00 occur in a string?
			dbuf_writebyte(d->outf, b);
			pos++;
			continue;
		}

		if(b>=0x80) {
			token = get_token(b);
			if(token) {
				dbuf_puts(d->outf, token);
			}
			else {
				dbuf_puts(d->outf, "***ERROR***");
			}
		}
		else if(b==0x00) {
			break;
		}
		else {
			dbuf_writebyte(d->outf, b);
			if(b==0x22) { // Quotation mark
				in_quote = !in_quote;
			}
		}
		pos++;
	}

	dbuf_puts(d->outf, "\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl $0x0, -0x4c(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x38(%rbp), %rsi
callq 0x165280
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movl %eax, %edx
movq -0x18(%rbp), %rax
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %eax, %r8d
movq -0x28(%rbp), %rax
movl %eax, %r9d
leaq 0x172fc6(%rip), %rsi    # 0x19fcfb
movb $0x0, %al
callq 0x15b0d0
movq -0x38(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movl %eax, %edx
leaq 0x172fc2(%rip), %rsi    # 0x19fd1e
movb $0x0, %al
callq 0x167f00
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
addq -0x28(%rbp), %rcx
cmpq %rcx, %rax
jge 0x2ce49
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x38(%rbp), %rsi
callq 0x165060
movb %al, -0x39(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0x2cdb9
movzbl -0x39(%rbp), %eax
cmpl $0x22, %eax
je 0x2cdb9
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movzbl -0x39(%rbp), %esi
callq 0x168380
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x2cd63
movzbl -0x39(%rbp), %eax
cmpl $0x80, %eax
jl 0x2cdff
movzbl -0x39(%rbp), %edi
callq 0x2ce70
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x2cdea
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x48(%rbp), %rsi
callq 0x168da0
jmp 0x2cdfd
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x172f2a(%rip), %rsi    # 0x19fd22
callq 0x168da0
jmp 0x2ce38
movzbl -0x39(%rbp), %eax
cmpl $0x0, %eax
jne 0x2ce0a
jmp 0x2ce49
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movzbl -0x39(%rbp), %esi
callq 0x168380
movzbl -0x39(%rbp), %eax
cmpl $0x22, %eax
jne 0x2ce34
cmpl $0x0, -0x4c(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4c(%rbp)
jmp 0x2ce36
jmp 0x2ce38
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x2cd63
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x16f32c(%rip), %rsi    # 0x19c183
callq 0x168da0
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)