#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 */
struct dirent {
  scalar_t__ d_type;
  char *d_name;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
scalar_t__ DT_REG;
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ *opendir(char *);
struct dirent *readdir(int /*<<< orphan*/ *);
bool checkFile(void) {
  int counter = 0;
  DIR *d;
  struct dirent *dir;
  d = opendir(".");
  if (d) {
    while ((dir = readdir(d)) != NULL) {
      if (dir->d_type == DT_REG) {
        if ((*(dir->d_name) == 'A' || *(dir->d_name) == 'B') &&
            (*(dir->d_name + 1) != '.'))
          counter++;
      }
    }
    closedir(d);
  }
  if (counter == 2)
    return true;
  else
    return false;
}


x86 assembly (clang, -O0):
<checkFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x8(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <opendir@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11e6 <checkFile+0xb6>
jmp    115f <checkFile+0x2f>
mov    -0x10(%rbp),%rdi
call   1050 <readdir@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11dd <checkFile+0xad>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2e5c(%rip),%rcx
cmp    (%rcx),%rax
jne    11d8 <checkFile+0xa8>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x41,%eax
je     11b5 <checkFile+0x85>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x42,%eax
jne    11d3 <checkFile+0xa3>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2e,%eax
je     11d3 <checkFile+0xa3>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11d8 <checkFile+0xa8>
jmp    115f <checkFile+0x2f>
mov    -0x10(%rbp),%rdi
call   1040 <closedir@plt>
cmpl   $0x2,-0x8(%rbp)
jne    11fc <checkFile+0xcc>
movl   $0x1,-0x4(%rbp)
jmp    1203 <checkFile+0xd3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkFile>:
push   %rbp
push   %r14
push   %rbx
lea    0xec5(%rip),%rdi
call   1030 <opendir@plt>
test   %rax,%rax
je     11b6 <checkFile+0x86>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <readdir@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     11a3 <checkFile+0x73>
mov    0x2e81(%rip),%rbp
jmp    117d <checkFile+0x4d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <readdir@plt>
test   %rax,%rax
je     11a3 <checkFile+0x73>
mov    (%rax),%rcx
cmp    0x0(%rbp),%rcx
jne    1170 <checkFile+0x40>
mov    0x8(%rax),%rax
movzbl (%rax),%ecx
add    $0xbf,%cl
cmp    $0x1,%cl
ja     1170 <checkFile+0x40>
xor    %ecx,%ecx
cmpb   $0x2e,0x1(%rax)
setne  %cl
add    %ecx,%r14d
jmp    1170 <checkFile+0x40>
mov    %rbx,%rdi
call   1040 <closedir@plt>
xor    %eax,%eax
cmp    $0x2,%r14d
sete   %al
jmp    11b8 <checkFile+0x88>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i64, i8* }
@.str = [2 x i8] c".\00"
@DT_REG = global i64 0
define i32 @checkFile() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca %struct.dirent*
store i32 0, i32* %2
%5 = call i32* @opendir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %5, i32** %3
%6 = load i32*, i32** %3
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %49
8: ; preds = %0
br label %9
9: ; preds = %45, %8
%10 = load i32*, i32** %3
%11 = call %struct.dirent* @readdir(i32* %10)
store %struct.dirent* %11, %struct.dirent** %4
%12 = icmp ne %struct.dirent* %11, null
br i1 %12, label %13, label %46
13: ; preds = %9
%14 = load %struct.dirent*, %struct.dirent** %4
%15 = getelementptr inbounds %struct.dirent, %struct.dirent* %14, i32 0, i32 0
%16 = load i64, i64* %15
%17 = load i64, i64* @DT_REG
%18 = icmp eq i64 %16, %17
br i1 %18, label %19, label %45
19: ; preds = %13
%20 = load %struct.dirent*, %struct.dirent** %4
%21 = getelementptr inbounds %struct.dirent, %struct.dirent* %20, i32 0, i32 1
%22 = load i8*, i8** %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 65
br i1 %25, label %33, label %26
26: ; preds = %19
%27 = load %struct.dirent*, %struct.dirent** %4
%28 = getelementptr inbounds %struct.dirent, %struct.dirent* %27, i32 0, i32 1
%29 = load i8*, i8** %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 66
br i1 %32, label %33, label %44
33: ; preds = %26, %19
%34 = load %struct.dirent*, %struct.dirent** %4
%35 = getelementptr inbounds %struct.dirent, %struct.dirent* %34, i32 0, i32 1
%36 = load i8*, i8** %35
%37 = getelementptr inbounds i8, i8* %36, i64 1
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 46
br i1 %40, label %41, label %44
41: ; preds = %33
%42 = load i32, i32* %2
%43 = add nsw i32 %42, 1
store i32 %43, i32* %2
br label %44
44: ; preds = %41, %33, %26
br label %45
45: ; preds = %44, %13
br label %9
46: ; preds = %9
%47 = load i32*, i32** %3
%48 = call i32 @closedir(i32* %47)
br label %49
49: ; preds = %46, %0
%50 = load i32, i32* %2
%51 = icmp eq i32 %50, 2
br i1 %51, label %52, label %53
52: ; preds = %49
store i32 1, i32* %1
br label %54
53: ; preds = %49
store i32 0, i32* %1
br label %54
54: ; preds = %53, %52
%55 = load i32, i32* %1
ret i32 %55
}

LLVM IR (-O2):
%struct.dirent = type { i64, i8* }
@.str = [2 x i8] c".\00"
@DT_REG = global i64 0
define i32 @checkFile() {
%1 = tail call i32* @opendir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %34, label %3
3: ; preds = %0
%4 = tail call %struct.dirent* @readdir(i32* %1)
%5 = icmp eq %struct.dirent* %4, null
br i1 %5, label %29, label %6
6: ; preds = %3, %25
%7 = phi %struct.dirent* [ %27, %25 ], [ %4, %3 ]
%8 = phi i32 [ %26, %25 ], [ 0, %3 ]
%9 = getelementptr inbounds %struct.dirent, %struct.dirent* %7, i64 0, i32 0
%10 = load i64, i64* %9
%11 = load i64, i64* @DT_REG
%12 = icmp eq i64 %10, %11
br i1 %12, label %13, label %25
13: ; preds = %6
%14 = getelementptr inbounds %struct.dirent, %struct.dirent* %7, i64 0, i32 1
%15 = load i8*, i8** %14
%16 = load i8, i8* %15
%17 = add i8 %16, -65
%18 = icmp ult i8 %17, 2
br i1 %18, label %19, label %25
19: ; preds = %13
%20 = getelementptr inbounds i8, i8* %15, i64 1
%21 = load i8, i8* %20
%22 = icmp ne i8 %21, 46
%23 = zext i1 %22 to i32
%24 = add nsw i32 %8, %23
br label %25
25: ; preds = %19, %13, %6
%26 = phi i32 [ %8, %6 ], [ %8, %13 ], [ %24, %19 ]
%27 = tail call %struct.dirent* @readdir(i32* %1)
%28 = icmp eq %struct.dirent* %27, null
br i1 %28, label %29, label %6
29: ; preds = %25, %3
%30 = phi i32 [ 0, %3 ], [ %26, %25 ]
%31 = tail call i32 @closedir(i32* %1)
%32 = icmp eq i32 %30, 2
%33 = zext i1 %32 to i32
br label %34
34: ; preds = %29, %0
%35 = phi i32 [ 0, %0 ], [ %33, %29 ]
ret i32 %35
}