// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/builtins_ir.c
// Function: prv_compute_whole_hex_part
static void prv_compute_whole_hex_part(subtilis_parser_t *p,
				       subtilis_ir_operand_t str_data,
				       subtilis_ir_operand_t base,
				       subtilis_ir_operand_t ptr,
				       subtilis_ir_operand_t ret_val,
				       subtilis_ir_operand_t overflow_label,
				       subtilis_ir_operand_t end_label,
				       subtilis_ir_operand_t factor,
				       subtilis_error_t *err)
/* clang-format off */

{
	subtilis_ir_operand_t sign;
	subtilis_ir_operand_t op1;
	subtilis_ir_operand_t condee;
	subtilis_ir_operand_t byte;
	subtilis_ir_operand_t ored_byte;
	subtilis_ir_operand_t product;
	subtilis_ir_operand_t new_ptr;
	subtilis_ir_operand_t overflow;
	subtilis_ir_operand_t whole_start_label;
	subtilis_ir_operand_t process_whole_label;
	subtilis_ir_operand_t hex_digit_label;
	subtilis_ir_operand_t skip_dec_label;
	subtilis_ir_operand_t dec_digit_label;
	subtilis_ir_operand_t check_overflow_label;

	whole_start_label.label = subtilis_ir_section_new_label(p->current);
	process_whole_label.label = subtilis_ir_section_new_label(p->current);
	hex_digit_label.label = subtilis_ir_section_new_label(p->current);
	dec_digit_label.label = subtilis_ir_section_new_label(p->current);
	skip_dec_label.label = subtilis_ir_section_new_label(p->current);
	check_overflow_label.label = subtilis_ir_section_new_label(p->current);

	sign.reg = subtilis_ir_section_add_instr2(
	    p->current, SUBTILIS_OP_INSTR_MOV, factor, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	new_ptr.reg = subtilis_ir_section_add_instr2(
	    p->current, SUBTILIS_OP_INSTR_MOV, ptr, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_label(p->current, whole_start_label.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	op1.integer = 1;
	subtilis_ir_section_add_instr_reg(
	    p->current, SUBTILIS_OP_INSTR_SUBI_I32, new_ptr, new_ptr, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	condee.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_GTE_I32, new_ptr, str_data, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  condee, process_whole_label,
					  end_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_label(p->current, process_whole_label.label,
				      err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	op1.integer = 0;
	byte.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LOADO_I8, new_ptr, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	op1.integer = '9';
	condee.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_GTI_I32, byte, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  condee, hex_digit_label,
					  dec_digit_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_label(p->current, hex_digit_label.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	op1.integer = 32;
	ored_byte.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_ORI_I32, byte, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	op1.integer = 'a' - 10;
	subtilis_ir_section_add_instr_reg(
	    p->current, SUBTILIS_OP_INSTR_SUBI_I32, byte, ored_byte, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_instr_no_reg(p->current, SUBTILIS_OP_INSTR_JMP,
					     skip_dec_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_label(p->current, dec_digit_label.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	op1.integer = '0';
	subtilis_ir_section_add_instr_reg(
	    p->current, SUBTILIS_OP_INSTR_SUBI_I32, byte, byte, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_label(p->current, skip_dec_label.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	product.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_MUL_I32, byte, factor, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	op1.integer = 4;
	subtilis_ir_section_add_instr_reg(
	    p->current, SUBTILIS_OP_INSTR_LSLI_I32, factor, factor, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_ADD_I32,
					  ret_val, ret_val, product, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  ret_val, check_overflow_label,
					  whole_start_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_label(p->current, check_overflow_label.label,
				      err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	/*
	 * Now check for overflow.  We EOR the sign and the sum
	 * together.  If the top bit is set we've overflowed.
	 */

	overflow.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_EOR_I32, ret_val, sign, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	op1.integer = 0x80000000;
	overflow.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_ANDI_I32, overflow, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  overflow, overflow_label,
					  whole_start_label, err);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rcx, -0xc0(%rbp)
movq %rdx, %rax
movq -0xc0(%rbp), %rdx
movq %rax, -0xb8(%rbp)
movq %rsi, %r10
movq -0xb8(%rbp), %rsi
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rcx
movq %r10, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq %rax, -0x38(%rbp)
movq %rdi, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x88(%rbp)
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x90(%rbp)
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x98(%rbp)
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0xa8(%rbp)
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0xa0(%rbp)
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0xb0(%rbp)
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %rcx
movq -0x38(%rbp), %rdx
movl $0x1d, %esi
callq 0x38490
movq %rax, -0x48(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x463cd
jmp 0x4683b
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %rcx
movq -0x18(%rbp), %rdx
movl $0x1d, %esi
callq 0x38490
movq %rax, -0x78(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x463f9
jmp 0x4683b
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x88(%rbp), %rsi
movq 0x20(%rbp), %rdx
callq 0x39960
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x4641f
jmp 0x4683b
movl $0x1, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r9
movq -0x78(%rbp), %rdx
movq -0x78(%rbp), %rcx
movq -0x50(%rbp), %r8
movl $0xb, %esi
callq 0x38360
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x46456
jmp 0x4683b
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r8
movq -0x78(%rbp), %rdx
movq -0x8(%rbp), %rcx
movl $0x3f, %esi
callq 0x38230
movq %rax, -0x58(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x46486
jmp 0x4683b
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r9
movq -0x58(%rbp), %rdx
movq -0x90(%rbp), %rcx
movq -0x30(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x464b9
jmp 0x4683b
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x90(%rbp), %rsi
movq 0x20(%rbp), %rdx
callq 0x39960
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x464df
jmp 0x4683b
movl $0x0, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r8
movq -0x78(%rbp), %rdx
movq -0x50(%rbp), %rcx
movl $0x11, %esi
callq 0x38230
movq %rax, -0x60(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x46516
jmp 0x4683b
movl $0x39, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r8
movq -0x60(%rbp), %rdx
movq -0x50(%rbp), %rcx
movl $0x35, %esi
callq 0x38230
movq %rax, -0x58(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x4654d
jmp 0x4683b
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r9
movq -0x58(%rbp), %rdx
movq -0x98(%rbp), %rcx
movq -0xa8(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x46583
jmp 0x4683b
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x98(%rbp), %rsi
movq 0x20(%rbp), %rdx
callq 0x39960
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x465a9
jmp 0x4683b
movl $0x20, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r8
movq -0x60(%rbp), %rdx
movq -0x50(%rbp), %rcx
movl $0x27, %esi
callq 0x38230
movq %rax, -0x68(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x465e0
jmp 0x4683b
movl $0x57, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r9
movq -0x60(%rbp), %rdx
movq -0x68(%rbp), %rcx
movq -0x50(%rbp), %r8
movl $0xb, %esi
callq 0x38360
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x46617
jmp 0x4683b
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %rcx
movq -0xa0(%rbp), %rdx
movl $0x45, %esi
callq 0x38540
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x46642
jmp 0x4683b
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0xa8(%rbp), %rsi
movq 0x20(%rbp), %rdx
callq 0x39960
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x46668
jmp 0x4683b
movl $0x30, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r9
movq -0x60(%rbp), %rdx
movq -0x60(%rbp), %rcx
movq -0x50(%rbp), %r8
movl $0xb, %esi
callq 0x38360
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x4669f
jmp 0x4683b
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0xa0(%rbp), %rsi
movq 0x20(%rbp), %rdx
callq 0x39960
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x466c5
jmp 0x4683b
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r8
movq -0x60(%rbp), %rdx
movq -0x38(%rbp), %rcx
movl $0x4, %esi
callq 0x38230
movq %rax, -0x70(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x466f5
jmp 0x4683b
movl $0x4, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r9
movq -0x38(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x50(%rbp), %r8
movl $0x4c, %esi
callq 0x38360
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x4672c
jmp 0x4683b
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r9
movq -0x20(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x70(%rbp), %r8
xorl %esi, %esi
callq 0x38360
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x46759
jmp 0x4683b
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r9
movq -0x20(%rbp), %rdx
movq -0xb0(%rbp), %rcx
movq -0x88(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x4678f
jmp 0x4683b
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0xb0(%rbp), %rsi
movq 0x20(%rbp), %rdx
callq 0x39960
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x467b5
jmp 0x4683b
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r8
movq -0x20(%rbp), %rdx
movq -0x48(%rbp), %rcx
movl $0x28, %esi
callq 0x38230
movq %rax, -0x80(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x467e2
jmp 0x4683b
movl $0x80000000, -0x50(%rbp) # imm = 0x80000000
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r8
movq -0x80(%rbp), %rdx
movq -0x50(%rbp), %rcx
movl $0x25, %esi
callq 0x38230
movq %rax, -0x80(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x46816
jmp 0x4683b
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r9
movq -0x80(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x88(%rbp), %r8
movl $0x43, %esi
callq 0x38360
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)