#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 */
typedef int uint8_t;
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
int getR1(int /*<<< orphan*/);
int getR2(int /*<<< orphan*/);
int getR3(int /*<<< orphan*/);
int /*<<< orphan*/ printSegmentationFaultMessage();
int checkRtypeInstructionIsValid(uint32_t ins) {
  uint8_t r1 = getR1(ins);
  uint8_t r2 = getR2(ins);
  uint8_t r3 = getR3(ins);
  if (r1 < 0 || r2 < 0 || r3 < 0 || r1 >= 32 || r2 >= 32 || r3 >= 32) {
    printSegmentationFaultMessage();
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<checkRtypeInstructionIsValid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <getR1@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <getR2@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <getR3@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     11a8 <checkRtypeInstructionIsValid+0x68>
cmpl   $0x0,-0x10(%rbp)
jl     11a8 <checkRtypeInstructionIsValid+0x68>
cmpl   $0x0,-0x14(%rbp)
jl     11a8 <checkRtypeInstructionIsValid+0x68>
cmpl   $0x20,-0xc(%rbp)
jge    11a8 <checkRtypeInstructionIsValid+0x68>
cmpl   $0x20,-0x10(%rbp)
jge    11a8 <checkRtypeInstructionIsValid+0x68>
cmpl   $0x20,-0x14(%rbp)
jl     11bb <checkRtypeInstructionIsValid+0x7b>
mov    $0x0,%al
call   1060 <printSegmentationFaultMessage@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c2 <checkRtypeInstructionIsValid+0x82>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkRtypeInstructionIsValid>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
call   1040 <getR1@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1030 <getR2@plt>
mov    %eax,%r14d
mov    %ebp,%edi
call   1050 <getR3@plt>
test   %ebx,%ebx
js     1180 <checkRtypeInstructionIsValid+0x40>
test   %r14d,%r14d
js     1180 <checkRtypeInstructionIsValid+0x40>
test   %eax,%eax
js     1180 <checkRtypeInstructionIsValid+0x40>
cmp    $0x1f,%ebx
jg     1180 <checkRtypeInstructionIsValid+0x40>
cmp    $0x1f,%r14d
jg     1180 <checkRtypeInstructionIsValid+0x40>
mov    $0x1,%ebx
cmp    $0x20,%eax
jl     1189 <checkRtypeInstructionIsValid+0x49>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <printSegmentationFaultMessage@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @checkRtypeInstructionIsValid(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
%7 = load i32, i32* %3
%8 = call i32 @getR1(i32 %7)
store i32 %8, i32* %4
%9 = load i32, i32* %3
%10 = call i32 @getR2(i32 %9)
store i32 %10, i32* %5
%11 = load i32, i32* %3
%12 = call i32 @getR3(i32 %11)
store i32 %12, i32* %6
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 0
br i1 %14, label %30, label %15
15: ; preds = %1
%16 = load i32, i32* %5
%17 = icmp slt i32 %16, 0
br i1 %17, label %30, label %18
18: ; preds = %15
%19 = load i32, i32* %6
%20 = icmp slt i32 %19, 0
br i1 %20, label %30, label %21
21: ; preds = %18
%22 = load i32, i32* %4
%23 = icmp sge i32 %22, 32
br i1 %23, label %30, label %24
24: ; preds = %21
%25 = load i32, i32* %5
%26 = icmp sge i32 %25, 32
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = load i32, i32* %6
%29 = icmp sge i32 %28, 32
br i1 %29, label %30, label %32
30: ; preds = %27, %24, %21, %18, %15, %1
%31 = call i32 (...) @printSegmentationFaultMessage()
store i32 0, i32* %2
br label %33
32: ; preds = %27
store i32 1, i32* %2
br label %33
33: ; preds = %32, %30
%34 = load i32, i32* %2
ret i32 %34
}

LLVM IR (-O2):
define i32 @checkRtypeInstructionIsValid(i32 %0) {
%2 = tail call i32 @getR1(i32 %0)
%3 = tail call i32 @getR2(i32 %0)
%4 = tail call i32 @getR3(i32 %0)
%5 = icmp slt i32 %2, 0
%6 = icmp slt i32 %3, 0
%7 = select i1 %5, i1 true, i1 %6
%8 = icmp slt i32 %4, 0
%9 = select i1 %7, i1 true, i1 %8
%10 = icmp sgt i32 %2, 31
%11 = select i1 %9, i1 true, i1 %10
%12 = icmp sgt i32 %3, 31
%13 = select i1 %11, i1 true, i1 %12
%14 = icmp sgt i32 %4, 31
%15 = select i1 %13, i1 true, i1 %14
br i1 %15, label %16, label %18
16: ; preds = %1
%17 = tail call i32 (...) @printSegmentationFaultMessage()
br label %18
18: ; preds = %1, %16
%19 = phi i32 [ 0, %16 ], [ 1, %1 ]
ret i32 %19
}