#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;
  int /*<<< orphan*/ st_ctime;
  int /*<<< orphan*/ st_size;
};

/* Variables and functions */
int S_IFDIR;
int S_IFMT;
int /*<<< orphan*/ ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ dirwalk(char *, void (*)(char *));
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/, char *,
                          int /*<<< orphan*/);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
void fsize(char *filename) {
  struct stat stbuf;
  if (stat(filename, &stbuf) == -1) {
    fprintf(stderr, "fsize: cannot access %s\n", filename);
    return;
  }
  if ((stbuf.st_mode & S_IFMT) == S_IFDIR) {
    dirwalk(filename, fsize);
  }
  printf("%8ld %s last changed on %s", stbuf.st_size, filename,
         ctime(&stbuf.st_ctime));
}


x86 assembly (clang, -O0):
<fsize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0xffffffff,%eax
jne    1190 <fsize+0x40>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe7a(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11eb <fsize+0x9b>
mov    -0x18(%rbp),%eax
mov    0x2e3e(%rip),%rcx
and    (%rcx),%eax
mov    0x2e1d(%rip),%rcx
cmp    (%rcx),%eax
jne    11bb <fsize+0x6b>
mov    -0x8(%rbp),%rdi
mov    0x2e32(%rip),%rsi
call   1070 <dirwalk@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x18(%rbp),%rdi
add    $0x4,%rdi
call   1030 <ctime@plt>
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    %eax,%ecx
lea    0xe33(%rip),%rdi
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fsize>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
call   1060 <stat@plt>
cmp    $0xffffffff,%eax
je     11b7 <fsize+0x67>
mov    0x2e69(%rip),%rax
mov    (%rax),%eax
and    0x8(%rsp),%eax
mov    0x2e44(%rip),%rcx
cmp    (%rcx),%eax
jne    118f <fsize+0x3f>
mov    0x2e61(%rip),%rsi
mov    %rbx,%rdi
call   1070 <dirwalk@plt>
mov    0x10(%rsp),%ebp
lea    0xc(%rsp),%rdi
call   1030 <ctime@plt>
lea    0xe75(%rip),%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1040 <printf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
lea    0xe39(%rip),%rsi
mov    %rbx,%rdx
add    $0x18,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <fprintf@plt>

LLVM IR (-O0):
%struct.stat = type { i32, i32, i32 }
@stderr = global i32 0
@.str = [25 x i8] c"fsize: cannot access %s\0A\00"
@S_IFMT = global i32 0
@S_IFDIR = global i32 0
@.str.1 = [27 x i8] c"%8ld %s last changed on %s\00"
define void @fsize(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 ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %28
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 @dirwalk(i8* %19, void (i8*)* @fsize)
br label %21
21: ; preds = %18, %11
%22 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 2
%23 = load i32, i32* %22
%24 = load i8*, i8** %2
%25 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 1
%26 = call i32 @ctime(i32* %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %23, i8* %24, i32 %26)
br label %28
28: ; preds = %21, %7
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32 }
@stderr = global i32 0
@.str = [25 x i8] c"fsize: cannot access %s\0A\00"
@S_IFMT = global i32 0
@S_IFDIR = global i32 0
@.str.1 = [27 x i8] c"%8ld %s last changed on %s\00"
define void @fsize(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 ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %24
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 @dirwalk(i8* %0, void (i8*)* @fsize)
br label %18
18: ; preds = %16, %9
%19 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 2
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 1
%22 = call i32 @ctime(i32* %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %20, i8* %0, i32 %22)
br label %24
24: ; preds = %18, %6
ret void
}