// File: /workspace/github_c_makefile_star2_O1/markdryan[P]subtilis/frontend/builtins_ir.c
// Function: prv_compute_fractional_part
static void prv_compute_fractional_part(subtilis_parser_t *p,
					subtilis_ir_operand_t end_str,
					subtilis_ir_operand_t ptr,
					subtilis_ir_operand_t ret_val,
					subtilis_ir_operand_t factor,
					subtilis_error_t *err)
{
	subtilis_ir_operand_t condee;
	subtilis_ir_operand_t byte;
	subtilis_ir_operand_t bytef;
	subtilis_ir_operand_t op1;
	subtilis_ir_operand_t le_9;
	subtilis_ir_operand_t product;
	subtilis_ir_operand_t have_fractional_label;
	subtilis_ir_operand_t no_fractional_label;
	subtilis_ir_operand_t decimal_point_label;
	subtilis_ir_operand_t process_digit_label;
	subtilis_ir_operand_t keep_looking_label;
	subtilis_ir_operand_t loop_label;

	have_fractional_label.label = subtilis_ir_section_new_label(p->current);
	no_fractional_label.label = subtilis_ir_section_new_label(p->current);
	decimal_point_label.label = subtilis_ir_section_new_label(p->current);
	process_digit_label.label = subtilis_ir_section_new_label(p->current);
	keep_looking_label.label = subtilis_ir_section_new_label(p->current);
	loop_label.label = subtilis_ir_section_new_label(p->current);

	op1.integer = 0;
	condee.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LT_I32, ptr, end_str, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

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

	subtilis_ir_section_add_label(p->current, have_fractional_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, ptr, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

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

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

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

	op1.real = 0.1;
	factor.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_MULI_REAL, factor, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

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

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

	condee.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LT_I32, ptr, end_str, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

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

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

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

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

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

	condee.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_AND_I32, condee, le_9, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

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

	subtilis_ir_section_add_label(p->current, process_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;

	bytef.reg = subtilis_ir_section_add_instr2(
	    p->current, SUBTILIS_OP_INSTR_MOV_I32_FP, byte, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

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

	op1.real = 0.1;
	subtilis_ir_section_add_instr_reg(
	    p->current, SUBTILIS_OP_INSTR_MULI_REAL, factor, factor, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

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

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

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %rbx
movq %r8, 0x30(%rsp)
movq %rcx, 0x28(%rsp)
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %r14
movq 0x48(%rdi), %rdi
callq 0x2d00a
movq %rax, %r15
movq 0x48(%r14), %rdi
callq 0x2d00a
movq %rax, 0x8(%rsp)
movq 0x48(%r14), %rdi
callq 0x2d00a
movq %rax, %rbp
movq 0x48(%r14), %rdi
callq 0x2d00a
movq %rax, 0x10(%rsp)
movq 0x48(%r14), %rdi
callq 0x2d00a
movq %rax, 0x18(%rsp)
movq 0x48(%r14), %rdi
callq 0x2d00a
movq %rax, 0x20(%rsp)
movq 0x48(%r14), %rdi
movl $0x3b, %esi
movq %r12, %rdx
movq %r13, %rcx
movq %rbx, %r8
callq 0x2c00f
cmpl $0x0, (%rbx)
jne 0x33002
movq 0x48(%r14), %rdi
movl $0x43, %esi
movq %rax, %rdx
movq %r15, %rcx
movq 0x8(%rsp), %r8
movq %rbx, %r9
callq 0x2c0c2
cmpl $0x0, (%rbx)
jne 0x33002
movq 0x48(%r14), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x2d017
cmpl $0x0, (%rbx)
jne 0x33002
movq 0x48(%r14), %rdi
movl $0x11, %esi
movq %r12, %rdx
xorl %ecx, %ecx
movq %rbx, %r8
callq 0x2c00f
cmpl $0x0, (%rbx)
jne 0x33002
movq 0x48(%r14), %rdi
movl $0x2e, %ecx
movl $0x2d, %esi
movq %rax, %rdx
movq %rbx, %r8
movq %rax, %r15
callq 0x2c00f
cmpl $0x0, (%rbx)
jne 0x33002
movq 0x48(%r14), %rdi
movl $0x43, %esi
movq %rax, %rdx
movq %rbp, %rcx
movq 0x8(%rsp), %r8
movq %rbx, %r9
callq 0x2c0c2
cmpl $0x0, (%rbx)
jne 0x33002
movq 0x48(%r14), %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x2d017
cmpl $0x0, (%rbx)
jne 0x33002
movabsq $0x3fb999999999999a, %rcx # imm = 0x3FB999999999999A
movq 0x48(%r14), %rdi
movl $0xe, %esi
movq 0x30(%rsp), %rdx
movq %rbx, %r8
callq 0x2c00f
cmpl $0x0, (%rbx)
jne 0x33002
movq %rax, %rbp
movq 0x48(%r14), %rdi
movq 0x20(%rsp), %rsi
movq %rbx, %rdx
callq 0x2d017
cmpl $0x0, (%rbx)
jne 0x33002
movabsq $0x3fb9999900000030, %rax # imm = 0x3FB9999900000030
movq 0x48(%r14), %rdi
leaq -0x2f(%rax), %r8
movl $0x9, %esi
movq %r12, %rdx
movq %r12, %rcx
movq %rbx, %r9
callq 0x2c0c2
cmpl $0x0, (%rbx)
jne 0x33002
movq 0x48(%r14), %rdi
movl $0x3b, %esi
movq %r12, %rdx
movq %r13, %rcx
movq %rbx, %r8
callq 0x2c00f
cmpl $0x0, (%rbx)
jne 0x33002
movq 0x48(%r14), %rdi
movl $0x43, %esi
movq %rax, %rdx
movq 0x18(%rsp), %rcx
movq 0x8(%rsp), %r8
movq %rbx, %r9
callq 0x2c0c2
cmpl $0x0, (%rbx)
jne 0x33002
movq 0x48(%r14), %rdi
movq 0x18(%rsp), %rsi
movq %rbx, %rdx
callq 0x2d017
cmpl $0x0, (%rbx)
jne 0x33002
movq %r15, %rdx
movq 0x48(%r14), %rdi
movabsq $0x3fb9999900000030, %rax # imm = 0x3FB9999900000030
leaq -0x30(%rax), %r8
movl $0x11, %esi
movq %r12, %rcx
movq %rbx, %r9
callq 0x2c0c2
cmpl $0x0, (%rbx)
jne 0x33002
movq %r15, %rdx
movq 0x48(%r14), %rdi
movl $0x41, %esi
movabsq $0x3fb9999900000030, %rcx # imm = 0x3FB9999900000030
movq %rbx, %r8
callq 0x2c00f
cmpl $0x0, (%rbx)
jne 0x33002
movq %r15, %rdx
movq %rax, %r12
movq 0x48(%r14), %rdi
movabsq $0x3fb9999900000030, %rax # imm = 0x3FB9999900000030
leaq 0x9(%rax), %rcx
movl $0x39, %esi
movq %rbx, %r8
callq 0x2c00f
cmpl $0x0, (%rbx)
jne 0x33002
movq 0x48(%r14), %rdi
movl $0x24, %esi
movq %r12, %rdx
movq %rax, %rcx
movq %rbx, %r8
callq 0x2c00f
cmpl $0x0, (%rbx)
jne 0x33002
movq 0x48(%r14), %rdi
movl $0x43, %esi
movq %rax, %rdx
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %r8
movq %rbx, %r9
callq 0x2c0c2
cmpl $0x0, (%rbx)
jne 0x33002
movq 0x48(%r14), %rdi
movq 0x10(%rsp), %rsi
movq %rbx, %rdx
callq 0x2d017
cmpl $0x0, (%rbx)
jne 0x33002
movq %r15, %rcx
movq 0x48(%r14), %rdi
movl $0xb, %esi
movq %r15, %rdx
movabsq $0x3fb9999900000030, %r8 # imm = 0x3FB9999900000030
movq %rbx, %r9
callq 0x2c0c2
cmpl $0x0, (%rbx)
jne 0x33002
movq 0x48(%r14), %rdi
movl $0x51, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x2c189
cmpl $0x0, (%rbx)
jne 0x33002
movq 0x48(%r14), %rdi
movl $0x5, %esi
movq %rax, %rdx
movq %rbp, %rcx
movq %rbx, %r8
callq 0x2c00f
cmpl $0x0, (%rbx)
jne 0x33002
movq %rax, %r15
movq 0x48(%r14), %rdi
movl $0xe, %esi
movq %rbp, %rdx
movq %rbp, %rcx
movabsq $0x3fb999999999999a, %r8 # imm = 0x3FB999999999999A
movq %rbx, %r9
callq 0x2c0c2
cmpl $0x0, (%rbx)
jne 0x33002
movq 0x48(%r14), %rdi
movl $0x1, %esi
movq 0x28(%rsp), %rcx
movq %rcx, %rdx
movq %r15, %r8
movq %rbx, %r9
callq 0x2c0c2
cmpl $0x0, (%rbx)
jne 0x33002
movq 0x48(%r14), %rdi
movl $0x45, %esi
movq 0x20(%rsp), %rdx
movq %rbx, %rcx
callq 0x2c19f
cmpl $0x0, (%rbx)
je 0x33011
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x48(%r14), %rdi
movq 0x8(%rsp), %rsi
movq %rbx, %rdx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2d017