#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*/ isalnum(char const);
scalar_t__ isspace(char const);
int canon_doc_option(const char **name) {
  int non_opt;
  while (isspace(**name))
    (*name)++;
  non_opt = (**name != '-');
  while (**name && !isalnum(**name))
    (*name)++;
  return non_opt;
}


x86 assembly (clang, -O0):
<canon_doc_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     1158 <canon_doc_option+0x38>
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    112c <canon_doc_option+0xc>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0xd(%rbp)
je     11a2 <canon_doc_option+0x82>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    11b2 <canon_doc_option+0x92>
jmp    11c5 <canon_doc_option+0xa5>
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    1170 <canon_doc_option+0x50>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<canon_doc_option>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%rax
movsbl (%rax),%edi
nopl   0x0(%rax)
call   1040 <isspace@plt>
test   %rax,%rax
je     114a <canon_doc_option+0x2a>
mov    (%rbx),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rbx)
movsbl 0x1(%rax),%edi
jmp    1130 <canon_doc_option+0x10>
mov    (%rbx),%rax
mov    (%rax),%bpl
test   %bpl,%bpl
je     117e <canon_doc_option+0x5e>
mov    %ebp,%eax
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <isalnum@plt>
test   %eax,%eax
jne    117e <canon_doc_option+0x5e>
mov    (%rbx),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rbx)
movzbl 0x1(%rax),%eax
test   %al,%al
jne    1160 <canon_doc_option+0x40>
xor    %eax,%eax
cmp    $0x2d,%bpl
setne  %al
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @canon_doc_option(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
store i8** %0, i8*** %2
br label %4
4: ; preds = %10, %1
%5 = load i8**, i8*** %2
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
%8 = call i64 @isspace(i8 signext %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %4
%11 = load i8**, i8*** %2
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %11
br label %4
14: ; preds = %4
%15 = load i8**, i8*** %2
%16 = load i8*, i8** %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 45
%20 = zext i1 %19 to i32
store i32 %20, i32* %3
br label %21
21: ; preds = %36, %14
%22 = load i8**, i8*** %2
%23 = load i8*, i8** %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %34
27: ; preds = %21
%28 = load i8**, i8*** %2
%29 = load i8*, i8** %28
%30 = load i8, i8* %29
%31 = call i32 @isalnum(i8 signext %30)
%32 = icmp ne i32 %31, 0
%33 = xor i1 %32, true
br label %34
34: ; preds = %27, %21
%35 = phi i1 [ false, %21 ], [ %33, %27 ]
br i1 %35, label %36, label %40
36: ; preds = %34
%37 = load i8**, i8*** %2
%38 = load i8*, i8** %37
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %37
br label %21
40: ; preds = %34
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
define i32 @canon_doc_option(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = load i8, i8* %2
%4 = tail call i64 @isspace(i8 signext %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %1, %6
%7 = load i8*, i8** %0
%8 = getelementptr inbounds i8, i8* %7, i64 1
store i8* %8, i8** %0
%9 = load i8, i8* %8
%10 = tail call i64 @isspace(i8 signext %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %6
12: ; preds = %6, %1
%13 = load i8*, i8** %0
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %25, label %16
16: ; preds = %12, %20
%17 = phi i8 [ %23, %20 ], [ %14, %12 ]
%18 = tail call i32 @isalnum(i8 signext %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = load i8*, i8** %0
%22 = getelementptr inbounds i8, i8* %21, i64 1
store i8* %22, i8** %0
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %16
25: ; preds = %16, %20, %12
%26 = icmp ne i8 %14, 45
%27 = zext i1 %26 to i32
ret i32 %27
}