// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/int32_type.c
// Function: prv_div_mod_vars
static size_t prv_div_mod_vars(subtilis_parser_t *p, subtilis_ir_operand_t a,
			       subtilis_ir_operand_t b,
			       subtilis_op_instr_type_t type,
			       subtilis_error_t *err)
{
	subtilis_exp_t *e;
	subtilis_ir_arg_t *args;
	size_t res;
	size_t div_flag;
	size_t eflag_reg;
	size_t err_reg;
	subtilis_ir_operand_t div_mod;
	subtilis_ir_operand_t eflag_offset;
	subtilis_ir_operand_t err_offset;
	static const char idiv[] = "_idiv";
	char *name = NULL;

	if (p->backend.caps & SUBTILIS_BACKEND_HAVE_DIV) {
		res =
		    subtilis_ir_section_add_instr(p->current, type, a, b, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return 0;
		subtilis_exp_handle_errors(p, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return 0;
		return res;
	}

	name = malloc(sizeof(idiv));
	if (!name) {
		subtilis_error_set_oom(err);
		return 0;
	}
	strcpy(name, idiv);

	args = malloc(sizeof(*args) * 5);
	if (!args) {
		free(name);
		subtilis_error_set_oom(err);
		return 0;
	}

	div_mod.integer = type == SUBTILIS_OP_INSTR_DIV_I32 ? 0 : 1;
	div_flag = subtilis_ir_section_add_instr2(
	    p->current, SUBTILIS_OP_INSTR_MOVI_I32, div_mod, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return 0;

	eflag_offset.integer = p->eflag_offset;
	eflag_reg = subtilis_ir_section_add_instr2(
	    p->current, SUBTILIS_OP_INSTR_MOVI_I32, eflag_offset, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return 0;

	err_offset.integer = p->error_offset;
	err_reg = subtilis_ir_section_add_instr2(
	    p->current, SUBTILIS_OP_INSTR_MOVI_I32, err_offset, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return 0;

	args[0].type = SUBTILIS_IR_REG_TYPE_INTEGER;
	args[0].reg = a.reg;
	args[1].type = SUBTILIS_IR_REG_TYPE_INTEGER;
	args[1].reg = b.reg;
	args[2].type = SUBTILIS_IR_REG_TYPE_INTEGER;
	args[2].reg = div_flag;
	args[3].type = SUBTILIS_IR_REG_TYPE_INTEGER;
	args[3].reg = eflag_reg;
	args[4].type = SUBTILIS_IR_REG_TYPE_INTEGER;
	args[4].reg = err_reg;
	e = subtilis_exp_add_call(p, name, SUBTILIS_BUILTINS_IDIV, NULL, args,
				  &subtilis_type_integer, 5, true, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return 0;
	res = e->exp.ir_op.reg;
	subtilis_exp_delete(e);

	return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rdi, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
movq $0x0, -0x80(%rbp)
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x50edb
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movl -0x24(%rbp), %esi
movq -0x30(%rbp), %r8
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x38230
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x50eab
movq $0x0, -0x8(%rbp)
jmp 0x51113
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x36ce0
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x50ece
movq $0x0, -0x8(%rbp)
jmp 0x51113
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x51113
movl $0x6, %edi
callq 0x121b0
movq %rax, -0x80(%rbp)
cmpq $0x0, -0x80(%rbp)
jne 0x50f17
movq -0x30(%rbp), %rdi
movl $0x1, %esi
leaq 0x5b5a5(%rip), %rdx     # 0xac4a5
movl $0x1bb, %ecx            # imm = 0x1BB
callq 0x158e0
movq $0x0, -0x8(%rbp)
jmp 0x51113
movq -0x80(%rbp), %rdi
leaq 0x5b57a(%rip), %rsi     # 0xac49c
callq 0x12060
movl $0x78, %edi
callq 0x121b0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x50f6c
movq -0x80(%rbp), %rdi
callq 0x12290
movq -0x30(%rbp), %rdi
movl $0x1, %esi
leaq 0x5b550(%rip), %rdx     # 0xac4a5
movl $0x1c3, %ecx            # imm = 0x1C3
callq 0x158e0
movq $0x0, -0x8(%rbp)
jmp 0x51113
movl -0x24(%rbp), %edx
movl $0x1, %eax
xorl %ecx, %ecx
cmpl $0x6, %edx
cmovel %ecx, %eax
movl %eax, -0x68(%rbp)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %rcx
movq -0x68(%rbp), %rdx
movl $0x1b, %esi
callq 0x38490
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x50fb3
movq $0x0, -0x8(%rbp)
jmp 0x51113
movq -0x20(%rbp), %rax
movl 0xb0(%rax), %eax
movl %eax, -0x70(%rbp)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %rcx
movq -0x70(%rbp), %rdx
movl $0x1b, %esi
callq 0x38490
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x50ff4
movq $0x0, -0x8(%rbp)
jmp 0x51113
movq -0x20(%rbp), %rax
movl 0xb4(%rax), %eax
movl %eax, -0x78(%rbp)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %rcx
movq -0x78(%rbp), %rdx
movl $0x1b, %esi
callq 0x38490
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x51035
movq $0x0, -0x8(%rbp)
jmp 0x51113
movq -0x40(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x18(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x40(%rbp), %rax
movl $0x0, 0x30(%rax)
movq -0x50(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x40(%rbp), %rax
movl $0x0, 0x48(%rax)
movq -0x58(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x40(%rbp), %rax
movl $0x0, 0x60(%rax)
movq -0x60(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x20(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq -0x40(%rbp), %r8
movq -0x30(%rbp), %rax
xorl %edx, %edx
xorl %ecx, %ecx
leaq 0x5a80e(%rip), %r9      # 0xab8d0
movq $0x5, (%rsp)
movl $0x1, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x36f50
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x510f3
movq $0x0, -0x8(%rbp)
jmp 0x51113
movq -0x38(%rbp), %rax
movq 0x148(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rdi
callq 0x36ee0
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq