#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*/ FREE(char *);
scalar_t__ MALLOC(int);
int PCGetFileDirType(char *);
int /*<<< orphan*/ memcpy(char *, char const *, int);
scalar_t__ strcmp(char const *, char *);
scalar_t__ strlen(char const *);
int ProceedWithDirEntry(const char *dirName, const char *filename,
                        int maxPathLength) {
  int dirLen;
  int fnLen;
  int val;
  char *fullpath;
  dirLen = (int)strlen(dirName);
  fnLen = (int)strlen(filename);
  if ((strcmp(filename, ".") == 0) || (strcmp(filename, "..") == 0)) {
    return 0;
  }
  if ((dirLen + fnLen + 2) > maxPathLength) {
    return 0;
  }
  fullpath = (char *)MALLOC(maxPathLength);
  memcpy(fullpath, dirName, dirLen);
  memcpy(fullpath + dirLen, filename, fnLen);
  fullpath[dirLen + fnLen] = '\0';
  val = PCGetFileDirType(fullpath);
  FREE(fullpath);
  if (val == 0) {
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<ProceedWithDirEntry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe6b(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11bf <ProceedWithDirEntry+0x5f>
mov    -0x18(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11cb <ProceedWithDirEntry+0x6b>
movl   $0x0,-0x4(%rbp)
jmp    125f <ProceedWithDirEntry+0xff>
mov    -0x20(%rbp),%eax
add    -0x24(%rbp),%eax
add    $0x2,%eax
cmp    -0x1c(%rbp),%eax
jle    11e9 <ProceedWithDirEntry+0x89>
movl   $0x0,-0x4(%rbp)
jmp    125f <ProceedWithDirEntry+0xff>
mov    -0x1c(%rbp),%edi
call   1080 <MALLOC@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1060 <memcpy@plt>
mov    -0x30(%rbp),%rdi
movslq -0x20(%rbp),%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1060 <memcpy@plt>
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    -0x24(%rbp),%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x30(%rbp),%rdi
call   1040 <PCGetFileDirType@plt>
mov    %eax,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
call   1070 <FREE@plt>
cmpl   $0x0,-0x28(%rbp)
jne    1258 <ProceedWithDirEntry+0xf8>
movl   $0x0,-0x4(%rbp)
jmp    125f <ProceedWithDirEntry+0xff>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ProceedWithDirEntry>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r13d
mov    %rsi,%rbx
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rax,%r14
lea    0xe73(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1213 <ProceedWithDirEntry+0xb3>
lea    0xe5c(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1213 <ProceedWithDirEntry+0xb3>
lea    (%r14,%r12,1),%eax
add    $0x2,%eax
cmp    %r13d,%eax
jg     1213 <ProceedWithDirEntry+0xb3>
lea    (%r14,%r12,1),%eax
mov    %eax,0x4(%rsp)
mov    %r13d,%edi
call   1080 <MALLOC@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r15,%rsi
mov    %r12d,%edx
call   1060 <memcpy@plt>
movslq %r12d,%rdi
add    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1060 <memcpy@plt>
movslq 0x4(%rsp),%rax
movb   $0x0,0x0(%rbp,%rax,1)
mov    %rbp,%rdi
call   1040 <PCGetFileDirType@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1070 <FREE@plt>
xor    %ebp,%ebp
test   %ebx,%ebx
setne  %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
@.str.1 = [3 x i8] c"..\00"
define i32 @ProceedWithDirEntry(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%12 = load i8*, i8** %5
%13 = call i64 @strlen(i8* %12)
%14 = trunc i64 %13 to i32
store i32 %14, i32* %8
%15 = load i8*, i8** %6
%16 = call i64 @strlen(i8* %15)
%17 = trunc i64 %16 to i32
store i32 %17, i32* %9
%18 = load i8*, i8** %6
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %3
%22 = load i8*, i8** %6
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %21, %3
store i32 0, i32* %4
br label %63
26: ; preds = %21
%27 = load i32, i32* %8
%28 = load i32, i32* %9
%29 = add nsw i32 %27, %28
%30 = add nsw i32 %29, 2
%31 = load i32, i32* %7
%32 = icmp sgt i32 %30, %31
br i1 %32, label %33, label %34
33: ; preds = %26
store i32 0, i32* %4
br label %63
34: ; preds = %26
%35 = load i32, i32* %7
%36 = call i64 @MALLOC(i32 %35)
%37 = inttoptr i64 %36 to i8*
store i8* %37, i8** %11
%38 = load i8*, i8** %11
%39 = load i8*, i8** %5
%40 = load i32, i32* %8
%41 = call i32 @memcpy(i8* %38, i8* %39, i32 %40)
%42 = load i8*, i8** %11
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = load i8*, i8** %6
%47 = load i32, i32* %9
%48 = call i32 @memcpy(i8* %45, i8* %46, i32 %47)
%49 = load i8*, i8** %11
%50 = load i32, i32* %8
%51 = load i32, i32* %9
%52 = add nsw i32 %50, %51
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %49, i64 %53
store i8 0, i8* %54
%55 = load i8*, i8** %11
%56 = call i32 @PCGetFileDirType(i8* %55)
store i32 %56, i32* %10
%57 = load i8*, i8** %11
%58 = call i32 @FREE(i8* %57)
%59 = load i32, i32* %10
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %34
store i32 0, i32* %4
br label %63
62: ; preds = %34
store i32 1, i32* %4
br label %63
63: ; preds = %62, %61, %33, %25
%64 = load i32, i32* %4
ret i32 %64
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
@.str.1 = [3 x i8] c"..\00"
define i32 @ProceedWithDirEntry(i8* %0, i8* %1, i32 %2) {
%4 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%5 = trunc i64 %4 to i32
%6 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%7 = trunc i64 %6 to i32
%8 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %31, label %10
10: ; preds = %3
%11 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %31, label %13
13: ; preds = %10
%14 = add nsw i32 %7, %5
%15 = add nsw i32 %14, 2
%16 = icmp sgt i32 %15, %2
br i1 %16, label %31, label %17
17: ; preds = %13
%18 = tail call i64 @MALLOC(i32 %2)
%19 = inttoptr i64 %18 to i8*
%20 = tail call i32 @memcpy(i8* %19, i8* %0, i32 %5)
%21 = shl i64 %4, 32
%22 = ashr exact i64 %21, 32
%23 = getelementptr inbounds i8, i8* %19, i64 %22
%24 = tail call i32 @memcpy(i8* %23, i8* %1, i32 %7)
%25 = sext i32 %14 to i64
%26 = getelementptr inbounds i8, i8* %19, i64 %25
store i8 0, i8* %26
%27 = tail call i32 @PCGetFileDirType(i8* %19)
%28 = tail call i32 @FREE(i8* %19)
%29 = icmp ne i32 %27, 0
%30 = zext i1 %29 to i32
br label %31
31: ; preds = %17, %13, %3, %10
%32 = phi i32 [ 0, %10 ], [ 0, %3 ], [ 0, %13 ], [ %30, %17 ]
ret i32 %32
}