#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ myisalnum(char);
scalar_t__ myisspace(char);
char *strtok(char *, char *);
void _write_man_xref(FILE *f, char *xref, char *ext, int notfirst) {
  char *tok, *p;
  tok = strtok(xref, ",;");
  while (tok) {
    while ((*tok) && (myisspace(*tok)))
      tok++;
    p = tok;
    while (*p) {
      if ((!myisalnum(*p)) && (*p != '_'))
        break;
      p++;
    }
    if (!*p) {
      if (notfirst)
        fprintf(f, ",\n");
      fprintf(f, ".BR %s (%s)", tok, ext);
      notfirst = 1;
    }
    tok = strtok(NULL, ",;");
  }
}


x86 assembly (clang, -O0):
<_write_man_xref>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe9e(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     127a <_write_man_xref+0x13a>
jmp    117b <_write_man_xref+0x3b>
mov    -0x28(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x31(%rbp)
je     11a6 <_write_man_xref+0x66>
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1030 <myisspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    11b6 <_write_man_xref+0x76>
jmp    11c7 <_write_man_xref+0x87>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    117b <_write_man_xref+0x3b>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
je     1217 <_write_man_xref+0xd7>
mov    -0x30(%rbp),%rax
movsbl (%rax),%edi
call   1060 <myisalnum@plt>
cmp    $0x0,%eax
jne    1206 <_write_man_xref+0xc6>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     1206 <_write_man_xref+0xc6>
jmp    1217 <_write_man_xref+0xd7>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11cf <_write_man_xref+0x8f>
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1261 <_write_man_xref+0x121>
cmpl   $0x0,-0x1c(%rbp)
je     1240 <_write_man_xref+0x100>
mov    -0x8(%rbp),%rdi
lea    0xdca(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xdb3(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x1c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd94(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x28(%rbp)
jmp    116b <_write_man_xref+0x2b>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_write_man_xref>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %rsi,%rax
mov    %rdi,%rbx
lea    0xe93(%rip),%rsi
mov    %rax,%rdi
call   1050 <strtok@plt>
test   %rax,%rax
je     124b <_write_man_xref+0xfb>
mov    %rax,%r12
lea    0xe78(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    (%r12),%al
test   %al,%al
je     11bf <_write_man_xref+0x6f>
lea    0x1(%r12),%r15
nopl   (%rax)
movsbl %al,%edi
call   1030 <myisspace@plt>
test   %rax,%rax
je     1210 <_write_man_xref+0xc0>
movzbl 0x1(%r12),%eax
add    $0x1,%r12
add    $0x1,%r15
test   %al,%al
jne    11a0 <_write_man_xref+0x50>
test   %ebp,%ebp
je     11dc <_write_man_xref+0x8c>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xe2f(%rip),%rdi
mov    %rbx,%rcx
call   1060 <fwrite@plt>
mov    %rbx,%rdi
lea    0xe20(%rip),%rsi
mov    %r12,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%ebp
xor    %edi,%edi
mov    %r13,%rsi
call   1050 <strtok@plt>
mov    %rax,%r12
test   %rax,%rax
jne    1190 <_write_man_xref+0x40>
jmp    124b <_write_man_xref+0xfb>
nopl   0x0(%rax)
mov    (%r12),%al
jmp    1228 <_write_man_xref+0xd8>
cs nopw 0x0(%rax,%rax,1)
movzbl (%r15),%eax
add    $0x1,%r15
test   %al,%al
je     11bf <_write_man_xref+0x6f>
movsbl %al,%edi
call   1070 <myisalnum@plt>
test   %eax,%eax
jne    1220 <_write_man_xref+0xd0>
movzbl -0x1(%r15),%eax
cmp    $0x5f,%al
je     1220 <_write_man_xref+0xd0>
test   %al,%al
je     11bf <_write_man_xref+0x6f>
jmp    11f8 <_write_man_xref+0xa8>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c",;\00"
@.str.1 = [3 x i8] c",\0A\00"
@.str.2 = [12 x i8] c".BR %s (%s)\00"
define void @_write_man_xref(i32* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%11 = load i8*, i8** %6
%12 = call i8* @strtok(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %12, i8** %9
br label %13
13: ; preds = %67, %4
%14 = load i8*, i8** %9
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %69
16: ; preds = %13
br label %17
17: ; preds = %29, %16
%18 = load i8*, i8** %9
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = load i8*, i8** %9
%24 = load i8, i8* %23
%25 = call i64 @myisspace(i8 signext %24)
%26 = icmp ne i64 %25, 0
br label %27
27: ; preds = %22, %17
%28 = phi i1 [ false, %17 ], [ %26, %22 ]
br i1 %28, label %29, label %32
29: ; preds = %27
%30 = load i8*, i8** %9
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %9
br label %17
32: ; preds = %27
%33 = load i8*, i8** %9
store i8* %33, i8** %10
br label %34
34: ; preds = %49, %32
%35 = load i8*, i8** %10
%36 = load i8, i8* %35
%37 = icmp ne i8 %36, 0
br i1 %37, label %38, label %52
38: ; preds = %34
%39 = load i8*, i8** %10
%40 = load i8, i8* %39
%41 = call i32 @myisalnum(i8 signext %40)
%42 = icmp ne i32 %41, 0
br i1 %42, label %49, label %43
43: ; preds = %38
%44 = load i8*, i8** %10
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp ne i32 %46, 95
br i1 %47, label %48, label %49
48: ; preds = %43
br label %52
49: ; preds = %43, %38
%50 = load i8*, i8** %10
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %10
br label %34
52: ; preds = %48, %34
%53 = load i8*, i8** %10
%54 = load i8, i8* %53
%55 = icmp ne i8 %54, 0
br i1 %55, label %67, label %56
56: ; preds = %52
%57 = load i32, i32* %8
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %56
%60 = load i32*, i32** %5
%61 = call i32 (i32*, i8*, ...) @fprintf(i32* %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %62
62: ; preds = %59, %56
%63 = load i32*, i32** %5
%64 = load i8*, i8** %9
%65 = load i8*, i8** %7
%66 = call i32 (i32*, i8*, ...) @fprintf(i32* %63, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %64, i8* %65)
store i32 1, i32* %8
br label %67
67: ; preds = %62, %52
%68 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %68, i8** %9
br label %13
69: ; preds = %13
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c",;\00"
@.str.1 = [3 x i8] c",\0A\00"
@.str.2 = [12 x i8] c".BR %s (%s)\00"
define void @_write_man_xref(i32* nocapture %0, i8* %1, i8* %2, i32 %3) {
%5 = tail call i8* @strtok(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %46, label %7
7: ; preds = %4, %42
%8 = phi i8* [ %44, %42 ], [ %5, %4 ]
%9 = phi i32 [ %43, %42 ], [ %3, %4 ]
%10 = load i8, i8* %8
%11 = icmp eq i8 %10, 0
br i1 %11, label %35, label %12
12: ; preds = %7, %17
%13 = phi i8 [ %19, %17 ], [ %10, %7 ]
%14 = phi i8* [ %18, %17 ], [ %8, %7 ]
%15 = tail call i64 @myisspace(i8 signext %13)
%16 = icmp eq i64 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %12
%18 = getelementptr inbounds i8, i8* %14, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %35, label %12
21: ; preds = %12
%22 = load i8, i8* %14
%23 = icmp eq i8 %22, 0
br i1 %23, label %35, label %24
24: ; preds = %21, %31
%25 = phi i8 [ %33, %31 ], [ %22, %21 ]
%26 = phi i8* [ %32, %31 ], [ %14, %21 ]
%27 = tail call i32 @myisalnum(i8 signext %25)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = load i8, i8* %26
switch i8 %30, label %42 [
i8 95, label %31
i8 0, label %35
]
31: ; preds = %29, %24
%32 = getelementptr inbounds i8, i8* %26, i64 1
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 0
br i1 %34, label %35, label %24
35: ; preds = %17, %31, %29, %7, %21
%36 = phi i8* [ %14, %21 ], [ %8, %7 ], [ %14, %29 ], [ %14, %31 ], [ %18, %17 ]
%37 = icmp eq i32 %9, 0
br i1 %37, label %40, label %38
38: ; preds = %35
%39 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 2, i64 1, i32* %0)
br label %40
40: ; preds = %38, %35
%41 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %36, i8* %2)
br label %42
42: ; preds = %29, %40
%43 = phi i32 [ 1, %40 ], [ %9, %29 ]
%44 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%45 = icmp eq i8* %44, null
br i1 %45, label %46, label %7
46: ; preds = %42, %4
ret void
}