// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/builtins_ir.c
// Function: prv_builtins_ir_hexstr_to_int32
static void prv_builtins_ir_hexstr_to_int32(subtilis_parser_t *p,
					    subtilis_ir_section_t *current,
					    subtilis_error_t *err)
{
	subtilis_ir_section_t *old_current;
	subtilis_ir_operand_t str;
	subtilis_ir_operand_t str_data;
	subtilis_ir_operand_t base;
	subtilis_ir_operand_t str_len;
	subtilis_ir_operand_t end_str;
	subtilis_ir_operand_t ptr;
	subtilis_ir_operand_t condee;
	subtilis_ir_operand_t end_label;
	subtilis_ir_operand_t ret_val;
	subtilis_ir_operand_t op1;
	subtilis_ir_operand_t factor;
	subtilis_ir_operand_t plus_minus_label;
	subtilis_ir_operand_t overflow_label;
	subtilis_exp_t *e = NULL;

	old_current = p->current;
	p->current = current;

	str.reg = SUBTILIS_IR_REG_TEMP_START;
	base.reg = SUBTILIS_IR_REG_TEMP_START + 1;
	end_label.label = current->end_label;
	ret_val.reg = current->ret_reg;
	plus_minus_label.label = subtilis_ir_section_new_label(current);
	overflow_label.label = subtilis_ir_section_new_label(current);

	op1.integer = 0;
	subtilis_ir_section_add_instr_no_reg2(
	    p->current, SUBTILIS_OP_INSTR_MOVI_I32, ret_val, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	str_len.reg = subtilis_reference_type_get_size(p, str.reg, 0, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	op1.integer = 0;
	condee.reg = subtilis_ir_section_add_instr(
	    current, SUBTILIS_OP_INSTR_GTI_I32, str_len, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_instr_reg(current, SUBTILIS_OP_INSTR_JMPC,
					  condee, plus_minus_label, end_label,
					  err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	str_data.reg = subtilis_reference_get_data(p, str.reg, 0, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	end_str.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_ADD_I32, str_data, str_len, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	ptr.reg = prv_find_first_stop_hex(p, str_data, str_len, end_str,
					  end_label, &factor, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	prv_compute_whole_hex_part(p, str_data, base, ptr, ret_val,
				   overflow_label, end_label, factor, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	subtilis_ir_section_add_instr_no_reg(current, SUBTILIS_OP_INSTR_RET_I32,
					     ret_val, err);

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

	e = subtilis_exp_new_int32(SUBTILIS_ERROR_CODE_NUMBER_TOO_BIG, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_exp_generate_error(p, e, err);
	e = NULL;
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

cleanup:
	p->current = old_current;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x90(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x48(%rax)
movq $0x4, -0x28(%rbp)
movq $0x5, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0xa8(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
callq 0x39940
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rdi
callq 0x39940
movq %rax, -0x88(%rbp)
movl $0x0, -0x70(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %r8
movq -0x68(%rbp), %rdx
movq -0x70(%rbp), %rcx
movl $0x1b, %esi
callq 0x385a0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x441e8
jmp 0x44400
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x18(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
callq 0x6dc00
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x4420f
jmp 0x44400
movl $0x0, -0x70(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %r8
movq -0x40(%rbp), %rdx
movq -0x70(%rbp), %rcx
movl $0x35, %esi
callq 0x38230
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x44242
jmp 0x44400
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %r9
movq -0x58(%rbp), %rdx
movq -0x80(%rbp), %rcx
movq -0x60(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x4426e
jmp 0x44400
movq -0x10(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x39960
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x4428d
jmp 0x44400
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x18(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
callq 0x6d1e0
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x442b4
jmp 0x44400
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %r8
movq -0x30(%rbp), %rdx
movq -0x40(%rbp), %rcx
xorl %esi, %esi
callq 0x38230
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x442e1
jmp 0x44400
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq -0x60(%rbp), %r8
leaq -0x78(%rbp), %r9
movq %rax, (%rsp)
callq 0x46040
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x44318
jmp 0x44400
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x50(%rbp), %rcx
movq -0x68(%rbp), %r8
movq -0x88(%rbp), %r9
movq -0x60(%rbp), %r11
movq -0x78(%rbp), %r10
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x462d0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x44360
jmp 0x44400
movq -0x10(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x39960
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x4437f
jmp 0x44400
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rcx
movq -0x68(%rbp), %rdx
movl $0x47, %esi
callq 0x38540
movq -0x10(%rbp), %rdi
movq -0x88(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x39960
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x443b4
jmp 0x44400
movq -0x18(%rbp), %rsi
movl $0x14, %edi
callq 0x37800
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x443d4
jmp 0x44400
movq -0x8(%rbp), %rdi
movq -0x90(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x37d10
movq $0x0, -0x90(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x443fe
jmp 0x44400
jmp 0x44400
movq -0x20(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x48(%rax)
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)