#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
__attribute__((visibility("hidden"))) void boundscheck(int jpk, int n2, int ipk,
                                                       int n1) {
  if ((jpk < 0) || jpk >= n2) {
    printf("Bounds check error, jpk, n2\n");
    exit(0);
  }
  if ((ipk < 0) || ipk >= n1) {
    printf("Bounds check error, jpk, n1\n");
    exit(0);
  }
}


x86 assembly (clang, -O0):
<boundscheck>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     114a <boundscheck+0x2a>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     115d <boundscheck+0x3d>
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <exit@plt>
cmpl   $0x0,-0xc(%rbp)
jl     1173 <boundscheck+0x53>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     1186 <boundscheck+0x66>
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<boundscheck>:
push   %rax
test   %edi,%edi
js     1133 <boundscheck+0x13>
cmp    %esi,%edi
jge    1133 <boundscheck+0x13>
test   %edx,%edx
js     113c <boundscheck+0x1c>
cmp    %ecx,%edx
jge    113c <boundscheck+0x1c>
pop    %rax
ret
lea    0xee2(%rip),%rdi
jmp    1143 <boundscheck+0x23>
lea    0xebd(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"Bounds check error, jpk, n2\0A\00"
@.str.1 = [29 x i8] c"Bounds check error, jpk, n1\0A\00"
define hidden void @boundscheck(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* %5
%10 = icmp slt i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %4
%12 = load i32, i32* %5
%13 = load i32, i32* %6
%14 = icmp sge i32 %12, %13
br i1 %14, label %15, label %18
15: ; preds = %11, %4
%16 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %11
%19 = load i32, i32* %7
%20 = icmp slt i32 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %18
%22 = load i32, i32* %7
%23 = load i32, i32* %8
%24 = icmp sge i32 %22, %23
br i1 %24, label %25, label %28
25: ; preds = %21, %18
%26 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 @exit(i32 0)
unreachable
28: ; preds = %21
ret void
}

LLVM IR (-O2):
@str = [28 x i8] c"Bounds check error, jpk, n1\00"
@str.2 = [28 x i8] c"Bounds check error, jpk, n2\00"
define hidden void @boundscheck(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %0, -1
%6 = icmp slt i32 %0, %1
%7 = and i1 %5, %6
br i1 %7, label %11, label %8
8: ; preds = %4
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.2, i64 0, i64 0))
%10 = tail call i32 @exit(i32 0)
unreachable
11: ; preds = %4
%12 = icmp sgt i32 %2, -1
%13 = icmp slt i32 %2, %3
%14 = and i1 %12, %13
br i1 %14, label %18, label %15
15: ; preds = %11
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%17 = tail call i32 @exit(i32 0)
unreachable
18: ; preds = %11
ret void
}