#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_real(int /*<<< orphan*/, int);
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_real(0, 368);
  if (urem_i8(-1, 1) != 0)
    return fail_real(0, 370);
  if (srem_i8(1, -1) != 0)
    return fail_real(0, 372);
  if (srem_i16(-535, 7) != -3)
    return fail_real(0, 374);
  if (urem_i16(-535, 7) != 6)
    return fail_real(0, 376);
  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     1185 <test_rem+0x35>
xor    %edi,%edi
mov    $0x170,%esi
call   1050 <fail_real@plt>
mov    %eax,-0x4(%rbp)
jmp    123e <test_rem+0xee>
mov    $0xffffffff,%edi
mov    $0x1,%esi
call   1070 <urem_i8@plt>
cmp    $0x0,%rax
je     11b2 <test_rem+0x62>
xor    %edi,%edi
mov    $0x172,%esi
call   1050 <fail_real@plt>
mov    %eax,-0x4(%rbp)
jmp    123e <test_rem+0xee>
mov    $0x1,%edi
mov    $0xffffffff,%esi
call   1030 <srem_i8@plt>
cmp    $0x0,%rax
je     11df <test_rem+0x8f>
xor    %edi,%edi
mov    $0x174,%esi
call   1050 <fail_real@plt>
mov    %eax,-0x4(%rbp)
jmp    123e <test_rem+0xee>
mov    $0xfffffde9,%edi
mov    $0x7,%esi
call   1040 <srem_i16@plt>
cmp    $0xfffffffd,%eax
je     120b <test_rem+0xbb>
xor    %edi,%edi
mov    $0x176,%esi
call   1050 <fail_real@plt>
mov    %eax,-0x4(%rbp)
jmp    123e <test_rem+0xee>
mov    $0xfffffde9,%edi
mov    $0x7,%esi
call   1060 <urem_i16@plt>
cmp    $0x6,%eax
je     1237 <test_rem+0xe7>
xor    %edi,%edi
mov    $0x178,%esi
call   1050 <fail_real@plt>
mov    %eax,-0x4(%rbp)
jmp    123e <test_rem+0xee>
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>
mov    $0x170,%esi
test   %rax,%rax
jne    11d5 <test_rem+0x85>
mov    $0xffffffff,%edi
mov    $0x1,%esi
call   1070 <urem_i8@plt>
mov    $0x172,%esi
test   %rax,%rax
jne    11d5 <test_rem+0x85>
mov    $0x1,%edi
mov    $0xffffffff,%esi
call   1030 <srem_i8@plt>
mov    $0x174,%esi
test   %rax,%rax
jne    11d5 <test_rem+0x85>
mov    $0xfffffde9,%edi
mov    $0x7,%esi
call   1040 <srem_i16@plt>
mov    $0x176,%esi
cmp    $0xfffffffd,%eax
jne    11d5 <test_rem+0x85>
mov    $0xfffffde9,%edi
mov    $0x7,%esi
call   1060 <urem_i16@plt>
mov    $0x178,%esi
cmp    $0x6,%eax
jne    11d5 <test_rem+0x85>
mov    $0x400,%eax
pop    %rcx
ret
xor    %edi,%edi
pop    %rax
jmp    1050 <fail_real@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_real(i32 0, i32 368)
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_real(i32 0, i32 370)
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_real(i32 0, i32 372)
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_real(i32 0, i32 374)
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_real(i32 0, i32 376)
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 %18, label %15
15: ; preds = %12, %9, %6, %3, %0
%16 = phi i32 [ 368, %0 ], [ 370, %3 ], [ 372, %6 ], [ 374, %9 ], [ 376, %12 ]
%17 = tail call i32 @fail_real(i32 0, i32 %16)
br label %18
18: ; preds = %15, %12
%19 = phi i32 [ 1024, %12 ], [ %17, %15 ]
ret i32 %19
}