#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*/ fatal(char *, long, long, long);
long safe_cstring_to_long(char const *);
long safe_cstring_to_long_min_max(const char *text, long minimal,
                                  long maximal) {
  long result = safe_cstring_to_long(text);
  if (maximal < result || result < minimal)
    fatal("safe_cstring_to_long_min_max: %ld is not in range <%ld, %ld>.",
          result, minimal, maximal);
  return result;
}


x86 assembly (clang, -O0):
<safe_cstring_to_long_min_max>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <safe_cstring_to_long@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jl     115d <safe_cstring_to_long_min_max+0x3d>
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    1175 <safe_cstring_to_long_min_max+0x55>
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe90(%rip),%rdi
call   1040 <fatal@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<safe_cstring_to_long_min_max>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
call   1030 <safe_cstring_to_long@plt>
mov    %rax,%rbx
cmp    %r15,%rax
jg     113d <safe_cstring_to_long_min_max+0x1d>
cmp    %r14,%rbx
jge    1152 <safe_cstring_to_long_min_max+0x32>
lea    0xebc(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
call   1040 <fatal@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [62 x i8] c"safe_cstring_to_long_min_max: %ld is not in range <%ld, %ld>.\00"
define i64 @safe_cstring_to_long_min_max(i8* %0, i64 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%8 = load i8*, i8** %4
%9 = call i64 @safe_cstring_to_long(i8* %8)
store i64 %9, i64* %7
%10 = load i64, i64* %6
%11 = load i64, i64* %7
%12 = icmp slt i64 %10, %11
br i1 %12, label %17, label %13
13: ; preds = %3
%14 = load i64, i64* %7
%15 = load i64, i64* %5
%16 = icmp slt i64 %14, %15
br i1 %16, label %17, label %22
17: ; preds = %13, %3
%18 = load i64, i64* %7
%19 = load i64, i64* %5
%20 = load i64, i64* %6
%21 = call i32 @fatal(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i64 %18, i64 %19, i64 %20)
br label %22
22: ; preds = %17, %13
%23 = load i64, i64* %7
ret i64 %23
}

LLVM IR (-O2):
@.str = [62 x i8] c"safe_cstring_to_long_min_max: %ld is not in range <%ld, %ld>.\00"
define i64 @safe_cstring_to_long_min_max(i8* %0, i64 %1, i64 %2) {
%4 = tail call i64 @safe_cstring_to_long(i8* %0)
%5 = icmp sgt i64 %4, %2
%6 = icmp slt i64 %4, %1
%7 = or i1 %5, %6
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = tail call i32 @fatal(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i64 %4, i64 %1, i64 %2)
br label %10
10: ; preds = %3, %8
ret i64 %4
}