#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);
int /*<<< orphan*/ printf(char *, char const *, int, int, char const *);
void check_range(const char *name, int value, int low, int high,
                 const char *location) {
  if (value >= low && value < high)
    return;
  printf("Error: %s out of range (%i, must be below %i) %s\n", name, value,
         high, location ? location : "");
  exit(-1);
}


x86 assembly (clang, -O0):
<check_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     1157 <check_range+0x37>
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1157 <check_range+0x37>
add    $0x40,%rsp
pop    %rbp
ret
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1183 <check_range+0x63>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1193 <check_range+0x73>
lea    0xea7(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    1193 <check_range+0x73>
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%edx
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%r8
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<check_range>:
mov    %esi,%eax
mov    %rdi,%rsi
cmp    %edx,%eax
jl     112e <check_range+0xe>
cmp    %ecx,%eax
jge    112e <check_range+0xe>
ret
push   %rax
test   %r8,%r8
lea    0xef8(%rip),%r9
cmovne %r8,%r9
lea    0xebc(%rip),%rdi
mov    %eax,%edx
mov    %r9,%r8
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [50 x i8] c"Error: %s out of range (%i, must be below %i) %s\0A\00"
@.str.1 = [1 x i8] zeroinitializer
define void @check_range(i8* %0, i32 %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%11 = load i32, i32* %7
%12 = load i32, i32* %8
%13 = icmp sge i32 %11, %12
br i1 %13, label %14, label %19
14: ; preds = %5
%15 = load i32, i32* %7
%16 = load i32, i32* %9
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %14
ret void
19: ; preds = %14, %5
%20 = load i8*, i8** %6
%21 = load i32, i32* %7
%22 = load i32, i32* %9
%23 = load i8*, i8** %10
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = load i8*, i8** %10
br label %28
27: ; preds = %19
br label %28
28: ; preds = %27, %25
%29 = phi i8* [ %26, %25 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %27 ]
%30 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %20, i32 %21, i32 %22, i8* %29)
%31 = call i32 @exit(i32 -1)
unreachable
}

LLVM IR (-O2):
@.str = [50 x i8] c"Error: %s out of range (%i, must be below %i) %s\0A\00"
@.str.1 = [1 x i8] zeroinitializer
define void @check_range(i8* %0, i32 %1, i32 %2, i32 %3, i8* %4) {
%6 = icmp sge i32 %1, %2
%7 = icmp slt i32 %1, %3
%8 = and i1 %6, %7
br i1 %8, label %9, label %10
9: ; preds = %5
ret void
10: ; preds = %5
%11 = icmp eq i8* %4, null
%12 = select i1 %11, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* %4
%13 = tail call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1, i32 %3, i8* %12)
%14 = tail call i32 @exit(i32 -1)
unreachable
}