#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 st_size;
  int st_ino;
  int st_atime;
  int st_ctime;
};

/* Variables and functions */
int /*<<< orphan*/ dirwalk(char *, void (*)(char *));
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, int, char *);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
void fsize(char *name) {
  struct stat stubf;
  if (stat(name, &stubf) == -1) {
    fprintf(stderr, "fsize: can't access %s\n", name);
    return;
  }
  if ((stubf.st_mode & 00170000) == 0040000) {
    dirwalk(name, fsize);
  }
  printf("%8ld %s\n", stubf.st_size, name);
  printf("%8ld %s\n", stubf.st_ino, name);
  printf("%8d %s\n", stubf.st_mode, name);
  printf("%8ld %s\n", stubf.st_atime, name);
  printf("%8ld %s\n", stubf.st_ctime, name);
}


x86 assembly (clang, -O0):
<fsize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0xffffffff,%eax
jne    1180 <fsize+0x40>
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe8a(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1202 <fsize+0xc2>
mov    -0x20(%rbp),%eax
and    $0xf000,%eax
cmp    $0x4000,%eax
jne    11a3 <fsize+0x63>
mov    -0x8(%rbp),%rdi
mov    0x2e4a(%rip),%rsi
call   1060 <dirwalk@plt>
mov    -0x1c(%rbp),%esi
mov    -0x8(%rbp),%rdx
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
mov    -0x8(%rbp),%rdx
lea    0xe54(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%esi
mov    -0x8(%rbp),%rdx
lea    0xe4a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rdx
lea    0xe2e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%rdx
lea    0xe1b(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fsize>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
call   1050 <stat@plt>
cmp    $0xffffffff,%eax
je     11d7 <fsize+0x97>
mov    0x8(%rsp),%ebp
mov    %ebp,%eax
and    $0xf000,%eax
cmp    $0x4000,%eax
jne    117b <fsize+0x3b>
mov    0x2e75(%rip),%rsi
mov    %rbx,%rdi
call   1060 <dirwalk@plt>
mov    0xc(%rsp),%esi
lea    0xe92(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rdx
call   1030 <printf@plt>
mov    0x10(%rsp),%esi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1030 <printf@plt>
lea    0xe7a(%rip),%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1030 <printf@plt>
mov    0x14(%rsp),%esi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1030 <printf@plt>
mov    0x18(%rsp),%esi
mov    %r14,%rdi
mov    %rbx,%rdx
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
lea    0xe19(%rip),%rsi
mov    %rbx,%rdx
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
%struct.stat = type { i32, i32, i32, i32, i32 }
@stderr = global i32 0
@.str = [24 x i8] c"fsize: can't access %s\0A\00"
@.str.1 = [9 x i8] c"%8ld %s\0A\00"
@.str.2 = [8 x i8] c"%8d %s\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 %40
11: ; preds = %1
%12 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%13 = load i32, i32* %12
%14 = and i32 %13, 61440
%15 = icmp eq i32 %14, 16384
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i8*, i8** %2
%18 = call i32 @dirwalk(i8* %17, void (i8*)* @fsize)
br label %19
19: ; preds = %16, %11
%20 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 1
%21 = load i32, i32* %20
%22 = load i8*, i8** %2
%23 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %21, i8* %22)
%24 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 2
%25 = load i32, i32* %24
%26 = load i8*, i8** %2
%27 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %25, i8* %26)
%28 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%29 = load i32, i32* %28
%30 = load i8*, i8** %2
%31 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %29, i8* %30)
%32 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 3
%33 = load i32, i32* %32
%34 = load i8*, i8** %2
%35 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %33, i8* %34)
%36 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 4
%37 = load i32, i32* %36
%38 = load i8*, i8** %2
%39 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %37, i8* %38)
br label %40
40: ; preds = %19, %7
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32, i32, i32 }
@stderr = global i32 0
@.str = [24 x i8] c"fsize: can't access %s\0A\00"
@.str.1 = [9 x i8] c"%8ld %s\0A\00"
@.str.2 = [8 x i8] c"%8d %s\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 %30
9: ; preds = %1
%10 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%11 = load i32, i32* %10
%12 = and i32 %11, 61440
%13 = icmp eq i32 %12, 16384
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = tail call i32 @dirwalk(i8* %0, void (i8*)* @fsize)
br label %16
16: ; preds = %14, %9
%17 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 1
%18 = load i32, i32* %17
%19 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %18, i8* %0)
%20 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 2
%21 = load i32, i32* %20
%22 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %21, i8* %0)
%23 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %11, i8* %0)
%24 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 3
%25 = load i32, i32* %24
%26 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %25, i8* %0)
%27 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 4
%28 = load i32, i32* %27
%29 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %28, i8* %0)
br label %30
30: ; preds = %16, %6
ret void
}