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

/* Variables and functions */
char *exchange_with_port(char *, scalar_t__, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
scalar_t__ is_directory(char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int ask_for_dependency(char *path) {
  char buffer[1024], *p;
  int result = 0;
  if (is_directory(path))
    return 1;
  strncpy(buffer, "dep_check\t", sizeof(buffer));
  strncpy(buffer + 10, path, sizeof(buffer) - 10);
  p = exchange_with_port(buffer, strlen(buffer) + 1, 1, 0);
  if (p == (char *)-1 || !p)
    return 0;
  if (*p == '+')
    result = 1;
  free(p);
  return result;
}


x86 assembly (clang, -O0):
<ask_for_dependency>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x41c(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <is_directory@plt>
cmp    $0x0,%rax
je     1188 <ask_for_dependency+0x38>
movl   $0x1,-0x4(%rbp)
jmp    1254 <ask_for_dependency+0x104>
lea    -0x410(%rbp),%rdi
lea    0xe6a(%rip),%rsi
mov    $0x400,%edx
call   1050 <strncpy@plt>
lea    -0x410(%rbp),%rdi
add    $0xa,%rdi
mov    -0x10(%rbp),%rsi
mov    $0x3f6,%edx
call   1050 <strncpy@plt>
lea    -0x410(%rbp),%rax
mov    %rax,-0x428(%rbp)
lea    -0x410(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x428(%rbp),%rdi
mov    %rax,%rsi
add    $0x1,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1030 <exchange_with_port@plt>
mov    %rax,-0x418(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    %rax,-0x418(%rbp)
je     1216 <ask_for_dependency+0xc6>
cmpq   $0x0,-0x418(%rbp)
jne    1222 <ask_for_dependency+0xd2>
movl   $0x0,-0x4(%rbp)
jmp    1254 <ask_for_dependency+0x104>
mov    -0x418(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
jne    123f <ask_for_dependency+0xef>
movl   $0x1,-0x41c(%rbp)
mov    -0x418(%rbp),%rdi
call   1040 <free@plt>
mov    -0x41c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ask_for_dependency>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%r14
call   1070 <is_directory@plt>
mov    $0x1,%ebx
test   %rax,%rax
jne    11ce <ask_for_dependency+0x7e>
lea    0xe8b(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x400,%edx
call   1050 <strncpy@plt>
lea    0xa(%rsp),%rdi
mov    %r14,%rsi
mov    $0x3f6,%edx
call   1050 <strncpy@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%rsi
xor    %ebx,%ebx
mov    %r15,%rdi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1030 <exchange_with_port@plt>
lea    0x1(%rax),%rcx
cmp    $0x2,%rcx
jb     11ce <ask_for_dependency+0x7e>
xor    %ebx,%ebx
cmpb   $0x2b,(%rax)
sete   %bl
mov    %rax,%rdi
call   1040 <free@plt>
mov    %ebx,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"dep_check\09\00"
define i32 @ask_for_dependency(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [1024 x i8]
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %6
%7 = load i8*, i8** %3
%8 = call i64 @is_directory(i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 1, i32* %2
br label %39
11: ; preds = %1
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%13 = call i32 @strncpy(i8* %12, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 1024)
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%15 = getelementptr inbounds i8, i8* %14, i64 10
%16 = load i8*, i8** %3
%17 = call i32 @strncpy(i8* %15, i8* %16, i32 1014)
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%20 = call i64 @strlen(i8* %19)
%21 = add nsw i64 %20, 1
%22 = call i8* @exchange_with_port(i8* %18, i64 %21, i32 1, i32 0)
store i8* %22, i8** %5
%23 = load i8*, i8** %5
%24 = icmp eq i8* %23, inttoptr (i64 -1 to i8*)
br i1 %24, label %28, label %25
25: ; preds = %11
%26 = load i8*, i8** %5
%27 = icmp ne i8* %26, null
br i1 %27, label %29, label %28
28: ; preds = %25, %11
store i32 0, i32* %2
br label %39
29: ; preds = %25
%30 = load i8*, i8** %5
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 43
br i1 %33, label %34, label %35
34: ; preds = %29
store i32 1, i32* %6
br label %35
35: ; preds = %34, %29
%36 = load i8*, i8** %5
%37 = call i32 @free(i8* %36)
%38 = load i32, i32* %6
store i32 %38, i32* %2
br label %39
39: ; preds = %35, %28, %10
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
@.str = [11 x i8] c"dep_check\09\00"
define i32 @ask_for_dependency(i8* %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = tail call i64 @is_directory(i8* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %19
6: ; preds = %1
%7 = call i32 @strncpy(i8* %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 1024)
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 10
%9 = call i32 @strncpy(i8* %8, i8* %0, i32 1014)
%10 = call i64 @strlen(i8* %3)
%11 = add nsw i64 %10, 1
%12 = call i8* @exchange_with_port(i8* %3, i64 %11, i32 1, i32 0)
%13 = ptrtoint i8* %12 to i64
switch i64 %13, label %14 [
i64 -1, label %19
i64 0, label %19
]
14: ; preds = %6
%15 = load i8, i8* %12
%16 = icmp eq i8 %15, 43
%17 = zext i1 %16 to i32
%18 = call i32 @free(i8* %12)
br label %19
19: ; preds = %6, %6, %1, %14
%20 = phi i32 [ %17, %14 ], [ 1, %1 ], [ 0, %6 ], [ 0, %6 ]
ret i32 %20
}