#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*/ emit_andimm(int, int, int);
int /*<<< orphan*/ emit_orrmi_imm(int, int, int);
int /*<<< orphan*/ emit_orrne_imm(int, int, int);
int /*<<< orphan*/ emit_teq(int, int);
int /*<<< orphan*/ emit_testimm(int, int);
void emit_div0s(int s1, int s2, int sr, int temp) {
  emit_andimm(sr, 0xfe, sr);
  emit_testimm(s2, 0x80000000);
  emit_orrne_imm(sr, 0x100, sr);
  emit_testimm(s1, 0x80000000);
  emit_orrne_imm(sr, 0x200, sr);
  emit_teq(s1, s2);
  emit_orrmi_imm(sr, 1, sr);
}


x86 assembly (clang, -O0):
<emit_div0s>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%edx
mov    $0xfe,%esi
call   1070 <emit_andimm@plt>
mov    -0x8(%rbp),%edi
mov    $0x80000000,%esi
call   1040 <emit_testimm@plt>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%edx
mov    $0x100,%esi
call   1030 <emit_orrne_imm@plt>
mov    -0x4(%rbp),%edi
mov    $0x80000000,%esi
call   1040 <emit_testimm@plt>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%edx
mov    $0x200,%esi
call   1030 <emit_orrne_imm@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <emit_teq@plt>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%edx
mov    $0x1,%esi
call   1060 <emit_orrmi_imm@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emit_div0s>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%ebp
mov    %edx,%edi
mov    $0xfe,%esi
call   1070 <emit_andimm@plt>
mov    %r14d,%edi
mov    $0x80000000,%esi
call   1040 <emit_testimm@plt>
mov    %ebx,%edi
mov    $0x100,%esi
mov    %ebx,%edx
call   1030 <emit_orrne_imm@plt>
mov    %ebp,%edi
mov    $0x80000000,%esi
call   1040 <emit_testimm@plt>
mov    %ebx,%edi
mov    $0x200,%esi
mov    %ebx,%edx
call   1030 <emit_orrne_imm@plt>
mov    %ebp,%edi
mov    %r14d,%esi
call   1050 <emit_teq@plt>
mov    %ebx,%edi
mov    $0x1,%esi
mov    %ebx,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <emit_orrmi_imm@plt>

LLVM IR (-O0):
define void @emit_div0s(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %7
%10 = load i32, i32* %7
%11 = call i32 @emit_andimm(i32 %9, i32 254, i32 %10)
%12 = load i32, i32* %6
%13 = call i32 @emit_testimm(i32 %12, i32 -2147483648)
%14 = load i32, i32* %7
%15 = load i32, i32* %7
%16 = call i32 @emit_orrne_imm(i32 %14, i32 256, i32 %15)
%17 = load i32, i32* %5
%18 = call i32 @emit_testimm(i32 %17, i32 -2147483648)
%19 = load i32, i32* %7
%20 = load i32, i32* %7
%21 = call i32 @emit_orrne_imm(i32 %19, i32 512, i32 %20)
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = call i32 @emit_teq(i32 %22, i32 %23)
%25 = load i32, i32* %7
%26 = load i32, i32* %7
%27 = call i32 @emit_orrmi_imm(i32 %25, i32 1, i32 %26)
ret void
}

LLVM IR (-O2):
define void @emit_div0s(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @emit_andimm(i32 %2, i32 254, i32 %2)
%6 = tail call i32 @emit_testimm(i32 %1, i32 -2147483648)
%7 = tail call i32 @emit_orrne_imm(i32 %2, i32 256, i32 %2)
%8 = tail call i32 @emit_testimm(i32 %0, i32 -2147483648)
%9 = tail call i32 @emit_orrne_imm(i32 %2, i32 512, i32 %2)
%10 = tail call i32 @emit_teq(i32 %0, i32 %1)
%11 = tail call i32 @emit_orrmi_imm(i32 %2, i32 1, i32 %2)
ret void
}