#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 /*<<< orphan*/ num;

/* Variables and functions */
int const atoi(char const *);
int /*<<< orphan*/ snprintf(char *, int, char *, int const);
scalar_t__ strcmp(char const *, char *);
int checknumrange(const char *value, const int start, const int end) {
  char num[20];
  if (value != NULL)
    snprintf(num, sizeof(num), "%d", atoi(value));
  if (value == NULL || strcmp(value, num) || atoi(value) < start ||
      atoi(value) > end)
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<checknumrange>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1175 <checknumrange+0x45>
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%ecx
mov    $0x14,%esi
lea    0xe90(%rip),%rdx
call   1030 <snprintf@plt>
cmpq   $0x0,-0x10(%rbp)
je     11bb <checknumrange+0x8b>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11bb <checknumrange+0x8b>
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
cmp    -0x14(%rbp),%eax
jl     11bb <checknumrange+0x8b>
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
cmp    -0x18(%rbp),%eax
jle    11c7 <checknumrange+0x97>
movl   $0x1,-0x4(%rbp)
jmp    11ce <checknumrange+0x9e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checknumrange>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    $0x1,%ebx
test   %rdi,%rdi
je     1196 <checknumrange+0x66>
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbp
call   1050 <atoi@plt>
lea    0xea5(%rip),%rdx
mov    %rsp,%r12
mov    %r12,%rdi
mov    $0x14,%esi
mov    %eax,%ecx
call   1030 <snprintf@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1196 <checknumrange+0x66>
mov    %rbp,%rdi
call   1050 <atoi@plt>
cmp    %r15d,%eax
setl   %cl
cmp    %r14d,%eax
setg   %al
or     %cl,%al
movzbl %al,%ebx
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @checknumrange(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca [20 x i8]
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %16
11: ; preds = %3
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%13 = load i8*, i8** %5
%14 = call i32 @atoi(i8* %13)
%15 = call i32 @snprintf(i8* %12, i32 20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %11, %3
%17 = load i8*, i8** %5
%18 = icmp eq i8* %17, null
br i1 %18, label %34, label %19
19: ; preds = %16
%20 = load i8*, i8** %5
%21 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%22 = call i64 @strcmp(i8* %20, i8* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %34, label %24
24: ; preds = %19
%25 = load i8*, i8** %5
%26 = call i32 @atoi(i8* %25)
%27 = load i32, i32* %6
%28 = icmp slt i32 %26, %27
br i1 %28, label %34, label %29
29: ; preds = %24
%30 = load i8*, i8** %5
%31 = call i32 @atoi(i8* %30)
%32 = load i32, i32* %7
%33 = icmp sgt i32 %31, %32
br i1 %33, label %34, label %35
34: ; preds = %29, %24, %19, %16
store i32 1, i32* %4
br label %36
35: ; preds = %29
store i32 0, i32* %4
br label %36
36: ; preds = %35, %34
%37 = load i32, i32* %4
ret i32 %37
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @checknumrange(i8* %0, i32 %1, i32 %2) {
%4 = alloca [20 x i8]
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%6 = icmp eq i8* %0, null
br i1 %6, label %18, label %7
7: ; preds = %3
%8 = tail call i32 @atoi(i8* %0)
%9 = call i32 @snprintf(i8* %5, i32 20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i64 @strcmp(i8* %0, i8* %5)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %7
%13 = call i32 @atoi(i8* %0)
%14 = icmp slt i32 %13, %1
%15 = icmp sgt i32 %13, %2
%16 = or i1 %14, %15
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %12, %3, %7
%19 = phi i32 [ 1, %3 ], [ 1, %7 ], [ %17, %12 ]
ret i32 %19
}