#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 EndsWith(char const *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ ILibFileDir_CloseDir(void *);
void *ILibFileDir_GetDirFirstFile(char const *, char *, int,
                                  int /*<<< orphan*/ *);
int ILibFileDir_GetDirNextFile(void *, char const *, char *, int,
                               int /*<<< orphan*/ *);
int ILibFileDir_GetDirEntryCount(const char *fullPath, char *dirDelimiter) {
  char fn[1024];
  void *dirObj;
  int retVal = 0;
  int ewDD;
  int nextFile;
  dirObj = ILibFileDir_GetDirFirstFile(fullPath, fn, 1024, NULL);
  if (dirObj != NULL) {
    ewDD = EndsWith(fullPath, dirDelimiter, 0);
    do {
      retVal++;
      nextFile = ILibFileDir_GetDirNextFile(dirObj, fullPath, fn, 1024, NULL);
    } while (nextFile != 0);
    ILibFileDir_CloseDir(dirObj);
  }
  return retVal;
}


x86 assembly (clang, -O0):
<ILibFileDir_GetDirEntryCount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x41c(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1050 <ILibFileDir_GetDirFirstFile@plt>
mov    %rax,-0x418(%rbp)
cmpq   $0x0,-0x418(%rbp)
je     11ef <ILibFileDir_GetDirEntryCount+0xaf>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1040 <EndsWith@plt>
mov    %eax,-0x420(%rbp)
mov    -0x41c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x41c(%rbp)
mov    -0x418(%rbp),%rdi
mov    -0x8(%rbp),%rsi
lea    -0x410(%rbp),%rdx
mov    $0x400,%ecx
xor    %eax,%eax
mov    %eax,%r8d
call   1030 <ILibFileDir_GetDirNextFile@plt>
mov    %eax,-0x424(%rbp)
cmpl   $0x0,-0x424(%rbp)
jne    11a0 <ILibFileDir_GetDirEntryCount+0x60>
mov    -0x418(%rbp),%rdi
call   1060 <ILibFileDir_CloseDir@plt>
mov    -0x41c(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ILibFileDir_GetDirEntryCount>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%r12
mov    %rdi,%r14
xor    %ebx,%ebx
mov    %rsp,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1050 <ILibFileDir_GetDirFirstFile@plt>
test   %rax,%rax
je     11a5 <ILibFileDir_GetDirEntryCount+0x65>
mov    %rax,%r15
xor    %ebx,%ebx
mov    %r14,%rdi
mov    %r12,%rsi
xor    %edx,%edx
call   1040 <EndsWith@plt>
mov    %rsp,%r12
nop
add    $0x1,%ebx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
mov    $0x400,%ecx
xor    %r8d,%r8d
call   1030 <ILibFileDir_GetDirNextFile@plt>
test   %eax,%eax
jne    1180 <ILibFileDir_GetDirEntryCount+0x40>
mov    %r15,%rdi
call   1060 <ILibFileDir_CloseDir@plt>
mov    %ebx,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @ILibFileDir_GetDirEntryCount(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [1024 x i8]
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %7
%10 = load i8*, i8** %3
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%12 = call i8* @ILibFileDir_GetDirFirstFile(i8* %10, i8* %11, i32 1024, i32* null)
store i8* %12, i8** %6
%13 = load i8*, i8** %6
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %32
15: ; preds = %2
%16 = load i8*, i8** %3
%17 = load i8*, i8** %4
%18 = call i32 @EndsWith(i8* %16, i8* %17, i32 0)
store i32 %18, i32* %8
br label %19
19: ; preds = %26, %15
%20 = load i32, i32* %7
%21 = add nsw i32 %20, 1
store i32 %21, i32* %7
%22 = load i8*, i8** %6
%23 = load i8*, i8** %3
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%25 = call i32 @ILibFileDir_GetDirNextFile(i8* %22, i8* %23, i8* %24, i32 1024, i32* null)
store i32 %25, i32* %9
br label %26
26: ; preds = %19
%27 = load i32, i32* %9
%28 = icmp ne i32 %27, 0
br i1 %28, label %19, label %29
29: ; preds = %26
%30 = load i8*, i8** %6
%31 = call i32 @ILibFileDir_CloseDir(i8* %30)
br label %32
32: ; preds = %29, %2
%33 = load i32, i32* %7
ret i32 %33
}

LLVM IR (-O2):
define i32 @ILibFileDir_GetDirEntryCount(i8* %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = call i8* @ILibFileDir_GetDirFirstFile(i8* %0, i8* %4, i32 1024, i32* null)
%6 = icmp eq i8* %5, null
br i1 %6, label %16, label %7
7: ; preds = %2
%8 = call i32 @EndsWith(i8* %0, i8* %1, i32 0)
br label %9
9: ; preds = %9, %7
%10 = phi i32 [ 0, %7 ], [ %11, %9 ]
%11 = add nuw nsw i32 %10, 1
%12 = call i32 @ILibFileDir_GetDirNextFile(i8* %5, i8* %0, i8* %4, i32 1024, i32* null)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %9
14: ; preds = %9
%15 = call i32 @ILibFileDir_CloseDir(i8* %5)
br label %16
16: ; preds = %14, %2
%17 = phi i32 [ %11, %14 ], [ 0, %2 ]
ret i32 %17
}