#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 */
scalar_t__ matches(char const *, char const *);
char const *prj_get_bindir();
char const *prj_get_libdir();
char **prj_get_libpaths();
scalar_t__ strlen(char const *);
int prj_has_libpath(const char *path) {
  const char **libpath;
  if (path == NULL || strlen(path) == 0)
    return 1;
  libpath = prj_get_libpaths();
  while (*libpath) {
    if (matches(*libpath, path))
      return 1;
    libpath++;
  }
  if (matches(prj_get_libdir(), path))
    return 1;
  if (matches(prj_get_bindir(), path))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<prj_has_libpath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     117a <prj_has_libpath+0x2a>
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x0,%rax
jne    1186 <prj_has_libpath+0x36>
movl   $0x1,-0x4(%rbp)
jmp    122f <prj_has_libpath+0xdf>
mov    $0x0,%al
call   1070 <prj_get_libpaths@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     11d6 <prj_has_libpath+0x86>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <matches@plt>
cmp    $0x0,%rax
je     11c5 <prj_has_libpath+0x75>
movl   $0x1,-0x4(%rbp)
jmp    122f <prj_has_libpath+0xdf>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    1191 <prj_has_libpath+0x41>
mov    $0x0,%al
call   1040 <prj_get_libdir@plt>
mov    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1050 <matches@plt>
cmp    $0x0,%rax
je     11ff <prj_has_libpath+0xaf>
movl   $0x1,-0x4(%rbp)
jmp    122f <prj_has_libpath+0xdf>
mov    $0x0,%al
call   1030 <prj_get_bindir@plt>
mov    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1050 <matches@plt>
cmp    $0x0,%rax
je     1228 <prj_has_libpath+0xd8>
movl   $0x1,-0x4(%rbp)
jmp    122f <prj_has_libpath+0xdf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prj_has_libpath>:
push   %rbp
push   %r14
push   %rbx
mov    $0x1,%r14d
test   %rdi,%rdi
je     11bd <prj_has_libpath+0x7d>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     11bd <prj_has_libpath+0x7d>
xor    %eax,%eax
call   1060 <prj_get_libpaths@plt>
mov    (%rax),%rdi
test   %rdi,%rdi
je     118a <prj_has_libpath+0x4a>
mov    %rax,%rbp
add    $0x8,%rbp
nopl   (%rax)
mov    %rbx,%rsi
call   1050 <matches@plt>
test   %rax,%rax
jne    11bd <prj_has_libpath+0x7d>
mov    0x0(%rbp),%rdi
add    $0x8,%rbp
test   %rdi,%rdi
jne    1170 <prj_has_libpath+0x30>
xor    %eax,%eax
call   1040 <prj_get_libdir@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1050 <matches@plt>
test   %rax,%rax
jne    11bd <prj_has_libpath+0x7d>
xor    %eax,%eax
call   1030 <prj_get_bindir@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1050 <matches@plt>
xor    %r14d,%r14d
test   %rax,%rax
setne  %r14b
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @prj_has_libpath(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8**
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp eq i8* %5, null
br i1 %6, label %11, label %7
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i64 @strlen(i8* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7, %1
store i32 1, i32* %2
br label %41
12: ; preds = %7
%13 = call i8** (...) @prj_get_libpaths()
store i8** %13, i8*** %4
br label %14
14: ; preds = %25, %12
%15 = load i8**, i8*** %4
%16 = load i8*, i8** %15
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %28
18: ; preds = %14
%19 = load i8**, i8*** %4
%20 = load i8*, i8** %19
%21 = load i8*, i8** %3
%22 = call i64 @matches(i8* %20, i8* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %18
store i32 1, i32* %2
br label %41
25: ; preds = %18
%26 = load i8**, i8*** %4
%27 = getelementptr inbounds i8*, i8** %26, i32 1
store i8** %27, i8*** %4
br label %14
28: ; preds = %14
%29 = call i8* (...) @prj_get_libdir()
%30 = load i8*, i8** %3
%31 = call i64 @matches(i8* %29, i8* %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %28
store i32 1, i32* %2
br label %41
34: ; preds = %28
%35 = call i8* (...) @prj_get_bindir()
%36 = load i8*, i8** %3
%37 = call i64 @matches(i8* %35, i8* %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %34
store i32 1, i32* %2
br label %41
40: ; preds = %34
store i32 0, i32* %2
br label %41
41: ; preds = %40, %39, %33, %24, %11
%42 = load i32, i32* %2
ret i32 %42
}

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