// File: /workspace/github_c_makefile_star2_O2/markdryan[P]subtilis/frontend/parser.c
// Function: subtilis_parser_new
subtilis_parser_t *subtilis_parser_new(subtilis_lexer_t *l,
				       const subtilis_backend_t *backend,
				       const subtilis_settings_t *settings,
				       subtilis_error_t *err)
{
	const subtilis_symbol_t *s;
	subtilis_parser_t *p = calloc(1, sizeof(*p));
	subtilis_type_section_t *stype = NULL;

	if (!p) {
		subtilis_error_set_oom(err);
		goto on_error;
	}

	p->settings = *settings;

	p->st = subtilis_symbol_table_new(err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;

	p->main_st = subtilis_symbol_table_new(err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;
	p->local_st = p->main_st;

	p->prog = subtilis_ir_prog_new(&p->settings, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;

	stype =
	    subtilis_type_section_new(&subtilis_type_void, 0, NULL, NULL, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;

	/*
	 * We pre-seed the symbol table here to ensure that these variables
	 * have offsets 0 and 0 + sizeof(INT).
	 */

	s = subtilis_symbol_table_insert(p->st, subtilis_eflag_hidden_var,
					 &subtilis_type_integer, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;

	p->eflag_offset = (int32_t)s->loc;
	p->error_offset = s->size;
	s = subtilis_symbol_table_insert(p->st, subtilis_err_hidden_var,
					 &subtilis_type_integer, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;

	p->current = subtilis_ir_prog_section_new(
	    p->prog, SUBTILIS_MAIN_FN, 0, stype, SUBTILIS_BUILTINS_MAX,
	    l->stream->name, l->line, p->eflag_offset, p->error_offset, NULL,
	    err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;
	stype = NULL;
	p->main = p->current;

	p->l = l;
	p->backend = *backend;
	p->level = 0;

	return p;

on_error:

	subtilis_type_section_delete(stype);
	subtilis_parser_delete(p);

	return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rcx, %r15
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %r12
pushq $0x1
popq %rdi
movl $0xc0, %esi
callq 0x12150
movq %rax, %rbx
testq %rax, %rax
je 0x14c45
movb 0x2(%r13), %al
movb %al, 0xba(%rbx)
movzwl (%r13), %eax
movw %ax, 0xb8(%rbx)
movq %r15, %rdi
callq 0x2ca24
movq %rax, 0x60(%rbx)
cmpl $0x0, (%r15)
jne 0x14c5a
movq %r15, %rdi
callq 0x2ca24
movq %rax, 0x70(%rbx)
cmpl $0x0, (%r15)
jne 0x14c5a
movq %rbx, %rdi
addq $0xb8, %rdi
movq %rax, 0x68(%rbx)
movq %r15, %rsi
callq 0x2ac2e
movq %rax, 0x58(%rbx)
cmpl $0x0, (%r15)
jne 0x14c5a
leaq 0x5a159(%rip), %rdi     # 0x6eca0
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r15, %r8
callq 0x2d9c4
movq %rax, %r13
cmpl $0x0, (%r15)
jne 0x14c5d
movq 0x60(%rbx), %rdi
leaq 0x9160b(%rip), %rax     # 0xa6178
movq (%rax), %rsi
leaq 0x59d51(%rip), %rdx     # 0x6e8c8
movq %r15, %rcx
callq 0x2cbb7
cmpl $0x0, (%r15)
jne 0x14c5d
movl (%rax), %ecx
movl %ecx, 0xb0(%rbx)
movl 0x2a0(%rax), %eax
movl %eax, 0xb4(%rbx)
movq 0x60(%rbx), %rdi
leaq 0x915d8(%rip), %rax     # 0xa6180
movq (%rax), %rsi
leaq 0x59d16(%rip), %rdx     # 0x6e8c8
movq %r15, %rcx
callq 0x2cbb7
cmpl $0x0, (%r15)
jne 0x14c5d
movq 0x58(%rbx), %rdi
movq 0x30(%r12), %r9
movl 0x38(%r12), %eax
movl 0xb0(%rbx), %ecx
movl 0xb4(%rbx), %edx
movq %r15, 0x20(%rsp)
movl %edx, 0x10(%rsp)
movl %ecx, 0x8(%rsp)
movq %rax, (%rsp)
andq $0x0, 0x18(%rsp)
leaq 0x5889f(%rip), %rsi     # 0x6d49b
pushq $0x9
popq %r8
xorl %edx, %edx
movq %r13, %rcx
callq 0x2acef
movq %rax, 0x48(%rbx)
cmpl $0x0, (%r15)
jne 0x14c5d
movq %rax, 0x50(%rbx)
movq %r12, (%rbx)
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups 0x30(%r14), %xmm3
movups %xmm0, 0x8(%rbx)
movups %xmm1, 0x18(%rbx)
movups %xmm2, 0x28(%rbx)
movups %xmm3, 0x38(%rbx)
andq $0x0, 0x78(%rbx)
jmp 0x14c6f
leaq 0x5883d(%rip), %rdx     # 0x6d489
pushq $0x1
popq %rsi
pushq $0x36
popq %rcx
movq %r15, %rdi
callq 0x1429e
xorl %r13d, %r13d
movq %r13, %rdi
callq 0x2dc17
movq %rbx, %rdi
callq 0x14c80
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq