#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 /*<<< orphan*/ printSegmentationFaultMessage();
int checkItypeInstructionIsValid(uint32_t ins) {
  uint8_t r1 = getR1(ins);
  uint8_t r2 = getR2(ins);
  if (r1 < 0 || r2 < 0 || r1 >= 32 || r2 >= 32) {
    printSegmentationFaultMessage();
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<checkItypeInstructionIsValid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%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)
cmpl   $0x0,-0xc(%rbp)
jl     1179 <checkItypeInstructionIsValid+0x49>
cmpl   $0x0,-0x10(%rbp)
jl     1179 <checkItypeInstructionIsValid+0x49>
cmpl   $0x20,-0xc(%rbp)
jge    1179 <checkItypeInstructionIsValid+0x49>
cmpl   $0x20,-0x10(%rbp)
jl     118c <checkItypeInstructionIsValid+0x5c>
mov    $0x0,%al
call   1050 <printSegmentationFaultMessage@plt>
movl   $0x0,-0x4(%rbp)
jmp    1193 <checkItypeInstructionIsValid+0x63>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkItypeInstructionIsValid>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
call   1040 <getR1@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1030 <getR2@plt>
cmp    $0x1f,%ebx
jg     115a <checkItypeInstructionIsValid+0x2a>
test   %ebx,%ebx
js     115a <checkItypeInstructionIsValid+0x2a>
test   %eax,%eax
js     115a <checkItypeInstructionIsValid+0x2a>
mov    $0x1,%ebx
cmp    $0x20,%eax
jl     1163 <checkItypeInstructionIsValid+0x33>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printSegmentationFaultMessage@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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