#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;
};

/* Variables and functions */
int S_IFDIR;
int S_IFMT;
int /*<<< orphan*/ dir_walk(char *, void (*)(char *));
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
void start_walk(char *name) {
  struct stat stbuf;
  if (stat(name, &stbuf) == -1) {
    fprintf(stderr, "fsize: can't access %s\n", name);
    return;
  }
  if ((stbuf.st_mode & S_IFMT) == S_IFDIR) {
    dir_walk(name, start_walk);
  }
}


x86 assembly (clang, -O0):
<start_walk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0xffffffff,%eax
jne    1170 <start_walk+0x40>
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe9a(%rip),%rsi
call   1040 <fprintf@plt>
jmp    119b <start_walk+0x6b>
mov    -0x10(%rbp),%eax
mov    0x2e66(%rip),%rcx
and    (%rcx),%eax
mov    0x2e3d(%rip),%rcx
cmp    (%rcx),%eax
jne    119b <start_walk+0x6b>
mov    -0x8(%rbp),%rdi
mov    0x2e3a(%rip),%rsi
call   1030 <dir_walk@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_walk>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
call   1050 <stat@plt>
cmp    $0xffffffff,%eax
je     1173 <start_walk+0x43>
mov    0x2e92(%rip),%rax
mov    (%rax),%eax
and    0x8(%rsp),%eax
mov    0x2e65(%rip),%rcx
cmp    (%rcx),%eax
jne    1190 <start_walk+0x60>
mov    0x2e6a(%rip),%rsi
mov    %rbx,%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1030 <dir_walk@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0xe7d(%rip),%rsi
mov    %rbx,%rdx
add    $0x10,%rsp
pop    %rbx
jmp    1040 <fprintf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [24 x i8] c"fsize: can't access %s\0A\00"
@S_IFMT = global i32 0
@S_IFDIR = global i32 0
define void @start_walk(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.stat
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @stat(i8* %4, %struct.stat* %3)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %2
%10 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %21
11: ; preds = %1
%12 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%13 = load i32, i32* %12
%14 = load i32, i32* @S_IFMT
%15 = and i32 %13, %14
%16 = load i32, i32* @S_IFDIR
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %21
18: ; preds = %11
%19 = load i8*, i8** %2
%20 = call i32 @dir_walk(i8* %19, void (i8*)* @start_walk)
br label %21
21: ; preds = %7, %18, %11
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [24 x i8] c"fsize: can't access %s\0A\00"
@S_IFMT = global i32 0
@S_IFDIR = global i32 0
define void @start_walk(i8* %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
%4 = call i32 @stat(i8* %0, %struct.stat* %2)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %18
9: ; preds = %1
%10 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%11 = load i32, i32* %10
%12 = load i32, i32* @S_IFMT
%13 = and i32 %12, %11
%14 = load i32, i32* @S_IFDIR
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %18
16: ; preds = %9
%17 = tail call i32 @dir_walk(i8* %0, void (i8*)* @start_walk)
br label %18
18: ; preds = %9, %16, %6
ret void
}