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

/* Variables and functions */
int /*<<< orphan*/ S_ISREG(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, char *);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int ignore_maildir_entry(const char *dir, const struct dirent *entry) {
  char fname[(2048)];
  struct stat filestat;
  if (entry->d_name[0] == '.')
    return 1;
  snprintf(fname, sizeof(fname), "%s/%s", dir, entry->d_name);
  fname[sizeof(fname) - 1] = '\0';
  if (stat(fname, &filestat) != 0) {
    fprintf(stderr, "mailcheck: failed to stat file: %s\n", fname);
    return 1;
  }
  if (!S_ISREG(filestat.st_mode))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<ignore_maildir_entry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1172 <ignore_maildir_entry+0x32>
movl   $0x1,-0x4(%rbp)
jmp    1205 <ignore_maildir_entry+0xc5>
lea    -0x820(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    (%rax),%r8
mov    $0x800,%esi
lea    0xe70(%rip),%rdx
call   1030 <snprintf@plt>
movb   $0x0,-0x21(%rbp)
lea    -0x820(%rbp),%rdi
lea    -0x828(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
je     11de <ignore_maildir_entry+0x9e>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
lea    -0x820(%rbp),%rdx
lea    0xe39(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1205 <ignore_maildir_entry+0xc5>
mov    -0x828(%rbp),%edi
call   1060 <S_ISREG@plt>
cmp    $0x0,%eax
jne    11fe <ignore_maildir_entry+0xbe>
movl   $0x1,-0x4(%rbp)
jmp    1205 <ignore_maildir_entry+0xc5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ignore_maildir_entry>:
push   %r14
push   %rbx
sub    $0x818,%rsp
mov    (%rsi),%r8
mov    $0x1,%ebx
cmpb   $0x2e,(%r8)
je     11ba <ignore_maildir_entry+0x7a>
mov    %rdi,%rcx
lea    0xe9e(%rip),%rdx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x800,%esi
call   1030 <snprintf@plt>
movb   $0x0,0x80f(%rsp)
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1050 <stat@plt>
test   %rax,%rax
je     11aa <ignore_maildir_entry+0x6a>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
lea    0xe68(%rip),%rsi
lea    0x10(%rsp),%rdx
call   1040 <fprintf@plt>
jmp    11ba <ignore_maildir_entry+0x7a>
mov    0x8(%rsp),%edi
call   1060 <S_ISREG@plt>
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
mov    %ebx,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.dirent = type { i8* }
%struct.stat = type { i32 }
@.str = [6 x i8] c"%s/%s\00"
@stderr = global i32 0
@.str.1 = [36 x i8] c"mailcheck: failed to stat file: %s\0A\00"
define i32 @ignore_maildir_entry(i8* %0, %struct.dirent* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.dirent*
%6 = alloca [2048 x i8]
%7 = alloca %struct.stat
store i8* %0, i8** %4
store %struct.dirent* %1, %struct.dirent** %5
%8 = load %struct.dirent*, %struct.dirent** %5
%9 = getelementptr inbounds %struct.dirent, %struct.dirent* %8, i32 0, i32 0
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 46
br i1 %14, label %15, label %16
15: ; preds = %2
store i32 1, i32* %3
br label %38
16: ; preds = %2
%17 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%18 = load i8*, i8** %4
%19 = load %struct.dirent*, %struct.dirent** %5
%20 = getelementptr inbounds %struct.dirent, %struct.dirent* %19, i32 0, i32 0
%21 = load i8*, i8** %20
%22 = call i32 @snprintf(i8* %17, i32 2048, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %18, i8* %21)
%23 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 2047
store i8 0, i8* %23
%24 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%25 = call i64 @stat(i8* %24, %struct.stat* %7)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %16
%28 = load i32, i32* @stderr
%29 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%30 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %29)
store i32 1, i32* %3
br label %38
31: ; preds = %16
%32 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%33 = load i32, i32* %32
%34 = call i32 @S_ISREG(i32 %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %37, label %36
36: ; preds = %31
store i32 1, i32* %3
br label %38
37: ; preds = %31
store i32 0, i32* %3
br label %38
38: ; preds = %37, %36, %27, %15
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
%struct.stat = type { i32 }
@.str = [6 x i8] c"%s/%s\00"
@stderr = global i32 0
@.str.1 = [36 x i8] c"mailcheck: failed to stat file: %s\0A\00"
define i32 @ignore_maildir_entry(i8* %0, %struct.dirent* nocapture %1) {
%3 = alloca [2048 x i8]
%4 = alloca %struct.stat
%5 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%6 = bitcast %struct.stat* %4 to i8*
%7 = getelementptr inbounds %struct.dirent, %struct.dirent* %1, i64 0, i32 0
%8 = load i8*, i8** %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 46
br i1 %10, label %25, label %11
11: ; preds = %2
%12 = call i32 @snprintf(i8* %5, i32 2048, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %8)
%13 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 2047
store i8 0, i8* %13
%14 = call i64 @stat(i8* %5, %struct.stat* %4)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %5)
br label %25
19: ; preds = %11
%20 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%21 = load i32, i32* %20
%22 = call i32 @S_ISREG(i32 %21)
%23 = icmp eq i32 %22, 0
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %19, %2, %16
%26 = phi i32 [ 1, %16 ], [ 1, %2 ], [ %24, %19 ]
ret i32 %26
}