// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/builtins_ir.c
// Function: prv_compute_whole_int_part
static void prv_compute_whole_int_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 on */

{
	subtilis_ir_operand_t sign;
	subtilis_ir_operand_t op1;
	subtilis_ir_operand_t condee;
	subtilis_ir_operand_t 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 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);
	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 = '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;

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

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_MUL_I32,
					  factor, factor, base, 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 $0xa0, %rsp
movq %rcx, -0xa0(%rbp)
movq %rdx, %rax
movq -0xa0(%rbp), %rdx
movq %rax, -0x98(%rbp)
movq %rsi, %r10
movq -0x98(%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, -0x80(%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
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 0x4690e
jmp 0x46bf4
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %rcx
movq -0x18(%rbp), %rdx
movl $0x1d, %esi
callq 0x38490
movq %rax, -0x70(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x4693a
jmp 0x46bf4
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x80(%rbp), %rsi
movq 0x20(%rbp), %rdx
callq 0x39960
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x4695d
jmp 0x46bf4
movl $0x1, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r9
movq -0x70(%rbp), %rdx
movq -0x70(%rbp), %rcx
movq -0x50(%rbp), %r8
movl $0xb, %esi
callq 0x38360
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x46994
jmp 0x46bf4
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r8
movq -0x70(%rbp), %rdx
movq -0x8(%rbp), %rcx
movl $0x3f, %esi
callq 0x38230
movq %rax, -0x58(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x469c4
jmp 0x46bf4
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r9
movq -0x58(%rbp), %rdx
movq -0x88(%rbp), %rcx
movq -0x30(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x469f7
jmp 0x46bf4
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 0x46a1d
jmp 0x46bf4
movl $0x0, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r8
movq -0x70(%rbp), %rdx
movq -0x50(%rbp), %rcx
movl $0x11, %esi
callq 0x38230
movq %rax, -0x60(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x46a54
jmp 0x46bf4
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 0x46a8b
jmp 0x46bf4
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, -0x68(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x46abb
jmp 0x46bf4
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r9
movq -0x38(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %r8
movl $0x4, %esi
callq 0x38360
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x46aeb
jmp 0x46bf4
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r9
movq -0x20(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x68(%rbp), %r8
xorl %esi, %esi
callq 0x38360
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x46b18
jmp 0x46bf4
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r9
movq -0x20(%rbp), %rdx
movq -0x90(%rbp), %rcx
movq -0x80(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x46b4b
jmp 0x46bf4
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 0x46b71
jmp 0x46bf4
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, -0x78(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x46b9e
jmp 0x46bf4
movl $0x80000000, -0x50(%rbp) # imm = 0x80000000
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r8
movq -0x78(%rbp), %rdx
movq -0x50(%rbp), %rcx
movl $0x25, %esi
callq 0x38230
movq %rax, -0x78(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x46bd2
jmp 0x46bf4
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r9
movq -0x78(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x80(%rbp), %r8
movl $0x43, %esi
callq 0x38360
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)