#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;
  scalar_t__ st_gid;
  scalar_t__ st_uid;
  scalar_t__ st_nlink;
  scalar_t__ st_ino;
  scalar_t__ st_size;
};

/* Variables and functions */
int S_IFDIR;
int S_IFMT;
int /*<<< orphan*/ dirwalk(char *, void (*)(char *));
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, long, char *, long, short, short, short);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
void fsize(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)
    dirwalk(name, fsize);
  printf("%8ld %s [Inode: %ld Links: %hd UID: %hd GID: %hd]\n",
         (long)stbuf.st_size, name, (long)stbuf.st_ino, (short)stbuf.st_nlink,
         (short)stbuf.st_uid, (short)stbuf.st_gid);
}


x86 assembly (clang, -O0):
<fsize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0xffffffff,%eax
jne    1180 <fsize+0x40>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe8a(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11e3 <fsize+0xa3>
mov    -0x38(%rbp),%eax
mov    0x2e4e(%rip),%rcx
and    (%rcx),%eax
mov    0x2e2d(%rip),%rcx
cmp    (%rcx),%eax
jne    11ab <fsize+0x6b>
mov    -0x8(%rbp),%rdi
mov    0x2e42(%rip),%rsi
call   1060 <dirwalk@plt>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %ax,%r8w
mov    -0x28(%rbp),%rax
mov    %ax,%r9w
mov    -0x30(%rbp),%rax
lea    0xe46(%rip),%rdi
movswl %r8w,%r8d
movswl %r9w,%r9d
cwtl
mov    %eax,(%rsp)
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fsize>:
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%rbx
lea    0x10(%rsp),%rsi
call   1050 <stat@plt>
cmp    $0xffffffff,%eax
je     11b1 <fsize+0x71>
mov    0x2e7a(%rip),%rax
mov    (%rax),%eax
and    0x10(%rsp),%eax
mov    0x2e55(%rip),%rcx
cmp    (%rcx),%eax
jne    117e <fsize+0x3e>
mov    0x2e72(%rip),%rsi
mov    %rbx,%rdi
call   1060 <dirwalk@plt>
mov    0x30(%rsp),%rcx
mov    0x38(%rsp),%rsi
movswl 0x28(%rsp),%r8d
movswl 0x20(%rsp),%r9d
movswl 0x18(%rsp),%eax
mov    %eax,(%rsp)
lea    0xe75(%rip),%rdi
mov    %rbx,%rdx
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbx
ret
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
lea    0xe3f(%rip),%rsi
mov    %rbx,%rdx
add    $0x40,%rsp
pop    %rbx
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
%struct.stat = type { i32, i64, i64, i64, i64, i64 }
@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
@.str.1 = [51 x i8] c"%8ld %s [Inode: %ld Links: %hd UID: %hd GID: %hd]\0A\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 ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %37
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 5
%23 = load i64, i64* %22
%24 = load i8*, i8** %2
%25 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 4
%26 = load i64, i64* %25
%27 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 3
%28 = load i64, i64* %27
%29 = trunc i64 %28 to i16
%30 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 2
%31 = load i64, i64* %30
%32 = trunc i64 %31 to i16
%33 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 1
%34 = load i64, i64* %33
%35 = trunc i64 %34 to i16
%36 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i64 %23, i8* %24, i64 %26, i16 signext %29, i16 signext %32, i16 signext %35)
br label %37
37: ; preds = %21, %7
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32, i64, i64, i64, i64, i64 }
@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
@.str.1 = [51 x i8] c"%8ld %s [Inode: %ld Links: %hd UID: %hd GID: %hd]\0A\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 ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %33
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 5
%20 = load i64, i64* %19
%21 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 4
%22 = load i64, i64* %21
%23 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 3
%24 = load i64, i64* %23
%25 = trunc i64 %24 to i16
%26 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 2
%27 = load i64, i64* %26
%28 = trunc i64 %27 to i16
%29 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 1
%30 = load i64, i64* %29
%31 = trunc i64 %30 to i16
%32 = tail call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i64 %20, i8* %0, i64 %22, i16 signext %25, i16 signext %28, i16 signext %31)
br label %33
33: ; preds = %18, %6
ret void
}