#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ branch_offset(int);
int /*<<< orphan*/ i_type_inst_free(int, int /*<<< orphan*/, int,
                                    int /*<<< orphan*/);
int /*<<< orphan*/ r_type_inst(int, int, int, int);
int /*<<< orphan*/ trap_inst();
void div_inst(int op, int rd, int rs, int rt, int const_divisor) {
  if (rd != 0 && !const_divisor) {
    i_type_inst_free(301, 0, rt, branch_offset(2));
    trap_inst();
  }
  if (op == 382 || op == 587)
    r_type_inst(382, 0, rs, rt);
  else
    r_type_inst(384, 0, rs, rt);
  if (rd != 0) {
    if (op == 382 || op == 384)
      r_type_inst(427, rd, 0, 0);
    else
      r_type_inst(426, rd, 0, 0);
  }
}


x86 assembly (clang, -O0):
<div_inst>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1194 <div_inst+0x54>
cmpl   $0x0,-0x14(%rbp)
jne    1194 <div_inst+0x54>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x2,%edi
call   1030 <branch_offset@plt>
mov    -0x18(%rbp),%edx
mov    %eax,%ecx
mov    $0x12d,%edi
xor    %esi,%esi
call   1060 <i_type_inst_free@plt>
mov    $0x0,%al
call   1050 <trap_inst@plt>
cmpl   $0x17e,-0x4(%rbp)
je     11ae <div_inst+0x6e>
cmpl   $0x24b,-0x4(%rbp)
jne    11c5 <div_inst+0x85>
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    $0x17e,%edi
xor    %esi,%esi
call   1040 <r_type_inst@plt>
jmp    11d7 <div_inst+0x97>
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    $0x180,%edi
xor    %esi,%esi
call   1040 <r_type_inst@plt>
cmpl   $0x0,-0x8(%rbp)
je     1227 <div_inst+0xe7>
cmpl   $0x17e,-0x4(%rbp)
je     11fb <div_inst+0xbb>
cmpl   $0x180,-0x4(%rbp)
jne    1211 <div_inst+0xd1>
mov    -0x8(%rbp),%esi
mov    $0x1ab,%edi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1040 <r_type_inst@plt>
jmp    1222 <div_inst+0xe2>
mov    -0x8(%rbp),%esi
mov    $0x1aa,%edi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1040 <r_type_inst@plt>
jmp    1227 <div_inst+0xe7>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<div_inst>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%ebx
mov    %edi,%ebp
test   %esi,%esi
je     117c <div_inst+0x3c>
test   %r8d,%r8d
jne    117c <div_inst+0x3c>
mov    $0x2,%edi
call   1030 <branch_offset@plt>
mov    $0x12d,%edi
xor    %esi,%esi
mov    %r14d,%edx
mov    %eax,%ecx
call   1060 <i_type_inst_free@plt>
xor    %eax,%eax
call   1050 <trap_inst@plt>
xor    %eax,%eax
cmp    $0x17e,%ebp
setne  %al
cmp    $0x24b,%ebp
lea    0x17e(%rax,%rax,1),%eax
mov    $0x17e,%edi
cmovne %eax,%edi
xor    %esi,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
call   1040 <r_type_inst@plt>
test   %ebx,%ebx
je     11da <div_inst+0x9a>
add    $0xfffffe82,%ebp
xor    %edi,%edi
test   $0xfffffffd,%ebp
sete   %dil
or     $0x1aa,%edi
mov    %ebx,%esi
xor    %edx,%edx
xor    %ecx,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <r_type_inst@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @div_inst(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i32, i32* %7
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %5
%14 = load i32, i32* %10
%15 = icmp ne i32 %14, 0
br i1 %15, label %21, label %16
16: ; preds = %13
%17 = load i32, i32* %9
%18 = call i32 @branch_offset(i32 2)
%19 = call i32 @i_type_inst_free(i32 301, i32 0, i32 %17, i32 %18)
%20 = call i32 (...) @trap_inst()
br label %21
21: ; preds = %16, %13, %5
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, 382
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = load i32, i32* %6
%26 = icmp eq i32 %25, 587
br i1 %26, label %27, label %31
27: ; preds = %24, %21
%28 = load i32, i32* %8
%29 = load i32, i32* %9
%30 = call i32 @r_type_inst(i32 382, i32 0, i32 %28, i32 %29)
br label %35
31: ; preds = %24
%32 = load i32, i32* %8
%33 = load i32, i32* %9
%34 = call i32 @r_type_inst(i32 384, i32 0, i32 %32, i32 %33)
br label %35
35: ; preds = %31, %27
%36 = load i32, i32* %7
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %51
38: ; preds = %35
%39 = load i32, i32* %6
%40 = icmp eq i32 %39, 382
br i1 %40, label %44, label %41
41: ; preds = %38
%42 = load i32, i32* %6
%43 = icmp eq i32 %42, 384
br i1 %43, label %44, label %47
44: ; preds = %41, %38
%45 = load i32, i32* %7
%46 = call i32 @r_type_inst(i32 427, i32 %45, i32 0, i32 0)
br label %50
47: ; preds = %41
%48 = load i32, i32* %7
%49 = call i32 @r_type_inst(i32 426, i32 %48, i32 0, i32 0)
br label %50
50: ; preds = %47, %44
br label %51
51: ; preds = %50, %35
ret void
}

LLVM IR (-O2):
define void @div_inst(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp eq i32 %1, 0
%7 = icmp ne i32 %4, 0
%8 = or i1 %6, %7
br i1 %8, label %13, label %9
9: ; preds = %5
%10 = tail call i32 @branch_offset(i32 2)
%11 = tail call i32 @i_type_inst_free(i32 301, i32 0, i32 %3, i32 %10)
%12 = tail call i32 (...) @trap_inst()
br label %13
13: ; preds = %9, %5
%14 = icmp eq i32 %0, 587
%15 = icmp eq i32 %0, 382
%16 = or i1 %14, %15
%17 = select i1 %16, i32 382, i32 384
%18 = tail call i32 @r_type_inst(i32 %17, i32 0, i32 %2, i32 %3)
br i1 %6, label %25, label %19
19: ; preds = %13
%20 = icmp eq i32 %0, 384
%21 = icmp eq i32 %0, 382
%22 = or i1 %20, %21
%23 = select i1 %22, i32 427, i32 426
%24 = tail call i32 @r_type_inst(i32 %23, i32 %1, i32 0, i32 0)
br label %25
25: ; preds = %19, %13
ret void
}