#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 fail(int /*<<< orphan*/);
int srem_i16(int, int);
scalar_t__ srem_i8(int, int);
int urem_i16(int, int);
scalar_t__ urem_i8(int, int);
int test_rem(void) {
  if (srem_i8(-1, 1) != 0)
    return fail(0);
  if (urem_i8(-1, 1) != 0)
    return fail(0);
  if (srem_i8(1, -1) != 0)
    return fail(0);
  if (srem_i16(-535, 7) != -3)
    return fail(0);
  if (urem_i16(-535, 7) != 6)
    return fail(0);
  return 0x400;
}


x86 assembly (clang, -O0):
<test_rem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xffffffff,%edi
mov    $0x1,%esi
call   1030 <srem_i8@plt>
cmp    $0x0,%rax
je     1180 <test_rem+0x30>
xor    %edi,%edi
call   1050 <fail@plt>
mov    %eax,-0x4(%rbp)
jmp    1225 <test_rem+0xd5>
mov    $0xffffffff,%edi
mov    $0x1,%esi
call   1070 <urem_i8@plt>
cmp    $0x0,%rax
je     11a8 <test_rem+0x58>
xor    %edi,%edi
call   1050 <fail@plt>
mov    %eax,-0x4(%rbp)
jmp    1225 <test_rem+0xd5>
mov    $0x1,%edi
mov    $0xffffffff,%esi
call   1030 <srem_i8@plt>
cmp    $0x0,%rax
je     11d0 <test_rem+0x80>
xor    %edi,%edi
call   1050 <fail@plt>
mov    %eax,-0x4(%rbp)
jmp    1225 <test_rem+0xd5>
mov    $0xfffffde9,%edi
mov    $0x7,%esi
call   1040 <srem_i16@plt>
cmp    $0xfffffffd,%eax
je     11f7 <test_rem+0xa7>
xor    %edi,%edi
call   1050 <fail@plt>
mov    %eax,-0x4(%rbp)
jmp    1225 <test_rem+0xd5>
mov    $0xfffffde9,%edi
mov    $0x7,%esi
call   1060 <urem_i16@plt>
cmp    $0x6,%eax
je     121e <test_rem+0xce>
xor    %edi,%edi
call   1050 <fail@plt>
mov    %eax,-0x4(%rbp)
jmp    1225 <test_rem+0xd5>
movl   $0x400,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_rem>:
push   %rax
mov    $0xffffffff,%edi
mov    $0x1,%esi
call   1030 <srem_i8@plt>
test   %rax,%rax
jne    11bc <test_rem+0x6c>
mov    $0xffffffff,%edi
mov    $0x1,%esi
call   1070 <urem_i8@plt>
test   %rax,%rax
jne    11bc <test_rem+0x6c>
mov    $0x1,%edi
mov    $0xffffffff,%esi
call   1030 <srem_i8@plt>
test   %rax,%rax
jne    11bc <test_rem+0x6c>
mov    $0xfffffde9,%edi
mov    $0x7,%esi
call   1040 <srem_i16@plt>
cmp    $0xfffffffd,%eax
jne    11bc <test_rem+0x6c>
mov    $0xfffffde9,%edi
mov    $0x7,%esi
call   1060 <urem_i16@plt>
cmp    $0x6,%eax
jne    11bc <test_rem+0x6c>
mov    $0x400,%eax
pop    %rcx
ret
xor    %edi,%edi
pop    %rax
jmp    1050 <fail@plt>

LLVM IR (-O0):
define i32 @test_rem() {
%1 = alloca i32
%2 = call i64 @srem_i8(i32 -1, i32 1)
%3 = icmp ne i64 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = call i32 @fail(i32 0)
store i32 %5, i32* %1
br label %27
6: ; preds = %0
%7 = call i64 @urem_i8(i32 -1, i32 1)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = call i32 @fail(i32 0)
store i32 %10, i32* %1
br label %27
11: ; preds = %6
%12 = call i64 @srem_i8(i32 1, i32 -1)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @fail(i32 0)
store i32 %15, i32* %1
br label %27
16: ; preds = %11
%17 = call i32 @srem_i16(i32 -535, i32 7)
%18 = icmp ne i32 %17, -3
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 @fail(i32 0)
store i32 %20, i32* %1
br label %27
21: ; preds = %16
%22 = call i32 @urem_i16(i32 -535, i32 7)
%23 = icmp ne i32 %22, 6
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @fail(i32 0)
store i32 %25, i32* %1
br label %27
26: ; preds = %21
store i32 1024, i32* %1
br label %27
27: ; preds = %26, %24, %19, %14, %9, %4
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
define i32 @test_rem() {
%1 = tail call i64 @srem_i8(i32 -1, i32 1)
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %15
3: ; preds = %0
%4 = tail call i64 @urem_i8(i32 -1, i32 1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %3
%7 = tail call i64 @srem_i8(i32 1, i32 -1)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %6
%10 = tail call i32 @srem_i16(i32 -535, i32 7)
%11 = icmp eq i32 %10, -3
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = tail call i32 @urem_i16(i32 -535, i32 7)
%14 = icmp eq i32 %13, 6
br i1 %14, label %17, label %15
15: ; preds = %12, %9, %6, %3, %0
%16 = tail call i32 @fail(i32 0)
br label %17
17: ; preds = %15, %12
%18 = phi i32 [ 1024, %12 ], [ %16, %15 ]
ret i32 %18
}