#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*/ fprintf(int /*<<< orphan*/, char *, char const *,
                           char const *, unsigned long);
int /*<<< orphan*/ stderr;
unsigned long strtoul(char const *, char **, int /*<<< orphan*/);
int /*<<< orphan*/ usage(char const *);
unsigned long component(const char *prog, const char *arg, int issRGB) {
  char *ep;
  unsigned long c = strtoul(arg, &ep, 0);
  if (ep <= arg || *ep || c > 65535 || (issRGB && c > 255)) {
    fprintf(stderr, "%s: %s: invalid component value (%lu)\n", prog, arg, c);
    usage(prog);
  }
  return c;
}


x86 assembly (clang, -O0):
<component>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1050 <strtoul@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jbe    119a <component+0x6a>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    119a <component+0x6a>
cmpq   $0xffff,-0x28(%rbp)
ja     119a <component+0x6a>
cmpl   $0x0,-0x14(%rbp)
je     11c4 <component+0x94>
cmpq   $0xff,-0x28(%rbp)
jbe    11c4 <component+0x94>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    0xe4a(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <usage@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<component>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsp,%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1050 <strtoul@plt>
mov    %rax,%r15
mov    (%rsp),%rax
cmp    %rbx,%rax
jbe    1173 <component+0x43>
cmpb   $0x0,(%rax)
jne    1173 <component+0x43>
cmp    $0xffff,%r15
ja     1173 <component+0x43>
test   %ebp,%ebp
je     1199 <component+0x69>
cmp    $0x100,%r15
jb     1199 <component+0x69>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
lea    0xe7d(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %r15,%r8
call   1030 <fprintf@plt>
mov    %r14,%rdi
call   1040 <usage@plt>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [39 x i8] c"%s: %s: invalid component value (%lu)\0A\00"
define i64 @component(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %5
%10 = call i64 @strtoul(i8* %9, i8** %7, i32 0)
store i64 %10, i64* %8
%11 = load i8*, i8** %7
%12 = load i8*, i8** %5
%13 = icmp ule i8* %11, %12
br i1 %13, label %28, label %14
14: ; preds = %3
%15 = load i8*, i8** %7
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %28, label %19
19: ; preds = %14
%20 = load i64, i64* %8
%21 = icmp ugt i64 %20, 65535
br i1 %21, label %28, label %22
22: ; preds = %19
%23 = load i32, i32* %6
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %36
25: ; preds = %22
%26 = load i64, i64* %8
%27 = icmp ugt i64 %26, 255
br i1 %27, label %28, label %36
28: ; preds = %25, %19, %14, %3
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %4
%31 = load i8*, i8** %5
%32 = load i64, i64* %8
%33 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %30, i8* %31, i64 %32)
%34 = load i8*, i8** %4
%35 = call i32 @usage(i8* %34)
br label %36
36: ; preds = %28, %25, %22
%37 = load i64, i64* %8
ret i64 %37
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [39 x i8] c"%s: %s: invalid component value (%lu)\0A\00"
define i64 @component(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = call i64 @strtoul(i8* %1, i8** %4, i32 0)
%7 = load i8*, i8** %4
%8 = icmp ugt i8* %7, %1
br i1 %8, label %9, label %18
9: ; preds = %3
%10 = load i8, i8* %7
%11 = icmp ne i8 %10, 0
%12 = icmp ugt i64 %6, 65535
%13 = select i1 %11, i1 true, i1 %12
br i1 %13, label %18, label %14
14: ; preds = %9
%15 = icmp ne i32 %2, 0
%16 = icmp ugt i64 %6, 255
%17 = select i1 %15, i1 %16, i1 false
br i1 %17, label %18, label %22
18: ; preds = %14, %9, %3
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i64 %6)
%21 = tail call i32 @usage(i8* %0)
br label %22
22: ; preds = %18, %14
ret i64 %6
}