#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 */
int /*<<< orphan*/ io_print(char *, char const *);
scalar_t__ matches(int /*<<< orphan*/, char const *);
int prj_get_numpackages();
char *prj_get_pkgfilename_for(int, char *);
int /*<<< orphan*/ prj_get_pkgname_for(int);
scalar_t__ startsWith(char const *, char *);
const char *printProjectDependencies(const char *name) {
  int i;
  for (i = 0; i < prj_get_numpackages(); ++i) {
    if (matches(prj_get_pkgname_for(i), name)) {
      const char *filename = prj_get_pkgfilename_for(i, "cbp");
      if (startsWith(filename, "./"))
        filename += 2;
      io_print("\t\t\t<Depends filename=\"%s\" />\n", filename);
    }
  }
  return NULL;
}


x86 assembly (clang, -O0):
<printProjectDependencies>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1070 <prj_get_numpackages@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    1206 <printProjectDependencies+0xa6>
mov    -0xc(%rbp),%edi
call   1060 <prj_get_pkgname_for@plt>
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
call   1040 <matches@plt>
cmp    $0x0,%rax
je     11f3 <printProjectDependencies+0x93>
mov    -0xc(%rbp),%edi
lea    0xe4c(%rip),%rsi
call   1080 <prj_get_pkgfilename_for@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe3c(%rip),%rsi
call   1030 <startsWith@plt>
cmp    $0x0,%rax
je     11e3 <printProjectDependencies+0x83>
mov    -0x18(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe19(%rip),%rdi
call   1050 <io_print@plt>
jmp    11f8 <printProjectDependencies+0x98>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1173 <printProjectDependencies+0x13>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printProjectDependencies>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r13
xor    %eax,%eax
call   1070 <prj_get_numpackages@plt>
test   %eax,%eax
jle    11f2 <printProjectDependencies+0x92>
lea    0xe80(%rip),%r14
lea    0xe7d(%rip),%r15
lea    0xe79(%rip),%r12
xor    %ebp,%ebp
jmp    11ae <printProjectDependencies+0x4e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebp
xor    %eax,%eax
call   1070 <prj_get_numpackages@plt>
cmp    %eax,%ebp
jge    11f2 <printProjectDependencies+0x92>
mov    %ebp,%edi
call   1060 <prj_get_pkgname_for@plt>
mov    %eax,%edi
mov    %r13,%rsi
call   1040 <matches@plt>
test   %rax,%rax
je     11a0 <printProjectDependencies+0x40>
mov    %ebp,%edi
mov    %r14,%rsi
call   1080 <prj_get_pkgfilename_for@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   1030 <startsWith@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    (%rbx,%rcx,2),%rsi
mov    %r12,%rdi
call   1050 <io_print@plt>
jmp    11a0 <printProjectDependencies+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"cbp\00"
@.str.1 = [3 x i8] c"./\00"
@.str.2 = [30 x i8] c"\09\09\09<Depends filename=\22%s\22 />\0A\00"
define i8* @printProjectDependencies(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
store i32 0, i32* %3
br label %5
5: ; preds = %28, %1
%6 = load i32, i32* %3
%7 = call i32 (...) @prj_get_numpackages()
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %31
9: ; preds = %5
%10 = load i32, i32* %3
%11 = call i32 @prj_get_pkgname_for(i32 %10)
%12 = load i8*, i8** %2
%13 = call i64 @matches(i32 %11, i8* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %27
15: ; preds = %9
%16 = load i32, i32* %3
%17 = call i8* @prj_get_pkgfilename_for(i32 %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %17, i8** %4
%18 = load i8*, i8** %4
%19 = call i64 @startsWith(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i64 2
store i8* %23, i8** %4
br label %24
24: ; preds = %21, %15
%25 = load i8*, i8** %4
%26 = call i32 @io_print(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %24, %9
br label %28
28: ; preds = %27
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %5
31: ; preds = %5
ret i8* null
}

LLVM IR (-O2):
@.str = [4 x i8] c"cbp\00"
@.str.1 = [3 x i8] c"./\00"
@.str.2 = [30 x i8] c"\09\09\09<Depends filename=\22%s\22 />\0A\00"
define noalias i8* @printProjectDependencies(i8* %0) {
%2 = tail call i32 (...) @prj_get_numpackages()
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %20
4: ; preds = %1, %16
%5 = phi i32 [ %17, %16 ], [ 0, %1 ]
%6 = tail call i32 @prj_get_pkgname_for(i32 %5)
%7 = tail call i64 @matches(i32 %6, i8* %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %4
%10 = tail call i8* @prj_get_pkgfilename_for(i32 %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%11 = tail call i64 @startsWith(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i64 0, i64 2
%14 = getelementptr i8, i8* %10, i64 %13
%15 = tail call i32 @io_print(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %4, %9
%17 = add nuw nsw i32 %5, 1
%18 = tail call i32 (...) @prj_get_numpackages()
%19 = icmp slt i32 %17, %18
br i1 %19, label %4, label %20
20: ; preds = %16, %1
ret i8* null
}