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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char *fgetln(int /*<<< orphan*/ *, size_t *);
int /*<<< orphan*/ *fopen(char const *, char *);
scalar_t__ isspace(unsigned char);
int /*<<< orphan*/ manpath_add(struct manpaths *, char *);
size_t strlen(char *);
scalar_t__ strncmp(char *, char *, size_t);
char *strrchr(char *, char);
void manpath_manconf(struct manpaths *dirs, const char *file) {
  FILE *stream;
  char *p, *q;
  size_t len, keysz;
  keysz = strlen("_whatdb");
  assert(keysz > 0);
  if (NULL == (stream = fopen(file, "r")))
    return;
  while (NULL != (p = fgetln(stream, &len))) {
    if (0 == len || '\n' != p[--len])
      break;
    p[len] = '\0';
    while (isspace((unsigned char)*p))
      p++;
    if (strncmp("_whatdb", p, keysz))
      continue;
    p += keysz;
    while (isspace((unsigned char)*p))
      p++;
    if ('\0' == *p)
      continue;
    if (NULL == (q = strrchr(p, '/')))
      continue;
    *q = '\0';
    manpath_add(dirs, p);
  }
  fclose(stream);
}


x86 assembly (clang, -O0):
<manpath_manconf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe59(%rip),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x10(%rbp),%rdi
lea    0xe3b(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x18(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    11e9 <manpath_manconf+0x59>
jmp    1329 <manpath_manconf+0x199>
jmp    11ee <manpath_manconf+0x5e>
mov    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   10a0 <fgetln@plt>
mov    %rax,%rcx
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
je     1320 <manpath_manconf+0x190>
xor    %eax,%eax
cmp    -0x30(%rbp),%rax
je     123e <manpath_manconf+0xae>
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    %rcx,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x30(%rbp)
movsbl -0x1(%rax,%rcx,1),%ecx
mov    $0xa,%eax
cmp    %ecx,%eax
je     1243 <manpath_manconf+0xb3>
jmp    1320 <manpath_manconf+0x190>
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
movzbl (%rax),%edi
call   1070 <isspace@plt>
cmp    $0x0,%rax
je     1276 <manpath_manconf+0xe6>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    124f <manpath_manconf+0xbf>
mov    -0x20(%rbp),%rsi
mov    -0x38(%rbp),%rdx
lea    0xd7b(%rip),%rdi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1299 <manpath_manconf+0x109>
jmp    11ee <manpath_manconf+0x5e>
mov    -0x38(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%edi
call   1070 <isspace@plt>
cmp    $0x0,%rax
je     12cc <manpath_manconf+0x13c>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    12a5 <manpath_manconf+0x115>
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    12e2 <manpath_manconf+0x152>
jmp    11ee <manpath_manconf+0x5e>
mov    -0x20(%rbp),%rdi
mov    $0x2f,%esi
call   1060 <strrchr@plt>
mov    %rax,%rcx
mov    %rcx,-0x28(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    1307 <manpath_manconf+0x177>
jmp    11ee <manpath_manconf+0x5e>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1090 <manpath_add@plt>
jmp    11ee <manpath_manconf+0x5e>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<manpath_manconf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    $0x1,%edi
call   1070 <assert@plt>
lea    0xe66(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     12a1 <manpath_manconf+0x121>
mov    %rax,%r13
mov    %rsp,%rsi
mov    %rax,%rdi
call   1090 <fgetln@plt>
test   %rax,%rax
je     1299 <manpath_manconf+0x119>
mov    (%rsp),%rcx
test   %rcx,%rcx
je     1299 <manpath_manconf+0x119>
lea    0xe22(%rip),%r15
mov    %rsp,%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    -0x1(%rcx),%rdx
mov    %rdx,(%rsp)
cmpb   $0xa,-0x1(%rax,%rcx,1)
jne    1299 <manpath_manconf+0x119>
movb   $0x0,(%rax,%rdx,1)
lea    -0x1(%rax),%rbp
add    $0x6,%rax
nop
mov    %rax,%rbx
movzbl 0x1(%rbp),%edi
add    $0x1,%rbp
call   1060 <isspace@plt>
mov    %rax,%rcx
lea    0x1(%rbx),%rax
test   %rcx,%rcx
jne    1210 <manpath_manconf+0x90>
mov    $0x7,%edx
mov    %r15,%rdi
mov    %rbp,%rsi
call   1030 <strncmp@plt>
test   %rax,%rax
je     1260 <manpath_manconf+0xe0>
mov    %r13,%rdi
mov    %r12,%rsi
call   1090 <fgetln@plt>
test   %rax,%rax
je     1299 <manpath_manconf+0x119>
mov    (%rsp),%rcx
test   %rcx,%rcx
jne    11f0 <manpath_manconf+0x70>
jmp    1299 <manpath_manconf+0x119>
nopl   0x0(%rax)
movzbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1060 <isspace@plt>
test   %rax,%rax
jne    1260 <manpath_manconf+0xe0>
cmpb   $0x0,(%rbx)
je     1241 <manpath_manconf+0xc1>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
je     1241 <manpath_manconf+0xc1>
movb   $0x0,(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <manpath_add@plt>
jmp    1241 <manpath_manconf+0xc1>
mov    %r13,%rdi
call   1040 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.manpaths = type { i32 }
@.str = [8 x i8] c"_whatdb\00"
@.str.1 = [2 x i8] c"r\00"
define void @manpath_manconf(%struct.manpaths* %0, i8* nocapture %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = tail call i32 @assert(i32 1)
%6 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %55, label %8
8: ; preds = %2
%9 = call i8* @fgetln(i32* %6, i64* %3)
%10 = icmp eq i8* %9, null
%11 = load i64, i64* %3
%12 = icmp eq i64 %11, 0
%13 = select i1 %10, i1 true, i1 %12
br i1 %13, label %53, label %14
14: ; preds = %8, %47
%15 = phi i64 [ %50, %47 ], [ %11, %8 ]
%16 = phi i8* [ %48, %47 ], [ %9, %8 ]
%17 = add i64 %15, -1
store i64 %17, i64* %3
%18 = getelementptr inbounds i8, i8* %16, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 10
br i1 %20, label %21, label %53
21: ; preds = %14
store i8 0, i8* %18
br label %22
22: ; preds = %22, %21
%23 = phi i8* [ %16, %21 ], [ %27, %22 ]
%24 = load i8, i8* %23
%25 = call i64 @isspace(i8 zeroext %24)
%26 = icmp eq i64 %25, 0
%27 = getelementptr inbounds i8, i8* %23, i64 1
br i1 %26, label %28, label %22
28: ; preds = %22
%29 = call i64 @strncmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %23, i64 7)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %47
31: ; preds = %28
%32 = getelementptr inbounds i8, i8* %23, i64 7
br label %33
33: ; preds = %33, %31
%34 = phi i8* [ %32, %31 ], [ %38, %33 ]
%35 = load i8, i8* %34
%36 = call i64 @isspace(i8 zeroext %35)
%37 = icmp eq i64 %36, 0
%38 = getelementptr inbounds i8, i8* %34, i64 1
br i1 %37, label %39, label %33
39: ; preds = %33
%40 = load i8, i8* %34
%41 = icmp eq i8 %40, 0
br i1 %41, label %47, label %42
42: ; preds = %39
%43 = call i8* @strrchr(i8* %34, i8 signext 47)
%44 = icmp eq i8* %43, null
br i1 %44, label %47, label %45
45: ; preds = %42
store i8 0, i8* %43
%46 = call i32 @manpath_add(%struct.manpaths* %0, i8* %34)
br label %47
47: ; preds = %45, %28, %39, %42
%48 = call i8* @fgetln(i32* %6, i64* %3)
%49 = icmp eq i8* %48, null
%50 = load i64, i64* %3
%51 = icmp eq i64 %50, 0
%52 = select i1 %49, i1 true, i1 %51
br i1 %52, label %53, label %14
53: ; preds = %47, %14, %8
%54 = call i32 @fclose(i32* %6)
br label %55
55: ; preds = %2, %53
ret void
}