// File: /workspace/github_cpp_makefile_star2_O1/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 $0x78, %rsp
movl %r8d, 0x24(%rsp)
movq %rcx, %rbp
movq %rdx, %r14
movq %rsi, 0x18(%rsp)
movq %rdi, %r12
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
callq 0x6ba4
movq %r14, 0x58(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x11cc6
leaq 0x40(%rsp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0xdff3
callq 0x3230
leaq 0x30(%rsp), %r14
movups (%r12), %xmm0
movaps %xmm0, 0x60(%rsp)
movq %r12, 0x70(%rsp)
movq 0x10(%r12), %rax
movq %rax, 0x10(%rsp)
movb $0x1, %al
movq %rbp, 0x50(%rsp)
movl %eax, 0xc(%rsp)
testb $0x1, %al
jne 0xe09a
movq 0x58(%rsp), %rax
movq (%rax), %rbx
movq 0x8(%rax), %r12
cmpq %r12, %rbx
je 0xe09a
movq 0x18(%rsp), %rcx
movslq 0x18(%rcx), %rax
movq (%rcx), %rcx
movq (%rcx,%rax,8), %r13
movq (%rbx), %rax
movq %rax, 0x28(%rsp)
movq %r15, 0x30(%rsp)
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
addq %rsi, %rdx
leaq 0x30(%rsp), %rdi
callq 0x473c
movl 0x28(%rsp), %eax
cmpl $0x2, %eax
jb 0xe078
cmpl $0x11, %eax
jne 0xe082
cmpl $0x15, 0x2c(%rsp)
jne 0xe082
cmpl %eax, (%r13)
je 0xe184
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0xe091
callq 0x3230
addq $0x28, %rbx
cmpq %r12, %rbx
jne 0xe041
movq 0x18(%rsp), %rcx
cmpb $0x1, 0x20(%rcx)
jne 0xe0aa
incl 0x18(%rcx)
jmp 0xe0ae
movb $0x1, 0x20(%rcx)
movslq 0x18(%rcx), %rax
movq (%rcx), %rcx
movq (%rcx,%rax,8), %rbx
movq 0x58(%rsp), %rax
movq (%rax), %rbp
movq 0x8(%rax), %r13
cmpq %r13, %rbp
sete %r12b
je 0xe115
movq (%rbp), %rax
movq %rax, 0x28(%rsp)
movq %r15, 0x30(%rsp)
movq 0x8(%rbp), %rsi
movq 0x10(%rbp), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x473c
movl 0x28(%rsp), %eax
cmpl (%rbx), %eax
jne 0xe100
movl 0x2c(%rsp), %eax
cmpl 0x4(%rbx), %eax
je 0xe14d
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0xe10f
callq 0x3230
addq $0x28, %rbp
jmp 0xe0c5
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
movl 0x24(%rsp), %edx
callq 0xe2c4
movq %rax, 0x28(%rsp)
cmpl $0x6, (%rax)
movq 0x50(%rsp), %rbp
je 0xe1ca
movq 0x8(%rbp), %rsi
cmpq 0x10(%rbp), %rsi
je 0xe1bd
movq %rax, (%rsi)
addq $0x8, 0x8(%rbp)
jmp 0xe1ca
movq 0x50(%rsp), %rbp
movups (%rbp), %xmm0
movaps %xmm0, 0x60(%rsp)
movq 0x10(%rbp), %rax
movq %rax, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rbp)
movq $0x0, 0x10(%rbp)
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0xe1b7
callq 0x3230
jmp 0xe1b7
movups (%rbp), %xmm0
movaps %xmm0, 0x60(%rsp)
movq 0x10(%rbp), %rax
movq %rax, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rbp)
movq $0x0, 0x10(%rbp)
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0xe1b4
callq 0x3230
xorl %r12d, %r12d
movl 0xc(%rsp), %eax
jmp 0xe1cc
movq %rbp, %rdi
leaq 0x28(%rsp), %rdx
callq 0x11f54
xorl %eax, %eax
testb $0x1, %r12b
jne 0xe018
movq 0x70(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %rcx, 0x10(%rax)
movaps 0x60(%rsp), %xmm0
movups %xmm0, (%rax)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xe211
callq 0x3230
movq %rbx, %rdi
callq 0x33c0
nop