// File: /workspace/github_c_makefile_star2_O3/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
movq %rdx, %rsi
callq 0x139f9
cmpl $0x0, (%rbx)
je 0x14225
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
xorl %r12d, %r12d
movq 0x40(%r15), %rax
cmpq 0x360(%r15), %rax
je 0x14292
movq 0x368(%r15), %rcx
movb (%rcx,%rax), %r13b
movl %r13d, %eax
andb $-0x21, %al
addb $-0x41, %al
cmpb $0x1a, %al
jb 0x1425f
leal -0x30(%r13), %eax
cmpb $0xa, %al
setae %al
cmpb $0x5f, %r13b
setne %cl
testb %al, %cl
jne 0x14292
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x13c66
cmpl $0x0, (%rbx)
jne 0x14217
cmpq $0x3, %r12
ja 0x1427d
movb %r13b, 0xb(%rsp,%r12)
incq %r12
movq %r15, %rdi
movq %rbx, %rsi
callq 0x139f9
cmpl $0x0, (%rbx)
je 0x14228
jmp 0x14217
movq %r14, %rdi
callq 0x12ad0
cmpq $0x1, %r12
ja 0x142d6
movq 0x30(%r15), %r8
movl 0x38(%r15), %r9d
leaq 0x5dda5(%rip), %r10     # 0x72054
leaq 0x5fb5f(%rip), %rcx     # 0x73e15
movq %rbx, %rdi
movl $0xe, %esi
movq %rax, %rdx
pushq $0x249                  # imm = 0x249
pushq %r10
callq 0x143da
addq $0x20, %rsp
jmp 0x1421b
cmpq $0x4, %r12
movl $0x4, %ecx
cmovbq %r12, %rcx
movb $0x0, 0xb(%rsp,%rcx)
movzwl 0xb(%rsp), %ecx
xorl $0x4552, %ecx           # imm = 0x4552
movzbl 0xd(%rsp), %edx
xorl $0x43, %edx
orw %cx, %dx
je 0x1436e
cmpw $0x4e46, 0xb(%rsp)      # imm = 0x4E46
je 0x1433b
cmpl $0x434f5250, 0xb(%rsp)  # imm = 0x434F5250
je 0x1433b
movq 0x30(%r15), %r8
movl 0x38(%r15), %r9d
leaq 0x5dd32(%rip), %r10     # 0x72054
leaq 0x5faec(%rip), %rcx     # 0x73e15
movq %rbx, %rdi
movl $0xe, %esi
movq %rax, %rdx
pushq $0x25e                  # imm = 0x25E
jmp 0x142c6
movl $0x9, 0x8(%r14)
movq $0x0, 0x18(%r14)
movl $0x1, %edi
movl $0x148, %esi            # imm = 0x148
callq 0x12150
movq %rax, 0x10(%r14)
testq %rax, %rax
je 0x1438d
movl $0x8, (%rax)
jmp 0x14217
addq $0x8, %r14
movq %r14, %rdi
movq %rax, %rsi
movq %rbx, %rdx
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x2fba9
leaq 0x5dcc0(%rip), %rdx     # 0x72054
movq %rbx, %rdi
movl $0x1, %esi
movl $0x267, %ecx            # imm = 0x267
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x145a4
nop