// File: rofl0r[P]ascc/tokenizer.c
// Function: get_string
static int get_string(struct tokenizer *t, char quote_char, struct token* out, int wide) {
	char *s = t->buf+1;
	int escaped = 0;
	char *end = t->buf + t->bufsize - 2;
	while(s < end) {
		int c = tokenizer_getc(t);
		if(c == EOF) {
			out->type = TT_EOF;
			*s = 0;
			return apply_coords(t, out, s, 0);
		}
		if(c == '\\') {
			c = tokenizer_getc(t);
			if(c == '\n') continue;
			tokenizer_ungetc(t, c);
			c = '\\';
		}
		if(c == '\n') {
			if(escaped) {
				escaped = 0;
				continue;
			}
			tokenizer_ungetc(t, c);
			out->type = TT_UNKNOWN;
			s = assign_bufchar(t, s, 0);
			return apply_coords(t, out, s, 0);
		}
		if(!escaped) {
			if(c == quote_char) {
				s = assign_bufchar(t, s, c);
				*s = 0;
				//s = assign_bufchar(t, s, 0);
				if(!wide)
					out->type = (quote_char == '"'? TT_DQSTRING_LIT : TT_SQSTRING_LIT);
				else
					out->type = (quote_char == '"'? TT_WIDESTRING_LIT : TT_WIDECHAR_LIT);
				return apply_coords(t, out, s, 1);
			}
			if(c == '\\') escaped = 1;
		} else {
			escaped = 0;
		}
		s = assign_bufchar(t, s, c);
	}
	t->buf[MAX_TOK_LEN-1] = 0;
	out->type = TT_OVERFLOW;
	return apply_coords(t, out, s, 0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq -0x10(%rbp), %rax
addq $0x120, %rax            # imm = 0x120
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x10(%rbp), %rax
addq $0x120, %rax            # imm = 0x120
movq -0x10(%rbp), %rcx
addq 0x1120(%rcx), %rax
addq $-0x2, %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0x2ea0a
movq -0x10(%rbp), %rdi
callq 0x2d870
movl %eax, -0x44(%rbp)
cmpl $-0x1, -0x44(%rbp)
jne 0x2e8cb
movq -0x20(%rbp), %rax
movl $0xe, (%rax)
movq -0x30(%rbp), %rax
movb $0x0, (%rax)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x30(%rbp), %rdx
xorl %ecx, %ecx
callq 0x2e7b0
movl %eax, -0x4(%rbp)
jmp 0x2ea35
cmpl $0x5c, -0x44(%rbp)
jne 0x2e8f8
movq -0x10(%rbp), %rdi
callq 0x2d870
movl %eax, -0x44(%rbp)
cmpl $0xa, -0x44(%rbp)
jne 0x2e8e5
jmp 0x2e87f
movq -0x10(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x2d910
movl $0x5c, -0x44(%rbp)
cmpl $0xa, -0x44(%rbp)
jne 0x2e954
cmpl $0x0, -0x34(%rbp)
je 0x2e910
movl $0x0, -0x34(%rbp)
jmp 0x2e87f
movq -0x10(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x2d910
movq -0x20(%rbp), %rax
movl $0xa, (%rax)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
xorl %edx, %edx
callq 0x2df10
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x30(%rbp), %rdx
xorl %ecx, %ecx
callq 0x2e7b0
movl %eax, -0x4(%rbp)
jmp 0x2ea35
cmpl $0x0, -0x34(%rbp)
jne 0x2e9ea
movl -0x44(%rbp), %eax
movsbl -0x11(%rbp), %ecx
cmpl %ecx, %eax
jne 0x2e9db
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x44(%rbp), %edx
callq 0x2df10
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movb $0x0, (%rax)
cmpl $0x0, -0x24(%rbp)
jne 0x2e9a6
movsbl -0x11(%rbp), %edx
movl $0x2, %ecx
movl $0x3, %eax
cmpl $0x22, %edx
cmovel %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
jmp 0x2e9c0
movsbl -0x11(%rbp), %edx
movl $0xc, %ecx
movl $0xd, %eax
cmpl $0x22, %edx
cmovel %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x30(%rbp), %rdx
movl $0x1, %ecx
callq 0x2e7b0
movl %eax, -0x4(%rbp)
jmp 0x2ea35
cmpl $0x5c, -0x44(%rbp)
jne 0x2e9e8
movl $0x1, -0x34(%rbp)
jmp 0x2e9f1
movl $0x0, -0x34(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x44(%rbp), %edx
callq 0x2df10
movq %rax, -0x30(%rbp)
jmp 0x2e87f
movq -0x10(%rbp), %rax
movb $0x0, 0x111f(%rax)
movq -0x20(%rbp), %rax
movl $0xb, (%rax)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x30(%rbp), %rdx
xorl %ecx, %ecx
callq 0x2e7b0
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop