// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/lexer.c
// Function: lexer_parse
void lexer_parse(LexerContext *ctx) {
	assert(ctx);
	assert(ctx->matchers[0].name != NULL);

	const LexerTokenMatcher *matchers = ctx->matchers;

	while (ctx->index < ctx->len - 1) {
		LexerToken *token = NULL;
		int abandon = 0;
		int last_line = 0, last_column = -1;
		for (const LexerTokenMatcher *matcher = matchers; matcher->name != NULL;matcher++) {
			_store_char_context(ctx);
			int a;
			LexerToken *t = matcher->match(ctx, &a);
			if (t != NULL && (token == NULL || t->len > token->len)) {
				token = t;
				abandon = a;
				last_line = ctx->line;
				last_column = ctx->column;
			}
			_resume_char_context(ctx);
		}

		if (token != NULL) {
			ctx->index += token->len;
			ctx->line = last_line;
			ctx->column = last_column;
			if (!abandon) {
				_add_token(ctx, token);
			}
		} else {
			lexer_next_char(ctx);
			ctx->invalid_token(ctx);
		}
	}

	lexer_reset_token(ctx, 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0xbe85
jmp 0xbea4
leaq 0x41cd5(%rip), %rdi     # 0x4db61
leaq 0x40500(%rip), %rsi     # 0x4c393
movl $0x153, %edx            # imm = 0x153
leaq 0x3aa1f(%rip), %rcx     # 0x468be
callq 0xa0b0
movq -0x8(%rbp), %rax
movq 0x2078(%rax), %rax
cmpq $0x0, (%rax)
je 0xbeb7
jmp 0xbed6
leaq 0x3aa21(%rip), %rdi     # 0x468df
leaq 0x404ce(%rip), %rsi     # 0x4c393
movl $0x154, %edx            # imm = 0x154
leaq 0x3a9ed(%rip), %rcx     # 0x468be
callq 0xa0b0
movq -0x8(%rbp), %rax
movq 0x2078(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x34(%rax), %eax
movq -0x8(%rbp), %rcx
movl 0x30(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0xc003
movq $0x0, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl $0xffffffff, -0x24(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
je 0xbfa3
movq -0x8(%rbp), %rdi
callq 0xc020
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq *%rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0xbf8c
cmpq $0x0, -0x18(%rbp)
je 0xbf6a
movq -0x40(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jle 0xbf8c
movq -0x40(%rbp), %rax
movq %rax, -0x18(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movl 0x3c(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rdi
callq 0xc090
movq -0x30(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x30(%rbp)
jmp 0xbf23
cmpq $0x0, -0x18(%rbp)
je 0xbfe4
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x8(%rbp), %rax
addl 0x34(%rax), %ecx
movl %ecx, 0x34(%rax)
movl -0x20(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x38(%rax)
movl -0x24(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x3c(%rax)
cmpl $0x0, -0x1c(%rbp)
jne 0xbfe2
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xc100
jmp 0xbffe
movq -0x8(%rbp), %rdi
callq 0xb6d0
movq -0x8(%rbp), %rax
movq 0x2088(%rax), %rax
movq -0x8(%rbp), %rdi
callq *%rax
jmp 0xbee5
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0xb8e0
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)