// File: /workspace/github_c_makefile_star2_O1/markdryan[P]subtilis/frontend/symbol_table.c
// Function: prv_symbol_table_insert
static const subtilis_symbol_t *
prv_symbol_table_insert(subtilis_symbol_table_t *st, const char *key,
			const subtilis_type_t *id_type,
			const subtilis_type_t *sub_type, size_t size,
			size_t level, bool no_rc, subtilis_error_t *err)

{
	subtilis_symbol_t *sym;
	size_t align_bytes;
	size_t required_alignment;
	char *key_dup = NULL;

	sym = subtilis_hashtable_find(st->h, key);
	if (sym)
		return sym;

	key_dup = malloc(strlen(key) + 1);
	if (!key_dup) {
		subtilis_error_set_oom(err);
		goto on_error;
	}
	(void)strcpy(key_dup, key);

	/*
	 * TODO:  This can leave holes in our global data.  It would
	 * be good to keep track of those holes so we could plug them
	 * with bytes variables.
	 */

	if (size > 0) {
		required_alignment = subtilis_type_if_align(id_type, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;
		align_bytes = st->allocated % required_alignment;
		if (align_bytes > 0)
			st->allocated += required_alignment - align_bytes;
	}

	sym = prv_symbol_new(key_dup, st->allocated, id_type, sub_type, size,
			     false, no_rc, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;

	prv_ensure_symbol_level(st, level, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;
	st->levels[level].symbols[st->levels[level].size++] = sym;

	(void)subtilis_hashtable_insert(st->h, key_dup, sym, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;

	st->allocated += sym->size;
	if (st->allocated > st->max_allocated)
		st->max_allocated = st->allocated;

	return sym;

on_error:
	free(key_dup);
	prv_symbol_delete(sym);
	return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, 0x10(%rsp)
movq %r8, %rbx
movq %rcx, %r15
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %r12
movq 0x300(%rdi), %rdi
callq 0x2e1f3
movq %rax, %rbp
testq %rax, %rax
jne 0x2e8b5
movq %r12, (%rsp)
movq %r15, 0x8(%rsp)
movq 0x58(%rsp), %r12
movq %r14, %rdi
callq 0x120f0
leaq 0x1(%rax), %rdi
callq 0x121d0
movq %rax, %rbp
testq %rax, %rax
je 0x2e7c9
movq %rbp, %rdi
movq %r14, %rsi
callq 0x12070
movq %rbx, %r8
testq %rbx, %rbx
je 0x2e81b
movq %r13, %rdi
movq %r12, %rsi
callq 0x35f0e
cmpl $0x0, (%r12)
je 0x2e7ec
movq %rbp, %r14
jmp 0x2e7e5
movq %rbp, %r14
leaq 0x45adf(%rip), %rdx     # 0x742b2
movq %r12, %rdi
movl $0x1, %esi
movl $0xb7, %ecx
callq 0x145f4
xorl %ebp, %ebp
jmp 0x2e8a3
movq %rax, %rcx
movq (%rsp), %rax
movq 0x308(%rax), %rsi
movq %rsi, %rax
xorl %edx, %edx
divq %rcx
testq %rdx, %rdx
movq %rbx, %r8
je 0x2e81b
addq %rcx, %rsi
subq %rdx, %rsi
movq (%rsp), %rax
movq %rsi, 0x308(%rax)
movb 0x50(%rsp), %al
movq (%rsp), %rbx
movq 0x308(%rbx), %rsi
movzbl %al, %eax
movq %rbp, %r14
movq %rbp, %rdi
movq %r13, %rdx
movq 0x8(%rsp), %rcx
xorl %r9d, %r9d
pushq %r12
pushq %rax
callq 0x2ed63
addq $0x10, %rsp
movq %rax, %rbp
cmpl $0x0, (%r12)
jne 0x2e8a3
movq %rbx, %rdi
movq 0x10(%rsp), %r15
movq %r15, %rsi
movq %r12, %rdx
callq 0x2ee67
cmpl $0x0, (%r12)
jne 0x2e8a3
leaq (%r15,%r15,2), %rax
movq (%rbx,%rax,8), %rcx
movq 0x10(%rbx,%rax,8), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rbx,%rax,8)
movq %rbp, (%rdx,%rcx,8)
movq 0x300(%rbx), %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq %r12, %rcx
callq 0x2e248
cmpl $0x0, (%r12)
je 0x2e8c7
movq %r14, %rdi
callq 0x122c0
movq %rbp, %rdi
callq 0x2e5bf
xorl %ebp, %ebp
movq %rbp, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x308(%rbx), %rax
addq 0x2a0(%rbp), %rax
movq %rax, 0x308(%rbx)
cmpq 0x310(%rbx), %rax
jbe 0x2e8b5
movq %rax, 0x310(%rbx)
jmp 0x2e8b5