// File: /workspace/github_c_makefile_star2_O1/markdryan[P]subtilis/frontend/int32_type.c
// Function: prv_div
static subtilis_exp_t *prv_div(subtilis_parser_t *p, subtilis_exp_t *a1,
			       subtilis_exp_t *a2, subtilis_error_t *err)
{
	switch (a2->type.type) {
	case SUBTILIS_TYPE_CONST_INTEGER:
		if (a2->exp.ir_op.integer == 0) {
			subtilis_error_set_divide_by_zero(
			    err, p->l->stream->name, p->l->line);
			break;
		}
		a1->exp.ir_op.reg =
		    prv_div_by_constant(p, a1->exp.ir_op, a2->exp.ir_op, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;
		break;
	case SUBTILIS_TYPE_BYTE:
		a2 = subtilis_type_if_to_int(p, a2, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;
	case SUBTILIS_TYPE_INTEGER:
		a1->exp.ir_op.reg =
		    prv_div_mod_vars(p, a1->exp.ir_op, a2->exp.ir_op,
				     SUBTILIS_OP_INSTR_DIV_I32, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;
		break;
	default:
		subtilis_error_set_assertion_failed(err);
		goto on_error;
	}

	subtilis_exp_delete(a2);
	return a1;

on_error:

	subtilis_exp_delete(a1);
	subtilis_exp_delete(a2);
	return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r12
movl (%rdx), %eax
cmpl $0x6, %eax
je 0x3ae35
cmpl $0x5, %eax
je 0x3ae50
cmpl $0x1, %eax
jne 0x3ae7a
cmpl $0x0, 0x148(%r14)
je 0x3ae98
movq 0x148(%r14), %r8
testl %r8d, %r8d
je 0x3aec2
movl %r8d, %eax
negl %eax
cmovsl %r8d, %eax
movq 0x148(%rbx), %rdx
movl %eax, %edi
shrl %edi
xorl %r13d, %r13d
movl $0x1, %esi
movl %r13d, %ecx
shll %cl, %esi
incq %r13
cmpl %esi, %edi
jae 0x3adbb
cmpl %esi, %eax
jne 0x3aee9
movq %r8, 0x10(%rsp)
movq 0x48(%r12), %rdi
movl $0x1f, %ecx
movl $0x50, %esi
movq %rdx, 0x8(%rsp)
movq %r15, %r8
callq 0x2c00f
cmpl $0x0, (%r15)
jne 0x3ae22
movl $0x21, %ecx
subl %r13d, %ecx
movq 0x48(%r12), %rdi
movl $0x4e, %esi
movq %rax, %rdx
movq %r15, %r8
callq 0x2c00f
cmpl $0x0, (%r15)
je 0x3af81
xorl %ebp, %ebp
xorl %eax, %eax
movq 0x10(%rsp), %r8
movq 0x8(%rsp), %rdx
jmp 0x3aeed
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x3691f
movq %rax, %r14
cmpl $0x0, (%r15)
jne 0x3af5d
movq 0x148(%rbx), %rsi
movq 0x148(%r14), %rdx
movq %r12, %rdi
movl $0x6, %ecx
movq %r15, %r8
callq 0x3b97d
movq %rax, 0x148(%rbx)
jmp 0x3af57
leaq 0x3a63e(%rip), %rdx     # 0x754bf
movq %r15, %rdi
movl $0xf, %esi
movl $0x690, %ecx            # imm = 0x690
callq 0x145f4
jmp 0x3af5d
movq (%r12), %rax
movq 0x30(%rax), %rdx
movl 0x38(%rax), %ecx
leaq 0x3a615(%rip), %r8      # 0x754bf
movq %r15, %rdi
movl $0x1a, %esi
movl $0x67c, %r9d            # imm = 0x67C
callq 0x14618
jmp 0x3af67
movq (%r12), %rax
movq 0x30(%rax), %rdx
movl 0x38(%rax), %ecx
leaq 0x3a5eb(%rip), %r8      # 0x754bf
movq %r15, %rdi
movl $0x1a, %esi
movl $0x65d, %r9d            # imm = 0x65D
callq 0x14618
jmp 0x3af21
xorl %ebp, %ebp
xorl %eax, %eax
cmpl $0x0, (%r15)
setne %cl
orb %al, %cl
testb $0x1, %cl
jne 0x3af50
testb $0x1, 0x8(%r12)
movq 0x48(%r12), %rdi
jne 0x3af25
movq %rdx, %r13
movl $0x1b, %esi
movq %r8, %rdx
movq %r15, %rcx
callq 0x2c189
cmpl $0x0, (%r15)
je 0x3af37
xorl %ebp, %ebp
jmp 0x3af50
movl $0xf, %esi
movq %r8, %rcx
movq %r15, %r8
callq 0x2c00f
jmp 0x3af4d
movq %r12, %rdi
movq %r13, %rsi
movq %rax, %rdx
movl $0x6, %ecx
movq %r15, %r8
callq 0x3b97d
movq %rax, %rbp
movq %rbp, 0x148(%rbx)
cmpl $0x0, (%r15)
je 0x3af67
movq %rbx, %rdi
callq 0x2b4c3
xorl %ebx, %ebx
movq %r14, %rdi
callq 0x2b4c3
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x48(%r12), %rdi
xorl %ebp, %ebp
xorl %esi, %esi
movq 0x8(%rsp), %rdx
movq %rax, %rcx
movq %r15, %r8
callq 0x2c00f
cmpl $0x0, (%r15)
jne 0x3ae24
movq 0x48(%r12), %rdi
decq %r13
movl $0x50, %esi
movq %rax, %rdx
movq %r13, %rcx
movq %r15, %r8
callq 0x2c00f
cmpl $0x0, (%r15)
jne 0x3ae22
movq %rax, %rbp
movb $0x1, %al
movq 0x10(%rsp), %r8
testl %r8d, %r8d
movq 0x8(%rsp), %rdx
jns 0x3aeed
movq 0x48(%r12), %rdi
xorl %r13d, %r13d
movl $0x21, %esi
movq %rbp, %rdx
xorl %ecx, %ecx
movq %r15, %r8
callq 0x2c00f
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %r8
cmpl $0x0, (%r15)
movq %rax, %rbp
sete %al
cmovneq %r13, %rbp
jmp 0x3aeed