// File: /workspace/github_c_makefile_star2_O2/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 0x38c59
cmpl $0x5, %eax
je 0x38c74
cmpl $0x1, %eax
jne 0x38c99
cmpl $0x0, 0x148(%r14)
je 0x38cb2
movq 0x148(%r14), %rcx
testl %ecx, %ecx
je 0x38cd7
movq 0x148(%rbx), %rdx
movl %ecx, %eax
negl %eax
movq %rcx, 0x8(%rsp)
cmovsl %ecx, %eax
movl %eax, %r8d
shrl %r8d
xorl %ebp, %ebp
pushq $0x1
popq %rsi
movl %esi, %edi
movl %ebp, %ecx
shll %cl, %edi
incq %rbp
cmpl %edi, %r8d
jae 0x38b77
cmpl %edi, %eax
jne 0x38d2e
movq 0x48(%r12), %rdi
pushq $0x50
popq %rsi
pushq $0x1f
popq %rcx
movq %rdx, %r13
movq %r15, %r8
callq 0x2a819
cmpl $0x0, (%r15)
jne 0x38cfa
movq %r13, 0x10(%rsp)
pushq $0x21
popq %rcx
subl %ebp, %ecx
movq 0x48(%r12), %rdi
pushq $0x4e
popq %rsi
movq %rax, %rdx
movq %r15, %r8
callq 0x2a819
cmpl $0x0, (%r15)
jne 0x38cfa
movq 0x48(%r12), %rdi
xorl %r13d, %r13d
xorl %esi, %esi
movq 0x10(%rsp), %rdx
movq %rax, %rcx
movq %r15, %r8
callq 0x2a819
cmpl $0x0, (%r15)
jne 0x38cfd
movq 0x48(%r12), %rdi
decq %rbp
pushq $0x50
popq %rsi
movq %rax, %rdx
movq %rbp, %rcx
movq %r15, %r8
callq 0x2a819
cmpl $0x0, (%r15)
jne 0x38cfa
movq %rax, %r13
cmpl $0x0, 0x8(%rsp)
jns 0x38cfd
movq 0x48(%r12), %rdi
xorl %ebp, %ebp
pushq $0x21
popq %rsi
movq %r13, %rdx
xorl %ecx, %ecx
movq %r15, %r8
callq 0x2a819
movq %rax, %r13
movl (%r15), %eax
testl %eax, %eax
sete %cl
cmovneq %rbp, %r13
movq 0x10(%rsp), %rdx
jmp 0x38d36
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x347d5
movq %rax, %r14
cmpl $0x0, (%r15)
jne 0x38d0a
movq 0x148(%rbx), %rsi
movq 0x148(%r14), %rdx
pushq $0x6
popq %rcx
movq %r12, %rdi
movq %r15, %r8
callq 0x39670
movq %rax, 0x148(%rbx)
jmp 0x38d04
leaq 0x367ef(%rip), %rdx     # 0x6f48f
pushq $0xf
popq %rsi
movq %r15, %rdi
movl $0x690, %ecx            # imm = 0x690
callq 0x1429e
jmp 0x38d0a
movq (%r12), %rax
movq 0x30(%rax), %rdx
movl 0x38(%rax), %ecx
leaq 0x367cb(%rip), %r8      # 0x6f48f
pushq $0x1a
popq %rsi
movq %r15, %rdi
movl $0x67c, %r9d            # imm = 0x67C
callq 0x142c0
jmp 0x38d14
movq (%r12), %rax
movq 0x30(%rax), %rdx
movl 0x38(%rax), %ecx
leaq 0x367a6(%rip), %r8      # 0x6f48f
pushq $0x1a
popq %rsi
movq %r15, %rdi
movl $0x65d, %r9d            # imm = 0x65D
callq 0x142c0
xorl %r13d, %r13d
movq %r13, 0x148(%rbx)
cmpl $0x0, (%r15)
je 0x38d14
movq %rbx, %rdi
callq 0x29d88
xorl %ebx, %ebx
movq %r14, %rdi
callq 0x29d88
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl (%r15), %eax
xorl %r13d, %r13d
xorl %ecx, %ecx
testl %eax, %eax
setne %al
orb %cl, %al
testb $0x1, %al
jne 0x38cfd
testb $0x1, 0x8(%r12)
movq 0x48(%r12), %rdi
jne 0x38d7d
movq %rdx, %r13
pushq $0x1b
popq %rsi
movq 0x8(%rsp), %rdx
movq %r15, %rcx
callq 0x2a981
cmpl $0x0, (%r15)
jne 0x38cfa
pushq $0x6
popq %rcx
movq %r12, %rdi
movq %r13, %rsi
movq %rax, %rdx
movq %r15, %r8
callq 0x39670
jmp 0x38d8d
pushq $0xf
popq %rsi
movq 0x8(%rsp), %rcx
movq %r15, %r8
callq 0x2a819
movq %rax, %r13
jmp 0x38cfd