#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 st_mode;
};
struct FTW {
  int dummy;
};

/* Variables and functions */
int FTW_DNR;
int S_IFDIR;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ stderr;
int watch_this(char const *);
int walker(const char *pathname, const struct stat *sbuf, int type,
           struct FTW *ftwb) {
  if (sbuf->st_mode & S_IFDIR) {
    return watch_this(pathname);
  } else if (sbuf->st_mode & FTW_DNR) {
    fprintf(stderr, "Can't Read: %s\n", pathname);
    return 0;
  }
}


x86 assembly (clang, -O0):
<walker>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    0x2e84(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1160 <walker+0x40>
mov    -0x10(%rbp),%rdi
call   1030 <watch_this@plt>
mov    %eax,-0x4(%rbp)
jmp    11a2 <walker+0x82>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    0x2e6b(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     119d <walker+0x7d>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe74(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11a2 <walker+0x82>
jmp    11a2 <walker+0x82>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<walker>:
push   %rax
mov    %rdi,%rdx
mov    (%rsi),%eax
mov    0x2e9b(%rip),%rcx
test   %eax,(%rcx)
je     113a <walker+0x1a>
mov    %rdx,%rdi
pop    %rax
jmp    1030 <watch_this@plt>
mov    0x2e97(%rip),%rcx
test   %eax,(%rcx)
je     115a <walker+0x3a>
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
lea    0xeab(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
%struct.FTW = type { i32 }
@S_IFDIR = global i32 0
@FTW_DNR = global i32 0
@stderr = global i32 0
@.str = [16 x i8] c"Can't Read: %s\0A\00"
define i32 @walker(i8* %0, %struct.stat* %1, i32 %2, %struct.FTW* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca %struct.stat*
%8 = alloca i32
%9 = alloca %struct.FTW*
store i8* %0, i8** %6
store %struct.stat* %1, %struct.stat** %7
store i32 %2, i32* %8
store %struct.FTW* %3, %struct.FTW** %9
%10 = load %struct.stat*, %struct.stat** %7
%11 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = load i32, i32* @S_IFDIR
%14 = and i32 %12, %13
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %4
%17 = load i8*, i8** %6
%18 = call i32 @watch_this(i8* %17)
store i32 %18, i32* %5
br label %31
19: ; preds = %4
%20 = load %struct.stat*, %struct.stat** %7
%21 = getelementptr inbounds %struct.stat, %struct.stat* %20, i32 0, i32 0
%22 = load i32, i32* %21
%23 = load i32, i32* @FTW_DNR
%24 = and i32 %22, %23
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %19
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %6
%29 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %28)
store i32 0, i32* %5
br label %31
30: ; preds = %19
br label %31
31: ; preds = %16, %26, %30
%32 = load i32, i32* %5
ret i32 %32
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.FTW = type { i32 }
@S_IFDIR = global i32 0
@FTW_DNR = global i32 0
@stderr = global i32 0
@.str = [16 x i8] c"Can't Read: %s\0A\00"
define i32 @walker(i8* %0, %struct.stat* nocapture %1, i32 %2, %struct.FTW* nocapture readnone %3) {
%5 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%6 = load i32, i32* %5
%7 = load i32, i32* @S_IFDIR
%8 = and i32 %7, %6
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %4
%11 = tail call i32 @watch_this(i8* %0)
br label %19
12: ; preds = %4
%13 = load i32, i32* @FTW_DNR
%14 = and i32 %13, %6
%15 = icmp eq i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %19
19: ; preds = %12, %10, %16
%20 = phi i32 [ %11, %10 ], [ 0, %16 ], [ undef, %12 ]
ret i32 %20
}