// File: /workspace/github_c_makefile_star2_O2/markdryan[P]subtilis/common/lexer.c
// Function: prv_complete_custom_type
static void prv_complete_custom_type(subtilis_lexer_t *l, subtilis_token_t *t,
				     subtilis_error_t *err)
{
	char ch;
	char prefix[5];
	size_t i = 0;
	const char *tbuf;

	for (;;) {
		prv_ensure_input(l, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		if (l->index == l->buf_end)
			break;

		ch = l->buffer[l->index];
		if (!((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') ||
		      (ch >= '0' && ch <= '9') || (ch == '_')))
			break;
		prv_set_next_with_err(l, t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;

		if (i < 4)
			prefix[i] = ch;
		i++;
	}

	tbuf = subtilis_token_get_text(t);
	if (i < 2) {
		subtilis_error_set_bad_type_name(err, tbuf, l->stream->name,
						 l->line);
		return;
	}
	if (i > 4)
		i = 4;
	prefix[i] = 0;

	/*
	 * The lexer doesn't know the complete type of the token as this
	 * information is stored in the symbol table to which it doesn't have
	 * access.  It does know however, that we have a custom type and the
	 * type is either a record, a function or a procedure.
	 */

	if (!strncmp(prefix, "REC", 3)) {
		subtilis_type_init_rec(&t->tok.id_type, tbuf, err);
		return;
	}

	if (strncmp(prefix, "FN", 2) && strncmp(prefix, "PROC", 4)) {
		subtilis_error_set_bad_type_name(err, tbuf, l->stream->name,
						 l->line);
		return;
	}

	t->tok.id_type.type = SUBTILIS_TYPE_FN;
	t->tok.id_type.params.fn.num_params = 0;
	t->tok.id_type.params.fn.ret_val =
	    calloc(1, sizeof(*t->tok.id_type.params.fn.ret_val));
	if (!t->tok.id_type.params.fn.ret_val) {
		subtilis_error_set_oom(err);
		return;
	}
	t->tok.id_type.params.fn.ret_val->type = SUBTILIS_TYPE_VOID;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
xorl %r13d, %r13d
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1398d
cmpl $0x0, (%rbx)
jne 0x14051
movq 0x40(%r15), %rax
cmpq 0x360(%r15), %rax
je 0x13f83
movq 0x368(%r15), %rcx
movb (%rcx,%rax), %r12b
movl %r12d, %eax
andb $-0x21, %al
addb $-0x41, %al
cmpb $0x1a, %al
jb 0x13f5c
leal -0x30(%r12), %eax
cmpb $0xa, %al
setae %al
cmpb $0x5f, %r12b
setne %cl
testb %al, %cl
jne 0x13f83
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x13abf
cmpl $0x0, (%rbx)
jne 0x14051
cmpq $0x3, %r13
ja 0x13f7e
movb %r12b, 0xb(%rsp,%r13)
incq %r13
jmp 0x13f10
movq %r14, %rdi
callq 0x12a25
movq %rax, %r12
cmpq $0x1, %r13
ja 0x13fc7
movq 0x30(%r15), %r8
movl 0x38(%r15), %r9d
leaq 0x580b1(%rip), %rax     # 0x6c054
leaq 0x59e1b(%rip), %rcx     # 0x6ddc5
pushq $0xe
popq %rsi
movq %rbx, %rdi
movq %r12, %rdx
pushq $0x249                  # imm = 0x249
pushq %rax
callq 0x140cd
addq $0x20, %rsp
jmp 0x14055
cmpq $0x4, %r13
pushq $0x4
popq %rax
cmovbq %r13, %rax
movb $0x0, 0xb(%rsp,%rax)
leaq 0x5b7cc(%rip), %rsi     # 0x6f7aa
leaq 0xb(%rsp), %rdi
pushq $0x3
popq %rdx
callq 0x121e0
testl %eax, %eax
je 0x1405f
cmpw $0x4e46, 0xb(%rsp)      # imm = 0x4E46
je 0x14028
cmpl $0x434f5250, 0xb(%rsp)  # imm = 0x434F5250
je 0x14028
movq 0x30(%r15), %r8
movl 0x38(%r15), %r9d
leaq 0x58043(%rip), %rax     # 0x6c054
leaq 0x59dad(%rip), %rcx     # 0x6ddc5
pushq $0xe
popq %rsi
movq %rbx, %rdi
movq %r12, %rdx
pushq $0x25e                  # imm = 0x25E
jmp 0x13fb8
movl $0x9, 0x8(%r14)
andq $0x0, 0x18(%r14)
pushq $0x1
popq %rdi
movl $0x148, %esi            # imm = 0x148
callq 0x12150
movq %rax, 0x10(%r14)
testq %rax, %rax
je 0x1407e
movl $0x8, (%rax)
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
addq $0x8, %r14
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x2e26b
leaq 0x57fcf(%rip), %rdx     # 0x6c054
pushq $0x1
popq %rsi
movq %rbx, %rdi
movl $0x267, %ecx            # imm = 0x267
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x1429e
nop