// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/parser.c
// Function: prv_check_free_mem
static void prv_check_free_mem(subtilis_parser_t *p, subtilis_token_t *t,
			       subtilis_error_t *err)
{
	size_t reg;
	subtilis_ir_operand_t msg_ptr;
	subtilis_ir_operand_t msg_len_reg;
	subtilis_ir_operand_t msg_len;
	subtilis_ir_operand_t leak_label;
	subtilis_ir_operand_t no_leak_label;
	const char *msg = " BYTES LEAKED!";
	subtilis_exp_t *old_value = NULL;
	subtilis_exp_t *new_value = NULL;

	if (!p->settings.check_mem_leaks)
		return;

	leak_label.label = subtilis_ir_section_new_label(p->current);
	no_leak_label.label = subtilis_ir_section_new_label(p->current);

	old_value =
	    subtilis_var_lookup_var(p, subtilis_heap_free_on_startup_var, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	reg = subtilis_ir_section_add_instr1(p->current,
					     SUBTILIS_OP_INSTR_HEAP_FREE, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	new_value = subtilis_exp_new_int32_var(reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	old_value = subtilis_type_if_sub(p, old_value, new_value, err);
	new_value = NULL;
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  old_value->exp.ir_op, leak_label,
					  no_leak_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_label(p->current, leak_label.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	/*
	 * Any error here would cause the program to loop and possibly never
	 * end.  This is a debug feature but still.  We know dectostr will
	 * not generate an error but we need to ensure backends with native
	 * support for this function won't either.
	 */

	p->settings.ignore_graphics_errors = true;

	subtilis_type_if_print(p, old_value, err);
	old_value = NULL;
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	msg_len.integer = strlen(msg);
	msg_ptr.reg =
	    subtilis_string_type_lca_const(p, msg, msg_len.integer, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	msg_len_reg.reg = subtilis_ir_section_add_instr2(
	    p->current, SUBTILIS_OP_INSTR_MOVI_I32, msg_len, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_instr_no_reg2(
	    p->current, SUBTILIS_OP_INSTR_PRINT_STR, msg_ptr, msg_len_reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_label(p->current, no_leak_label.label, err);

cleanup:

	subtilis_exp_delete(old_value);
	subtilis_exp_delete(new_value);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq 0x92ff3(%rip), %rax     # 0xaa4de
movq %rax, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x8(%rbp), %rax
testb $0x1, 0xba(%rax)
jne 0x17511
jmp 0x17709
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
leaq 0xbd30a(%rip), %rax     # 0xd4848
movq (%rax), %rsi
movq -0x18(%rbp), %rdx
callq 0x47240
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1755c
jmp 0x17709
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %rdx
movl $0x87, %esi
callq 0x384e0
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x17584
jmp 0x176f7
movq -0x20(%rbp), %rax
movl %eax, %edi
movq -0x18(%rbp), %rsi
callq 0x37770
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x175a5
jmp 0x176f7
movq -0x8(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x492c0
movq %rax, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x175d4
jmp 0x176f7
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x58(%rbp), %rax
movq -0x18(%rbp), %r9
movq 0x148(%rax), %rdx
movq -0x40(%rbp), %rcx
movq -0x48(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1760b
jmp 0x176f7
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x40(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x39960
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1762e
jmp 0x176f7
movq -0x8(%rbp), %rax
movb $0x1, 0xb9(%rax)
movq -0x8(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x49f10
movq $0x0, -0x58(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x17660
jmp 0x17709
movq -0x50(%rbp), %rdi
callq 0x120d0
movl %eax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
movslq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x65d80
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x17690
jmp 0x17709
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %rcx
movq -0x38(%rbp), %rdx
movl $0x1b, %esi
callq 0x38490
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x176b9
jmp 0x17709
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %r8
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movl $0x1f, %esi
callq 0x385a0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x176e2
jmp 0x17709
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x48(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x39960
movq -0x58(%rbp), %rdi
callq 0x36ee0
movq -0x60(%rbp), %rdi
callq 0x36ee0
addq $0x60, %rsp
popq %rbp
retq
nop