#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 */
long INT_MAX;
long INT_MIN;
char *agt_readline(int);
int /*<<< orphan*/ gen_sysmsg(int, char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ r_free(char *);
long strtol(char *, char **, int);
long read_number(void) {
  char *s, *err;
  long n;
  n = 1;
  do {
    if (n != 1)
      gen_sysmsg(218, "Please enter a *number*. ", 1, NULL);
    s = agt_readline(1);
    n = strtol(s, &err, 10);
    if (err == s)
      err = NULL;
    (r_free(s), s = NULL);
  } while (err == NULL || n <= INT_MIN || n >= INT_MAX);
  return n;
}


x86 assembly (clang, -O0):
<read_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x1,-0x18(%rbp)
cmpq   $0x1,-0x18(%rbp)
je     1175 <read_number+0x35>
mov    $0xda,%edi
lea    0xe99(%rip),%rsi
mov    $0x1,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1040 <gen_sysmsg@plt>
mov    $0x1,%edi
call   1060 <agt_readline@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jne    11af <read_number+0x6f>
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <r_free@plt>
movq   $0x0,-0x8(%rbp)
mov    $0x1,%al
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x19(%rbp)
je     11fd <read_number+0xbd>
mov    -0x18(%rbp),%rcx
mov    $0x1,%al
mov    0x2e03(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x19(%rbp)
jle    11fd <read_number+0xbd>
mov    -0x18(%rbp),%rax
mov    0x2df4(%rip),%rcx
cmp    (%rcx),%rax
setge  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1150 <read_number+0x10>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_number>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%r12d
mov    %rsp,%r15
xor    %r13d,%r13d
mov    0x2e82(%rip),%rbp
xchg   %ax,%ax
cmp    $0x1,%r12
je     117e <read_number+0x3e>
mov    $0xda,%edi
lea    0xe8e(%rip),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1040 <gen_sysmsg@plt>
mov    $0x1,%edi
call   1060 <agt_readline@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,%r12
mov    (%rsp),%r14
cmp    %rbx,%r14
cmove  %r13,%r14
mov    %r14,(%rsp)
mov    %rbx,%rdi
call   1030 <r_free@plt>
test   %r14,%r14
je     1160 <read_number+0x20>
cmp    0x0(%rbp),%r12
jle    1160 <read_number+0x20>
mov    0x2e21(%rip),%rax
cmp    (%rax),%r12
jge    1160 <read_number+0x20>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Please enter a *number*. \00"
@INT_MIN = global i64 0
@INT_MAX = global i64 0
define i64 @read_number() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i64
store i64 1, i64* %3
br label %4
4: ; preds = %31, %0
%5 = load i64, i64* %3
%6 = icmp ne i64 %5, 1
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = call i32 @gen_sysmsg(i32 218, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 1, i32* null)
br label %9
9: ; preds = %7, %4
%10 = call i8* @agt_readline(i32 1)
store i8* %10, i8** %1
%11 = load i8*, i8** %1
%12 = call i64 @strtol(i8* %11, i8** %2, i32 10)
store i64 %12, i64* %3
%13 = load i8*, i8** %2
%14 = load i8*, i8** %1
%15 = icmp eq i8* %13, %14
br i1 %15, label %16, label %17
16: ; preds = %9
store i8* null, i8** %2
br label %17
17: ; preds = %16, %9
%18 = load i8*, i8** %1
%19 = call i32 @r_free(i8* %18)
store i8* null, i8** %1
br label %20
20: ; preds = %17
%21 = load i8*, i8** %2
%22 = icmp eq i8* %21, null
br i1 %22, label %31, label %23
23: ; preds = %20
%24 = load i64, i64* %3
%25 = load i64, i64* @INT_MIN
%26 = icmp sle i64 %24, %25
br i1 %26, label %31, label %27
27: ; preds = %23
%28 = load i64, i64* %3
%29 = load i64, i64* @INT_MAX
%30 = icmp sge i64 %28, %29
br label %31
31: ; preds = %27, %23, %20
%32 = phi i1 [ true, %23 ], [ true, %20 ], [ %30, %27 ]
br i1 %32, label %4, label %33
33: ; preds = %31
%34 = load i64, i64* %3
ret i64 %34
}

LLVM IR (-O2):
@.str = [26 x i8] c"Please enter a *number*. \00"
@INT_MIN = global i64 0
@INT_MAX = global i64 0
define i64 @read_number() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
br label %3
3: ; preds = %8, %0
%4 = phi i64 [ 1, %0 ], [ %10, %8 ]
%5 = icmp eq i64 %4, 1
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @gen_sysmsg(i32 218, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 1, i32* null)
br label %8
8: ; preds = %6, %3
%9 = tail call i8* @agt_readline(i32 1)
%10 = call i64 @strtol(i8* %9, i8** %1, i32 10)
%11 = load i8*, i8** %1
%12 = icmp eq i8* %11, %9
%13 = select i1 %12, i8* null, i8* %11
store i8* %13, i8** %1
%14 = tail call i32 @r_free(i8* %9)
%15 = icmp ne i8* %13, null
%16 = load i64, i64* @INT_MIN
%17 = icmp sgt i64 %10, %16
%18 = select i1 %15, i1 %17, i1 false
%19 = load i64, i64* @INT_MAX
%20 = icmp slt i64 %10, %19
%21 = select i1 %18, i1 %20, i1 false
br i1 %21, label %22, label %3
22: ; preds = %8
ret i64 %10
}