#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 stat {
  int /*<<< orphan*/ st_mode;
};

/* Variables and functions */
scalar_t__ S_ISDIR(int /*<<< orphan*/);
scalar_t__ has_child_dir(char const *, char *);
int filter_is_maildir(const char *path, const struct stat *sb) {
  if (S_ISDIR(sb->st_mode)) {
    if (has_child_dir(path, "new") && has_child_dir(path, "tmp") &&
        has_child_dir(path, "cur")) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<filter_is_maildir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   1030 <S_ISDIR@plt>
cmp    $0x0,%rax
je     11a4 <filter_is_maildir+0x84>
mov    -0x10(%rbp),%rdi
lea    0xeb0(%rip),%rsi
call   1040 <has_child_dir@plt>
cmp    $0x0,%rax
je     119f <filter_is_maildir+0x7f>
mov    -0x10(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1040 <has_child_dir@plt>
cmp    $0x0,%rax
je     119f <filter_is_maildir+0x7f>
mov    -0x10(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1040 <has_child_dir@plt>
cmp    $0x0,%rax
je     119f <filter_is_maildir+0x7f>
movl   $0x1,-0x4(%rbp)
jmp    11ab <filter_is_maildir+0x8b>
jmp    11a4 <filter_is_maildir+0x84>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filter_is_maildir>:
push   %rbx
mov    %rdi,%rbx
mov    (%rsi),%edi
call   1030 <S_ISDIR@plt>
test   %rax,%rax
je     1176 <filter_is_maildir+0x56>
lea    0xec9(%rip),%rsi
mov    %rbx,%rdi
call   1040 <has_child_dir@plt>
test   %rax,%rax
je     1176 <filter_is_maildir+0x56>
lea    0xeb9(%rip),%rsi
mov    %rbx,%rdi
call   1040 <has_child_dir@plt>
test   %rax,%rax
je     1176 <filter_is_maildir+0x56>
lea    0xea9(%rip),%rsi
mov    %rbx,%rdi
call   1040 <has_child_dir@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
je     1176 <filter_is_maildir+0x56>
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [4 x i8] c"new\00"
@.str.1 = [4 x i8] c"tmp\00"
@.str.2 = [4 x i8] c"cur\00"
define i32 @filter_is_maildir(i8* %0, %struct.stat* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.stat*
store i8* %0, i8** %4
store %struct.stat* %1, %struct.stat** %5
%6 = load %struct.stat*, %struct.stat** %5
%7 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%8 = load i32, i32* %7
%9 = call i64 @S_ISDIR(i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %25
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = call i64 @has_child_dir(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %11
%16 = load i8*, i8** %4
%17 = call i64 @has_child_dir(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = load i8*, i8** %4
%21 = call i64 @has_child_dir(i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19
store i32 1, i32* %3
br label %26
24: ; preds = %19, %15, %11
br label %25
25: ; preds = %24, %2
store i32 0, i32* %3
br label %26
26: ; preds = %25, %23
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [4 x i8] c"new\00"
@.str.1 = [4 x i8] c"tmp\00"
@.str.2 = [4 x i8] c"cur\00"
define i32 @filter_is_maildir(i8* %0, %struct.stat* nocapture %1) {
%3 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%4 = load i32, i32* %3
%5 = tail call i64 @S_ISDIR(i32 %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %16, label %7
7: ; preds = %2
%8 = tail call i64 @has_child_dir(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %7
%11 = tail call i64 @has_child_dir(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = tail call i64 @has_child_dir(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %7, %10, %13, %2
br label %17
17: ; preds = %13, %16
%18 = phi i32 [ 0, %16 ], [ 1, %13 ]
ret i32 %18
}