#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 scalar_t__ uintmax_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
scalar_t__ UINTMAX_MAX;
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ perror(char *);
scalar_t__ strtoumax(int /*<<< orphan*/, int /*<<< orphan*/ *, int);
uintmax_t read_number(void) {
  uintmax_t number;
  errno = 0;
  number = strtoumax(optarg, NULL, 10);
  if ((number == 0 || number == UINTMAX_MAX) && errno != 0) {
    perror("strtoumax");
    exit(EXIT_FAILURE);
  }
  return number;
}


x86 assembly (clang, -O0):
<read_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e91(%rip),%rax
movq   $0x0,(%rax)
mov    0x2eab(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtoumax@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1180 <read_number+0x50>
mov    -0x8(%rbp),%rax
mov    0x2e71(%rip),%rcx
cmp    (%rcx),%rax
jne    11ab <read_number+0x7b>
mov    0x2e49(%rip),%rax
cmpq   $0x0,(%rax)
je     11ab <read_number+0x7b>
lea    0xe68(%rip),%rdi
call   1030 <perror@plt>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_number>:
push   %rbx
mov    0x2e98(%rip),%rbx
movq   $0x0,(%rbx)
mov    0x2eb2(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtoumax@plt>
test   %rax,%rax
je     1165 <read_number+0x35>
mov    0x2e88(%rip),%rcx
cmp    (%rcx),%rax
jne    116b <read_number+0x3b>
cmpq   $0x0,(%rbx)
jne    116d <read_number+0x3d>
pop    %rbx
ret
lea    0xe8c(%rip),%rdi
call   1030 <perror@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@errno = global i64 0
@optarg = global i32 0
@UINTMAX_MAX = global i64 0
@.str = [10 x i8] c"strtoumax\00"
@EXIT_FAILURE = global i32 0
define i64 @read_number() {
%1 = alloca i64
store i64 0, i64* @errno
%2 = load i32, i32* @optarg
%3 = call i64 @strtoumax(i32 %2, i32* null, i32 10)
store i64 %3, i64* %1
%4 = load i64, i64* %1
%5 = icmp eq i64 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %0
%7 = load i64, i64* %1
%8 = load i64, i64* @UINTMAX_MAX
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %17
10: ; preds = %6, %0
%11 = load i64, i64* @errno
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %10, %6
%18 = load i64, i64* %1
ret i64 %18
}

LLVM IR (-O2):
@errno = global i64 0
@optarg = global i32 0
@UINTMAX_MAX = global i64 0
@.str = [10 x i8] c"strtoumax\00"
@EXIT_FAILURE = global i32 0
define i64 @read_number() {
store i64 0, i64* @errno
%1 = load i32, i32* @optarg
%2 = tail call i64 @strtoumax(i32 %1, i32* null, i32 10)
%3 = icmp eq i64 %2, 0
br i1 %3, label %10, label %4
4: ; preds = %0
%5 = load i64, i64* @UINTMAX_MAX
%6 = icmp eq i64 %2, %5
%7 = load i64, i64* @errno
%8 = icmp ne i64 %7, 0
%9 = select i1 %6, i1 %8, i1 false
br i1 %9, label %13, label %17
10: ; preds = %0
%11 = load i64, i64* @errno
%12 = icmp eq i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %4, %10
%14 = tail call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = tail call i32 @exit(i32 %15)
unreachable
17: ; preds = %10, %4
ret i64 %2
}