#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 */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ errx(int /*<<< orphan*/, char *);
int /*<<< orphan*/ isdigit(char const);
int xatou32(char const *, int *);
int parse_channel(const char *arg) {
  const char *s;
  int channel, err;
  for (s = arg; *s; s++)
    if (!isdigit(*s))
      errx(EXIT_FAILURE, "invalid channel number");
  channel = xatou32(arg, &err);
  if (err || channel > 26)
    errx(EXIT_FAILURE, "invalid channel number");
  return channel;
}


x86 assembly (clang, -O0):
<parse_channel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1191 <parse_channel+0x61>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%eax
jne    117b <parse_channel+0x4b>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
call   1050 <errx@plt>
jmp    1180 <parse_channel+0x50>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1144 <parse_channel+0x14>
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <xatou32@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    11b5 <parse_channel+0x85>
cmpl   $0x1a,-0x14(%rbp)
jle    11ca <parse_channel+0x9a>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
lea    0xe3b(%rip),%rsi
call   1050 <errx@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_channel>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%al
test   %al,%al
je     1185 <parse_channel+0x55>
lea    0x1(%r14),%rbx
mov    0x2e94(%rip),%r12
lea    0xead(%rip),%r15
jmp    116b <parse_channel+0x3b>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1185 <parse_channel+0x55>
movsbl %al,%edi
call   1040 <isdigit@plt>
test   %eax,%eax
jne    1160 <parse_channel+0x30>
mov    (%r12),%edi
mov    %r15,%rsi
call   1050 <errx@plt>
jmp    1160 <parse_channel+0x30>
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
call   1030 <xatou32@plt>
mov    %eax,%ebx
cmpl   $0x0,0x4(%rsp)
jne    11a0 <parse_channel+0x70>
cmp    $0x1b,%ebx
jl     11b5 <parse_channel+0x85>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
call   1050 <errx@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [23 x i8] c"invalid channel number\00"
define i32 @parse_channel(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
store i8* %6, i8** %3
br label %7
7: ; preds = %20, %1
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = call i32 @isdigit(i8 signext %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %11
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @errx(i32 %17, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %16, %11
br label %20
20: ; preds = %19
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %3
br label %7
23: ; preds = %7
%24 = load i8*, i8** %2
%25 = call i32 @xatou32(i8* %24, i32* %5)
store i32 %25, i32* %4
%26 = load i32, i32* %5
%27 = icmp ne i32 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %23
%29 = load i32, i32* %4
%30 = icmp sgt i32 %29, 26
br i1 %30, label %31, label %34
31: ; preds = %28, %23
%32 = load i32, i32* @EXIT_FAILURE
%33 = call i32 @errx(i32 %32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %34
34: ; preds = %31, %28
%35 = load i32, i32* %4
ret i32 %35
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [23 x i8] c"invalid channel number\00"
define i32 @parse_channel(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %18, label %6
6: ; preds = %1, %14
%7 = phi i8 [ %16, %14 ], [ %4, %1 ]
%8 = phi i8* [ %15, %14 ], [ %0, %1 ]
%9 = tail call i32 @isdigit(i8 signext %7)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @errx(i32 %12, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %6, %11
%15 = getelementptr inbounds i8, i8* %8, i64 1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %6
18: ; preds = %14, %1
%19 = call i32 @xatou32(i8* %0, i32* %2)
%20 = load i32, i32* %2
%21 = icmp ne i32 %20, 0
%22 = icmp sgt i32 %19, 26
%23 = select i1 %21, i1 true, i1 %22
br i1 %23, label %24, label %27
24: ; preds = %18
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @errx(i32 %25, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %18, %24
ret i32 %19
}