#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 */
scalar_t__ ERANGE;
long LONG_MAX;
long LONG_MIN;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stderr;
long strtol(char *, char **, int /*<<< orphan*/);
int isLongCL(char *input, int isVerbose) {
  char *end;
  long number;
  errno = 0;
  number = strtol(input, &end, 0);
  if ((errno == ERANGE && (number == LONG_MAX || number == LONG_MIN)) ||
      (errno != 0 && number == 0)) {
    if (isVerbose) {
      char msg[1024];
      sprintf(msg, "### Error for int '%s'", input);
      perror(msg);
    }
    return 0;
  } else if (end == input) {
    if (isVerbose) {
      fprintf(stderr, "### Error for int '%s': NaN\n", input);
    }
    return 0;
  } else if (*end != '\0') {
    if (1) {
      if (isVerbose) {
        fprintf(stderr, "### Error for int '%s': NaN, trailing '%s'\n", input,
                end);
      }
      return 0;
    } else {
      if (isVerbose) {
        fprintf(stderr, "### Warming for int '%s': trailing '%s'\n", input,
                end);
      }
      return 1;
    }
  } else {
    return 1;
  }
}


x86 assembly (clang, -O0):
<isLongCL>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    0x2e67(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %rax,-0x28(%rbp)
mov    0x2e46(%rip),%rax
mov    (%rax),%rax
mov    0x2e5c(%rip),%rcx
cmp    (%rcx),%rax
jne    11b5 <isLongCL+0x75>
mov    -0x28(%rbp),%rax
mov    0x2e30(%rip),%rcx
cmp    (%rcx),%rax
je     11d1 <isLongCL+0x91>
mov    -0x28(%rbp),%rax
mov    0x2e3c(%rip),%rcx
cmp    (%rcx),%rax
je     11d1 <isLongCL+0x91>
mov    0x2e04(%rip),%rax
cmpq   $0x0,(%rax)
je     120a <isLongCL+0xca>
cmpq   $0x0,-0x28(%rbp)
jne    120a <isLongCL+0xca>
cmpl   $0x0,-0x14(%rbp)
je     11fe <isLongCL+0xbe>
lea    -0x430(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe13(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x430(%rbp),%rdi
call   1050 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    1295 <isLongCL+0x155>
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    1249 <isLongCL+0x109>
cmpl   $0x0,-0x14(%rbp)
je     123d <isLongCL+0xfd>
mov    0x2da7(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xde1(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1295 <isLongCL+0x155>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     128e <isLongCL+0x14e>
cmpl   $0x0,-0x14(%rbp)
je     1282 <isLongCL+0x142>
mov    0x2d66(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xdb9(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1295 <isLongCL+0x155>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isLongCL>:
push   %rbp
push   %r14
push   %rbx
sub    $0x410,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
mov    0x2e69(%rip),%rbp
movq   $0x0,0x0(%rbp)
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    0x0(%rbp),%rcx
mov    0x2e6a(%rip),%rdx
cmp    (%rdx),%rcx
jne    1193 <isLongCL+0x53>
mov    0x2e46(%rip),%rdx
cmp    (%rdx),%rax
je     119d <isLongCL+0x5d>
mov    0x2e5a(%rip),%rdx
cmp    (%rdx),%rax
je     119d <isLongCL+0x5d>
test   %rcx,%rcx
je     11b1 <isLongCL+0x71>
test   %rax,%rax
jne    11b1 <isLongCL+0x71>
xor    %ebp,%ebp
test   %ebx,%ebx
jne    120f <isLongCL+0xcf>
mov    %ebp,%eax
add    $0x410,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x8(%rsp),%rcx
cmp    %r14,%rcx
je     11e2 <isLongCL+0xa2>
cmpb   $0x0,(%rcx)
je     1208 <isLongCL+0xc8>
test   %ebx,%ebx
je     1204 <isLongCL+0xc4>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
xor    %ebp,%ebp
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    11a3 <isLongCL+0x63>
test   %ebx,%ebx
je     1204 <isLongCL+0xc4>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
lea    0xe21(%rip),%rsi
xor    %ebp,%ebp
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    11a3 <isLongCL+0x63>
xor    %ebp,%ebp
jmp    11a3 <isLongCL+0x63>
mov    $0x1,%ebp
jmp    11a3 <isLongCL+0x63>
lea    0xdea(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rdx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <perror@plt>
jmp    11a3 <isLongCL+0x63>

LLVM IR (-O0):
@errno = global i64 0
@ERANGE = global i64 0
@LONG_MAX = global i64 0
@LONG_MIN = global i64 0
@.str = [23 x i8] c"### Error for int '%s'\00"
@stderr = global i32 0
@.str.1 = [29 x i8] c"### Error for int '%s': NaN\0A\00"
@.str.2 = [44 x i8] c"### Error for int '%s': NaN, trailing '%s'\0A\00"
define i32 @isLongCL(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca [1024 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
store i64 0, i64* @errno
%9 = load i8*, i8** %4
%10 = call i64 @strtol(i8* %9, i8** %6, i32 0)
store i64 %10, i64* %7
%11 = load i64, i64* @errno
%12 = load i64, i64* @ERANGE
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %22
14: ; preds = %2
%15 = load i64, i64* %7
%16 = load i64, i64* @LONG_MAX
%17 = icmp eq i64 %15, %16
br i1 %17, label %28, label %18
18: ; preds = %14
%19 = load i64, i64* %7
%20 = load i64, i64* @LONG_MIN
%21 = icmp eq i64 %19, %20
br i1 %21, label %28, label %22
22: ; preds = %18, %2
%23 = load i64, i64* @errno
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %38
25: ; preds = %22
%26 = load i64, i64* %7
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %38
28: ; preds = %25, %18, %14
%29 = load i32, i32* %5
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %37
31: ; preds = %28
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%33 = load i8*, i8** %4
%34 = call i32 @sprintf(i8* %32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %33)
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%36 = call i32 @perror(i8* %35)
br label %37
37: ; preds = %31, %28
store i32 0, i32* %3
br label %65
38: ; preds = %25, %22
%39 = load i8*, i8** %6
%40 = load i8*, i8** %4
%41 = icmp eq i8* %39, %40
br i1 %41, label %42, label %50
42: ; preds = %38
%43 = load i32, i32* %5
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %49
45: ; preds = %42
%46 = load i32, i32* @stderr
%47 = load i8*, i8** %4
%48 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %47)
br label %49
49: ; preds = %45, %42
store i32 0, i32* %3
br label %65
50: ; preds = %38
%51 = load i8*, i8** %6
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %64
55: ; preds = %50
%56 = load i32, i32* %5
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %63
58: ; preds = %55
%59 = load i32, i32* @stderr
%60 = load i8*, i8** %4
%61 = load i8*, i8** %6
%62 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %60, i8* %61)
br label %63
63: ; preds = %58, %55
store i32 0, i32* %3
br label %65
64: ; preds = %50
store i32 1, i32* %3
br label %65
65: ; preds = %64, %63, %49, %37
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
@errno = global i64 0
@ERANGE = global i64 0
@LONG_MAX = global i64 0
@LONG_MIN = global i64 0
@.str = [23 x i8] c"### Error for int '%s'\00"
@stderr = global i32 0
@.str.1 = [29 x i8] c"### Error for int '%s': NaN\0A\00"
@.str.2 = [44 x i8] c"### Error for int '%s': NaN, trailing '%s'\0A\00"
define i32 @isLongCL(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca [1024 x i8]
%5 = bitcast i8** %3 to i8*
store i64 0, i64* @errno
%6 = call i64 @strtol(i8* %0, i8** %3, i32 0)
%7 = load i64, i64* @errno
%8 = load i64, i64* @ERANGE
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i64, i64* @LONG_MAX
%12 = icmp eq i64 %6, %11
%13 = load i64, i64* @LONG_MIN
%14 = icmp eq i64 %6, %13
%15 = select i1 %12, i1 true, i1 %14
br i1 %15, label %20, label %16
16: ; preds = %10, %2
%17 = icmp ne i64 %7, 0
%18 = icmp eq i64 %6, 0
%19 = select i1 %17, i1 %18, i1 false
br i1 %19, label %20, label %26
20: ; preds = %16, %10
%21 = icmp eq i32 %1, 0
br i1 %21, label %42, label %22
22: ; preds = %20
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%24 = call i32 @sprintf(i8* %23, i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %0)
%25 = call i32 @perror(i8* %23)
br label %42
26: ; preds = %16
%27 = load i8*, i8** %3
%28 = icmp eq i8* %27, %0
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = icmp eq i32 %1, 0
br i1 %30, label %42, label %31
31: ; preds = %29
%32 = load i32, i32* @stderr
%33 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %42
34: ; preds = %26
%35 = load i8, i8* %27
%36 = icmp eq i8 %35, 0
br i1 %36, label %42, label %37
37: ; preds = %34
%38 = icmp eq i32 %1, 0
br i1 %38, label %42, label %39
39: ; preds = %37
%40 = load i32, i32* @stderr
%41 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %27)
br label %42
42: ; preds = %34, %37, %39, %29, %31, %20, %22
%43 = phi i32 [ 0, %22 ], [ 0, %20 ], [ 0, %31 ], [ 0, %29 ], [ 0, %39 ], [ 0, %37 ], [ 1, %34 ]
ret i32 %43
}