#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;
scalar_t__ errno;
int strtol(char const *, char **, int);
int validator_network(const char *network) {
  char *end_ptr = NULL;
  int net;
  net = strtol(network, &end_ptr, 10);
  if (errno == ERANGE || (net > 32 || net < 1) || *end_ptr)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<validator_network>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e98(%rip),%rax
mov    (%rax),%rax
mov    0x2e9e(%rip),%rcx
cmp    (%rcx),%rax
je     1177 <validator_network+0x67>
cmpl   $0x20,-0x1c(%rbp)
jg     1177 <validator_network+0x67>
cmpl   $0x1,-0x1c(%rbp)
jl     1177 <validator_network+0x67>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1183 <validator_network+0x73>
movl   $0x0,-0x4(%rbp)
jmp    118a <validator_network+0x7a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validator_network>:
push   %rax
movq   $0x0,(%rsp)
mov    %rsp,%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %eax,%ecx
mov    0x2ea9(%rip),%rax
mov    (%rax),%rdx
mov    0x2eaf(%rip),%rsi
xor    %eax,%eax
cmp    (%rsi),%rdx
je     1155 <validator_network+0x45>
cmp    $0x20,%ecx
jg     1155 <validator_network+0x45>
test   %ecx,%ecx
jle    1155 <validator_network+0x45>
mov    (%rsp),%rcx
xor    %eax,%eax
cmpb   $0x0,(%rcx)
sete   %al
pop    %rcx
ret

LLVM IR (-O0):
@errno = global i64 0
@ERANGE = global i64 0
define i32 @validator_network(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* null, i8** %4
%6 = load i8*, i8** %3
%7 = call i32 @strtol(i8* %6, i8** %4, i32 10)
store i32 %7, i32* %5
%8 = load i64, i64* @errno
%9 = load i64, i64* @ERANGE
%10 = icmp eq i64 %8, %9
br i1 %10, label %22, label %11
11: ; preds = %1
%12 = load i32, i32* %5
%13 = icmp sgt i32 %12, 32
br i1 %13, label %22, label %14
14: ; preds = %11
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, 1
br i1 %16, label %22, label %17
17: ; preds = %14
%18 = load i8*, i8** %4
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %17, %14, %11, %1
store i32 0, i32* %2
br label %24
23: ; preds = %17
store i32 1, i32* %2
br label %24
24: ; preds = %23, %22
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@errno = global i64 0
@ERANGE = global i64 0
define i32 @validator_network(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%4 = call i32 @strtol(i8* %0, i8** %2, i32 10)
%5 = load i64, i64* @errno
%6 = load i64, i64* @ERANGE
%7 = icmp eq i64 %5, %6
%8 = icmp sgt i32 %4, 32
%9 = select i1 %7, i1 true, i1 %8
%10 = icmp slt i32 %4, 1
%11 = select i1 %9, i1 true, i1 %10
br i1 %11, label %17, label %12
12: ; preds = %1
%13 = load i8*, i8** %2
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %12, %1
%18 = phi i32 [ 0, %1 ], [ %16, %12 ]
ret i32 %18
}