#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 */
struct manpaths {
  int dummy;
};

/* Variables and functions */
char *getenv(char *);
int /*<<< orphan*/ manpath_manconf(struct manpaths *, char const *);
int /*<<< orphan*/ manpath_parseline(struct manpaths *, char *);
int strlen(char *);
char *strstr(char *, char *);
void manpath_parse(struct manpaths *dirs, const char *file, char *defp,
                   char *auxp) {
  char *insert;
  manpath_parseline(dirs, auxp);
  if (NULL != defp) {
    manpath_parseline(dirs, defp);
    return;
  }
  defp = getenv("MANPATH");
  if (NULL == file)
    file = "/etc/man.conf";
  if (NULL == defp || '\0' == defp[0]) {
    manpath_manconf(dirs, file);
    return;
  }
  if (':' == defp[0]) {
    manpath_manconf(dirs, file);
    manpath_parseline(dirs, defp);
    return;
  }
  if (':' == defp[strlen(defp) - 1]) {
    manpath_parseline(dirs, defp);
    manpath_manconf(dirs, file);
    return;
  }
  insert = strstr(defp, "::");
  if (NULL != insert) {
    *insert++ = '\0';
    manpath_parseline(dirs, defp);
    manpath_manconf(dirs, file);
    manpath_parseline(dirs, insert + 1);
    return;
  }
  manpath_parseline(dirs, defp);
}


