#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 *);
char *path_getdir(char const *);
int prj_find_package(char const *);
char *prj_get_language_for(int);
char *prj_get_target_for(int);
int /*<<< orphan*/ prj_has_libpath(char const *);
const char *filterLinksForPaths(const char *name) {
  int i = prj_find_package(name);
  if (i >= 0) {
    const char *lang = prj_get_language_for(i);
    if (matches(lang, "c++") || matches(lang, "c")) {
      const char *target = prj_get_target_for(i);
      const char *dir = path_getdir(target);
      if (!prj_has_libpath(dir)) {
        return dir;
      }
    }
  }
  return NULL;
}


x86 assembly (clang, -O0):
<filterLinksForPaths>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <prj_find_package@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1204 <filterLinksForPaths+0xa4>
mov    -0x14(%rbp),%edi
call   1040 <prj_get_language_for@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1030 <matches@plt>
cmp    $0x0,%rax
jne    11c2 <filterLinksForPaths+0x62>
mov    -0x20(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1030 <matches@plt>
cmp    $0x0,%rax
je     11ff <filterLinksForPaths+0x9f>
mov    -0x14(%rbp),%edi
call   1050 <prj_get_target_for@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <path_getdir@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1080 <prj_has_libpath@plt>
cmp    $0x0,%eax
jne    11fa <filterLinksForPaths+0x9a>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    120c <filterLinksForPaths+0xac>
jmp    11ff <filterLinksForPaths+0x9f>
jmp    1204 <filterLinksForPaths+0xa4>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filterLinksForPaths>:
push   %r14
push   %rbx
push   %rax
call   1070 <prj_find_package@plt>
test   %eax,%eax
js     11bf <filterLinksForPaths+0x5f>
mov    %eax,%ebx
mov    %eax,%edi
call   1040 <prj_get_language_for@plt>
mov    %rax,%r14
lea    0xe80(%rip),%rsi
mov    %rax,%rdi
call   1030 <matches@plt>
test   %rax,%rax
jne    11a1 <filterLinksForPaths+0x41>
lea    0xe70(%rip),%rsi
mov    %r14,%rdi
call   1030 <matches@plt>
test   %rax,%rax
je     11bf <filterLinksForPaths+0x5f>
mov    %ebx,%edi
call   1050 <prj_get_target_for@plt>
mov    %rax,%rdi
call   1060 <path_getdir@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <prj_has_libpath@plt>
test   %eax,%eax
je     11c1 <filterLinksForPaths+0x61>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"c++\00"
@.str.1 = [2 x i8] c"c\00"
define i8* @filterLinksForPaths(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = call i32 @prj_find_package(i8* %8)
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = icmp sge i32 %10, 0
br i1 %11, label %12, label %34
12: ; preds = %1
%13 = load i32, i32* %4
%14 = call i8* @prj_get_language_for(i32 %13)
store i8* %14, i8** %5
%15 = load i8*, i8** %5
%16 = call i64 @matches(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %12
%19 = load i8*, i8** %5
%20 = call i64 @matches(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %33
22: ; preds = %18, %12
%23 = load i32, i32* %4
%24 = call i8* @prj_get_target_for(i32 %23)
store i8* %24, i8** %6
%25 = load i8*, i8** %6
%26 = call i8* @path_getdir(i8* %25)
store i8* %26, i8** %7
%27 = load i8*, i8** %7
%28 = call i32 @prj_has_libpath(i8* %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %22
%31 = load i8*, i8** %7
store i8* %31, i8** %2
br label %35
32: ; preds = %22
br label %33
33: ; preds = %32, %18
br label %34
34: ; preds = %33, %1
store i8* null, i8** %2
br label %35
35: ; preds = %34, %30
%36 = load i8*, i8** %2
ret i8* %36
}

LLVM IR (-O2):
@.str = [4 x i8] c"c++\00"
@.str.1 = [2 x i8] c"c\00"
define i8* @filterLinksForPaths(i8* %0) {
%2 = tail call i32 @prj_find_package(i8* %0)
%3 = icmp sgt i32 %2, -1
br i1 %3, label %4, label %17
4: ; preds = %1
%5 = tail call i8* @prj_get_language_for(i32 %2)
%6 = tail call i64 @matches(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %4
%9 = tail call i64 @matches(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %8, %4
%12 = tail call i8* @prj_get_target_for(i32 %2)
%13 = tail call i8* @path_getdir(i8* %12)
%14 = tail call i32 @prj_has_libpath(i8* %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %8, %11
br label %17
17: ; preds = %1, %16, %11
%18 = phi i8* [ %13, %11 ], [ null, %16 ], [ null, %1 ]
ret i8* %18
}