#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(unsigned char);
int is_manpage_name(char *name) {
  char *lastdot = NULL;
  char *n = name;
  while (*n != '\0') {
    if (!isalnum((unsigned char)*n)) {
      switch (*n) {
      case '_':
        break;
      case '-':
      case '+':
      case '[':
      case ':':
        lastdot = NULL;
        break;
      case '.':
        lastdot = n;
        break;
      default:
        return 0;
      }
    }
    n++;
  }
  return lastdot > name && lastdot + 1 < n;
}


x86 assembly (clang, -O0):
<is_manpage_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ff <is_manpage_name+0xef>
mov    -0x20(%rbp),%rax
movzbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%eax
jne    11ee <is_manpage_name+0xde>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x24(%rbp)
sub    $0x2b,%eax
je     11c3 <is_manpage_name+0xb3>
jmp    1169 <is_manpage_name+0x59>
mov    -0x24(%rbp),%eax
sub    $0x2d,%eax
je     11c3 <is_manpage_name+0xb3>
jmp    117a <is_manpage_name+0x6a>
mov    -0x24(%rbp),%eax
sub    $0x2e,%eax
je     11d0 <is_manpage_name+0xc0>
jmp    118b <is_manpage_name+0x7b>
mov    -0x24(%rbp),%eax
sub    $0x3a,%eax
je     11c3 <is_manpage_name+0xb3>
jmp    119c <is_manpage_name+0x8c>
mov    -0x24(%rbp),%eax
sub    $0x5b,%eax
je     11c3 <is_manpage_name+0xb3>
jmp    11ad <is_manpage_name+0x9d>
mov    -0x24(%rbp),%eax
sub    $0x5f,%eax
jne    11dd <is_manpage_name+0xcd>
jmp    11be <is_manpage_name+0xae>
jmp    11e9 <is_manpage_name+0xd9>
movq   $0x0,-0x18(%rbp)
jmp    11e9 <is_manpage_name+0xd9>
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    11e9 <is_manpage_name+0xd9>
movl   $0x0,-0x4(%rbp)
jmp    122f <is_manpage_name+0x11f>
jmp    11ee <is_manpage_name+0xde>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112c <is_manpage_name+0x1c>
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x10(%rbp),%rcx
mov    %al,-0x25(%rbp)
jbe    1224 <is_manpage_name+0x114>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
cmp    -0x20(%rbp),%rax
setb   %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_manpage_name>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%al
xor    %r15d,%r15d
test   %al,%al
je     117f <is_manpage_name+0x6f>
movabs $0x1000000008005,%r12
mov    %r14,%rbx
jmp    114f <is_manpage_name+0x3f>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %r15d,%r15d
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1182 <is_manpage_name+0x72>
movzbl %al,%edi
call   1030 <isalnum@plt>
test   %eax,%eax
jne    1143 <is_manpage_name+0x33>
movsbl (%rbx),%eax
add    $0xffffffd5,%eax
cmp    $0x34,%eax
ja     11a3 <is_manpage_name+0x93>
bt     %rax,%r12
jb     1140 <is_manpage_name+0x30>
cmp    $0x3,%rax
je     117a <is_manpage_name+0x6a>
cmp    $0x34,%rax
je     1143 <is_manpage_name+0x33>
jmp    11a3 <is_manpage_name+0x93>
mov    %rbx,%r15
jmp    1143 <is_manpage_name+0x33>
mov    %r14,%rbx
cmp    %r14,%r15
seta   %al
add    $0x1,%r15
cmp    %rbx,%r15
setb   %cl
and    %al,%cl
movzbl %cl,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
xor    %eax,%eax
jmp    1197 <is_manpage_name+0x87>

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

LLVM IR (-O2):
define i32 @is_manpage_name(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %20, label %4
4: ; preds = %1, %15
%5 = phi i8 [ %18, %15 ], [ %2, %1 ]
%6 = phi i8* [ %17, %15 ], [ %0, %1 ]
%7 = phi i8* [ %16, %15 ], [ null, %1 ]
%8 = tail call i32 @isalnum(i8 zeroext %5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %4
%11 = load i8, i8* %6
%12 = sext i8 %11 to i32
switch i32 %12, label %28 [
i32 95, label %15
i32 45, label %13
i32 43, label %13
i32 91, label %13
i32 58, label %13
i32 46, label %14
]
13: ; preds = %10, %10, %10, %10
br label %15
14: ; preds = %10
br label %15
15: ; preds = %10, %13, %14, %4
%16 = phi i8* [ %7, %4 ], [ %6, %14 ], [ null, %13 ], [ %7, %10 ]
%17 = getelementptr inbounds i8, i8* %6, i64 1
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %4
20: ; preds = %15, %1
%21 = phi i8* [ null, %1 ], [ %16, %15 ]
%22 = phi i8* [ %0, %1 ], [ %17, %15 ]
%23 = icmp ugt i8* %21, %0
%24 = getelementptr inbounds i8, i8* %21, i64 1
%25 = icmp ult i8* %24, %22
%26 = select i1 %23, i1 %25, i1 false
%27 = zext i1 %26 to i32
br label %28
28: ; preds = %10, %20
%29 = phi i32 [ %27, %20 ], [ 0, %10 ]
ret i32 %29
}