// File: /workspace/github_cpp_makefile_star2_O2/kram[P]kram/./src/parser/parser.cpp
// Function: Parser::read_until(std::vector<lexer::Token, std::allocator<lexer::Token>>, std::vector<Instruction*, std::allocator<Instruction*>>, ON)
std::vector<Instruction*> Parser::read_until(std::vector<lexer::Token> until, std::vector<Instruction*> res, ON on) {
	// Everything can end at a EOF
	until.push_back(lexer::Token::T_EOF());

	bool first = true;

	while (true) {

		// First, test the previous token
		lexer::Token* prev = this->get_token();

		if (!first) {
			for (lexer::Token unt : until) {
				if ((unt.type == lexer::Type::T_EOL || unt.type == lexer::Type::T_EOF || (unt.type == lexer::Type::OPERATOR && unt.sub == lexer::Type::OPERATOR_SEMICOLON)) && prev->type == unt.type) {
					return res;
				}
			}
		}

		// Test again
		this->advance();
		lexer::Token* next = this->get_token();

		for (lexer::Token unt : until) {
			if (unt.type == next->type && unt.sub == next->sub) {
				return res;
			}
		}

		Instruction* sym = this->symbol(next, on);

		if (sym->instruction != Ins::IGNORE) {
			res.push_back(sym);	
		}

		first = false;
	}

	return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r8d, 0xc(%rsp)
movq %rcx, (%rsp)
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r14
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x6266
movq %r15, 0x18(%rsp)
movq %r15, %rdi
movq %rbx, %rsi
callq 0xfe8e
movq %r14, 0x10(%rsp)
leaq 0x28(%rsp), %rdi
callq 0x3130
movb $0x1, %al
leaq 0x28(%rsp), %rbp
leaq 0x20(%rsp), %rbx
testb $0x1, %al
je 0xcba2
cmpb $0x1, 0x20(%r12)
jne 0xcbf9
movl 0x18(%r12), %eax
incl %eax
movl %eax, 0x18(%r12)
jmp 0xcc04
movslq 0x18(%r12), %rax
movq (%r12), %rcx
movq (%rcx,%rax,8), %r15
movq 0x18(%rsp), %rax
movq (%rax), %r14
movq 0x8(%rax), %r13
cmpq %r13, %r14
je 0xcb8c
movq %rbx, %rdi
movq %r14, %rsi
callq 0xf7d6
movl 0x20(%rsp), %eax
cmpl $0x2, %eax
jb 0xcbe0
cmpl $0x11, %eax
jne 0xcbe9
cmpl $0x15, 0x24(%rsp)
jne 0xcbe9
cmpl %eax, (%r15)
je 0xcc9e
leaq 0x28(%rsp), %rdi
callq 0x3130
addq $0x28, %r14
jmp 0xcbbb
movb $0x1, 0x20(%r12)
movl 0x18(%r12), %eax
cltq
movq (%r12), %rcx
movq (%rcx,%rax,8), %r14
movq 0x18(%rsp), %rax
movq (%rax), %r15
movq 0x8(%rax), %r13
cmpq %r13, %r15
je 0xcc4b
movq %rbx, %rdi
movq %r15, %rsi
callq 0xf7d6
movl 0x20(%rsp), %eax
cmpl (%r14), %eax
jne 0xcc3d
movl 0x24(%rsp), %eax
cmpl 0x4(%r14), %eax
je 0xcc77
movq %rbp, %rdi
callq 0x3130
addq $0x28, %r15
jmp 0xcc1a
movq %r12, %rdi
movq %r14, %rsi
movl 0xc(%rsp), %edx
callq 0xcd90
movq %rax, 0x20(%rsp)
cmpl $0x6, (%rax)
je 0xcc70
movq (%rsp), %rdi
movq %rbx, %rsi
callq 0xf7ea
xorl %eax, %eax
jmp 0xcb88
movq (%rsp), %rcx
movups (%rcx), %xmm0
movq 0x10(%rsp), %rbx
movups %xmm0, (%rbx)
movq 0x10(%rcx), %rax
movq %rax, 0x10(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
andq $0x0, 0x10(%rcx)
movq %rbp, %rdi
jmp 0xccc5
movq (%rsp), %rcx
movups (%rcx), %xmm0
movq 0x10(%rsp), %rbx
movups %xmm0, (%rbx)
movq 0x10(%rcx), %rax
movq %rax, 0x10(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
andq $0x0, 0x10(%rcx)
leaq 0x28(%rsp), %rdi
callq 0x3130
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x3130
movq %rbx, %rdi
callq 0x3390
nop