x86 assembly (clang, -O0):
<manpath_parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <manpath_parseline@plt>
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
je     1193 <manpath_parse+0x43>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <manpath_parseline@plt>
jmp    12d8 <manpath_parse+0x188>
lea    0xe66(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    11ba <manpath_parse+0x6a>
lea    0xe52(%rip),%rax
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
je     11d7 <manpath_parse+0x87>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    11e9 <manpath_parse+0x99>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <manpath_manconf@plt>
jmp    12d8 <manpath_parse+0x188>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x3a,%eax
cmp    %ecx,%eax
jne    121c <manpath_parse+0xcc>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <manpath_manconf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <manpath_parseline@plt>
jmp    12d8 <manpath_parse+0x188>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x3a,%eax
cmp    %ecx,%eax
jne    1269 <manpath_parse+0x119>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <manpath_parseline@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <manpath_manconf@plt>
jmp    12d8 <manpath_parse+0x188>
mov    -0x18(%rbp),%rdi
lea    0xda2(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
cmp    -0x28(%rbp),%rax
je     12cb <manpath_parse+0x17b>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <manpath_parseline@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <manpath_manconf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
add    $0x1,%rsi
call   1050 <manpath_parseline@plt>
jmp    12d8 <manpath_parse+0x188>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <manpath_parseline@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<manpath_parse>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r13
mov    %rdi,%r12
mov    %rcx,%rsi
call   1050 <manpath_parseline@plt>
test   %rbx,%rbx
je     1183 <manpath_parse+0x33>
mov    %r12,%rdi
mov    %rbx,%rsi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1050 <manpath_parseline@plt>
lea    0xe76(%rip),%rdi
call   1030 <getenv@plt>
test   %r13,%r13
lea    0xe6f(%rip),%r14
cmovne %r13,%r14
test   %rax,%rax
je     11cc <manpath_parse+0x7c>
mov    %rax,%r15
mov    (%rax),%al
cmp    $0x3a,%al
je     11e0 <manpath_parse+0x90>
test   %al,%al
je     11cc <manpath_parse+0x7c>
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x3a,-0x1(%rax,%r15,1)
jne    11f3 <manpath_parse+0xa3>
mov    %r12,%rdi
mov    %r15,%rsi
call   1050 <manpath_parseline@plt>
mov    %r12,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1060 <manpath_manconf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1060 <manpath_manconf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
jmp    1175 <manpath_parse+0x25>
lea    0xe1c(%rip),%rsi
mov    %r15,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
je     11eb <manpath_parse+0x9b>
mov    %rax,%rbx
movb   $0x0,(%rax)
mov    %r12,%rdi
mov    %r15,%rsi
call   1050 <manpath_parseline@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1060 <manpath_manconf@plt>
add    $0x2,%rbx
jmp    116f <manpath_parse+0x1f>

LLVM IR (-O0):
%struct.manpaths = type { i32 }
@.str = [8 x i8] c"MANPATH\00"
@.str.1 = [14 x i8] c"/etc/man.conf\00"
@.str.2 = [3 x i8] c"::\00"
define void @manpath_parse(%struct.manpaths* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca %struct.manpaths*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store %struct.manpaths* %0, %struct.manpaths** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%10 = load %struct.manpaths*, %struct.manpaths** %5
%11 = load i8*, i8** %8
%12 = call i32 @manpath_parseline(%struct.manpaths* %10, i8* %11)
%13 = load i8*, i8** %7
%14 = icmp ne i8* null, %13
br i1 %14, label %15, label %19
15: ; preds = %4
%16 = load %struct.manpaths*, %struct.manpaths** %5
%17 = load i8*, i8** %7
%18 = call i32 @manpath_parseline(%struct.manpaths* %16, i8* %17)
br label %89
19: ; preds = %4
%20 = call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i8* %20, i8** %7
%21 = load i8*, i8** %6
%22 = icmp eq i8* null, %21
br i1 %22, label %23, label %24
23: ; preds = %19
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8** %6
br label %24
24: ; preds = %23, %19
%25 = load i8*, i8** %7
%26 = icmp eq i8* null, %25
br i1 %26, label %33, label %27
27: ; preds = %24
%28 = load i8*, i8** %7
%29 = getelementptr inbounds i8, i8* %28, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 0, %31
br i1 %32, label %33, label %37
33: ; preds = %27, %24
%34 = load %struct.manpaths*, %struct.manpaths** %5
%35 = load i8*, i8** %6
%36 = call i32 @manpath_manconf(%struct.manpaths* %34, i8* %35)
br label %89
37: ; preds = %27
%38 = load i8*, i8** %7
%39 = getelementptr inbounds i8, i8* %38, i64 0
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 58, %41
br i1 %42, label %43, label %50
43: ; preds = %37
%44 = load %struct.manpaths*, %struct.manpaths** %5
%45 = load i8*, i8** %6
%46 = call i32 @manpath_manconf(%struct.manpaths* %44, i8* %45)
%47 = load %struct.manpaths*, %struct.manpaths** %5
%48 = load i8*, i8** %7
%49 = call i32 @manpath_parseline(%struct.manpaths* %47, i8* %48)
br label %89
50: ; preds = %37
%51 = load i8*, i8** %7
%52 = load i8*, i8** %7
%53 = call i32 @strlen(i8* %52)
%54 = sub nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %51, i64 %55
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp eq i32 58, %58
br i1 %59, label %60, label %67
60: ; preds = %50
%61 = load %struct.manpaths*, %struct.manpaths** %5
%62 = load i8*, i8** %7
%63 = call i32 @manpath_parseline(%struct.manpaths* %61, i8* %62)
%64 = load %struct.manpaths*, %struct.manpaths** %5
%65 = load i8*, i8** %6
%66 = call i32 @manpath_manconf(%struct.manpaths* %64, i8* %65)
br label %89
67: ; preds = %50
%68 = load i8*, i8** %7
%69 = call i8* @strstr(i8* %68, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %69, i8** %9
%70 = load i8*, i8** %9
%71 = icmp ne i8* null, %70
br i1 %71, label %72, label %85
72: ; preds = %67
%73 = load i8*, i8** %9
%74 = getelementptr inbounds i8, i8* %73, i32 1
store i8* %74, i8** %9
store i8 0, i8* %73
%75 = load %struct.manpaths*, %struct.manpaths** %5
%76 = load i8*, i8** %7
%77 = call i32 @manpath_parseline(%struct.manpaths* %75, i8* %76)
%78 = load %struct.manpaths*, %struct.manpaths** %5
%79 = load i8*, i8** %6
%80 = call i32 @manpath_manconf(%struct.manpaths* %78, i8* %79)
%81 = load %struct.manpaths*, %struct.manpaths** %5
%82 = load i8*, i8** %9
%83 = getelementptr inbounds i8, i8* %82, i64 1
%84 = call i32 @manpath_parseline(%struct.manpaths* %81, i8* %83)
br label %89
85: ; preds = %67
%86 = load %struct.manpaths*, %struct.manpaths** %5
%87 = load i8*, i8** %7
%88 = call i32 @manpath_parseline(%struct.manpaths* %86, i8* %87)
br label %89
89: ; preds = %85, %72, %60, %43, %33, %15
ret void
}

LLVM IR (-O2):
%struct.manpaths = type { i32 }
@.str = [8 x i8] c"MANPATH\00"
@.str.1 = [14 x i8] c"/etc/man.conf\00"
@.str.2 = [3 x i8] c"::\00"
define void @manpath_parse(%struct.manpaths* %0, i8* %1, i8* %2, i8* %3) {
%5 = tail call i32 @manpath_parseline(%struct.manpaths* %0, i8* %3)
%6 = icmp eq i8* %2, null
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call i32 @manpath_parseline(%struct.manpaths* %0, i8* %2)
br label %41
9: ; preds = %4
%10 = tail call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i8* %1, null
%12 = select i1 %11, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %1
%13 = icmp eq i8* %10, null
br i1 %13, label %16, label %14
14: ; preds = %9
%15 = load i8, i8* %10
switch i8 %15, label %21 [
i8 0, label %16
i8 58, label %18
]
16: ; preds = %14, %9
%17 = tail call i32 @manpath_manconf(%struct.manpaths* %0, i8* %12)
br label %41
18: ; preds = %14
%19 = tail call i32 @manpath_manconf(%struct.manpaths* %0, i8* %12)
%20 = tail call i32 @manpath_parseline(%struct.manpaths* %0, i8* %10)
br label %41
21: ; preds = %14
%22 = tail call i32 @strlen(i8* %10)
%23 = add nsw i32 %22, -1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %10, i64 %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 58
br i1 %27, label %28, label %31
28: ; preds = %21
%29 = tail call i32 @manpath_parseline(%struct.manpaths* %0, i8* %10)
%30 = tail call i32 @manpath_manconf(%struct.manpaths* %0, i8* %12)
br label %41
31: ; preds = %21
%32 = tail call i8* @strstr(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%33 = icmp eq i8* %32, null
br i1 %33, label %39, label %34
34: ; preds = %31
store i8 0, i8* %32
%35 = tail call i32 @manpath_parseline(%struct.manpaths* %0, i8* %10)
%36 = tail call i32 @manpath_manconf(%struct.manpaths* %0, i8* %12)
%37 = getelementptr inbounds i8, i8* %32, i64 2
%38 = tail call i32 @manpath_parseline(%struct.manpaths* %0, i8* %37)
br label %41
39: ; preds = %31
%40 = tail call i32 @manpath_parseline(%struct.manpaths* %0, i8* %10)
br label %41
41: ; preds = %39, %34, %28, %18, %16, %7
ret void
}