// File: /workspace/github_cpp_makefile_star2_O3/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, %r13
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r15
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x6b7c
movq %r14, 0x40(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x117ea
leaq 0x28(%rsp), %r14
movq -0x10(%r14), %rdi
cmpq %r14, %rdi
je 0xde77
callq 0x3230
movq %r13, (%rsp)
movq %r15, 0x38(%rsp)
leaq 0x18(%rsp), %rbp
movb $0x1, %al
testb $0x1, %al
jne 0xdf02
movq 0x40(%rsp), %rax
movq (%rax), %rbx
movq 0x8(%rax), %r15
cmpq %r15, %rbx
je 0xdf02
movslq 0x18(%r12), %rax
movq (%r12), %rcx
movq (%rcx,%rax,8), %r13
movq (%rbx), %rax
movq %rax, 0x10(%rsp)
movq %r14, 0x18(%rsp)
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
addq %rsi, %rdx
leaq 0x18(%rsp), %rdi
callq 0x473c
movl 0x10(%rsp), %eax
cmpl $0x2, %eax
jb 0xdee0
cmpl $0x11, %eax
jne 0xdeea
cmpl $0x15, 0x14(%rsp)
jne 0xdeea
cmpl %eax, (%r13)
je 0xdfc6
movq 0x18(%rsp), %rdi
cmpq %r14, %rdi
je 0xdef9
callq 0x3230
addq $0x28, %rbx
cmpq %r15, %rbx
jne 0xdea9
cmpb $0x1, 0x20(%r12)
jne 0xdf18
movl 0x18(%r12), %eax
incl %eax
movl %eax, 0x18(%r12)
jmp 0xdf23
movb $0x1, 0x20(%r12)
movl 0x18(%r12), %eax
cltq
movq (%r12), %rcx
movq (%rcx,%rax,8), %rbx
movq 0x40(%rsp), %rax
movq (%rax), %r15
movq 0x8(%rax), %r13
cmpq %r13, %r15
je 0xdf84
movq (%r15), %rax
movq %rax, 0x10(%rsp)
movq %r14, 0x18(%rsp)
movq 0x8(%r15), %rsi
movq 0x10(%r15), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0x473c
movl 0x10(%rsp), %eax
cmpl (%rbx), %eax
jne 0xdf6f
movl 0x14(%rsp), %eax
cmpl 0x4(%rbx), %eax
je 0xdfc6
movq 0x18(%rsp), %rdi
cmpq %r14, %rdi
je 0xdf7e
callq 0x3230
addq $0x28, %r15
jmp 0xdf39
movq %r12, %rdi
movq %rbx, %rsi
movl 0xc(%rsp), %edx
callq 0xe0d4
movq %rax, 0x10(%rsp)
cmpl $0x6, (%rax)
je 0xdfbf
movq (%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0xdfb5
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0xdfbf
leaq 0x10(%rsp), %rdx
callq 0x11a78
xorl %eax, %eax
jmp 0xde87
movq (%rsp), %rcx
movups (%rcx), %xmm0
movq 0x38(%rsp), %rbx
movups %xmm0, (%rbx)
movq 0x10(%rcx), %rax
movq %rax, 0x10(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
movq $0x0, 0x10(%rcx)
movq 0x18(%rsp), %rdi
cmpq %r14, %rdi
je 0xdffa
callq 0x3230
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), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xe022
callq 0x3230
movq %rbx, %rdi
callq 0x33c0