// File: /workspace/github_c_makefile_star2_O2/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, %r12
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %rbp
movq 0x300(%rdi), %rdi
callq 0x2c748
movq %rax, %r15
testq %rax, %rax
jne 0x2cd84
movq %r12, 0x8(%rsp)
movq 0x58(%rsp), %r12
movq %r14, %rdi
callq 0x120f0
leaq 0x1(%rax), %rdi
callq 0x121d0
movq %rax, %r15
testq %rax, %rax
je 0x2cc97
movq %r15, %rdi
movq %r14, %rsi
callq 0x12070
testq %rbx, %rbx
je 0x2ccb9
movq %r13, %rdi
movq %r12, %rsi
callq 0x33e26
cmpl $0x0, (%r12)
je 0x2ccca
movq %r15, %r14
jmp 0x2ccb1
movq %r15, %r14
leaq 0x415e1(%rip), %rdx     # 0x6e282
pushq $0x1
popq %rsi
movq %r12, %rdi
movl $0xb7, %ecx
callq 0x1429e
xorl %r15d, %r15d
jmp 0x2cd71
movq %rbx, %r8
movq 0x308(%rbp), %rsi
movq 0x8(%rsp), %rcx
jmp 0x2ccf6
movq %rax, %rdi
movq 0x308(%rbp), %rsi
movq %rsi, %rax
xorl %edx, %edx
divq %rdi
testq %rdx, %rdx
movq 0x8(%rsp), %rcx
je 0x2ccf3
addq %rdi, %rsi
subq %rdx, %rsi
movq %rsi, 0x308(%rbp)
movq %rbx, %r8
movb 0x50(%rsp), %al
movzbl %al, %eax
movq %r15, %r14
movq %r15, %rdi
movq %r13, %rdx
xorl %r9d, %r9d
movq %r12, %r13
pushq %r12
pushq %rax
callq 0x2d230
popq %rcx
popq %rdx
movq %rax, %r15
cmpl $0x0, (%r12)
jne 0x2cd71
movq %rbp, %rdi
movq 0x10(%rsp), %r12
movq %r12, %rsi
movq %r13, %rdx
callq 0x2d317
cmpl $0x0, (%r13)
jne 0x2cd71
imulq $0x18, %r12, %rax
movq (%rbp,%rax), %rcx
movq 0x10(%rbp,%rax), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rbp,%rax)
movq %r15, (%rdx,%rcx,8)
movq 0x300(%rbp), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x2c7ad
cmpl $0x0, (%r13)
je 0x2cd96
movq %r14, %rdi
callq 0x122c0
movq %r15, %rdi
callq 0x2caa0
xorl %r15d, %r15d
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x308(%rbp), %rax
addq 0x2a0(%r15), %rax
movq %rax, 0x308(%rbp)
cmpq 0x310(%rbp), %rax
jbe 0x2cd84
movq %rax, 0x310(%rbp)
jmp 0x2cd84