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

/* Variables and functions */
int /*<<< orphan*/ dirwalk(char *, void (*)(char *));
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/, char *, int);
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 & 0160000) == 0040000) {
    dirwalk(name, fsize);
  }
  printf("%8ld %s %o\n", stbuf.st_size, name, stbuf.st_mode & 0160000);
}


x86 assembly (clang, -O0):
<fsize>:
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    1180 <fsize+0x40>
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe8a(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11bf <fsize+0x7f>
mov    -0x10(%rbp),%eax
and    $0xe000,%eax
cmp    $0x4000,%eax
jne    11a3 <fsize+0x63>
mov    -0x8(%rbp),%rdi
mov    0x2e4a(%rip),%rsi
call   1060 <dirwalk@plt>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%ecx
and    $0xe000,%ecx
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fsize>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    %rsp,%rsi
call   1050 <stat@plt>
cmp    $0xffffffff,%eax
je     118d <fsize+0x4d>
mov    $0xe000,%ebp
and    (%rsp),%ebp
cmp    $0x4000,%ebp
jne    1172 <fsize+0x32>
mov    0x2e7e(%rip),%rsi
mov    %rbx,%rdi
call   1060 <dirwalk@plt>
mov    0x4(%rsp),%esi
lea    0xe9b(%rip),%rdi
mov    %rbx,%rdx
mov    %ebp,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <printf@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
mov    %rbx,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
%struct.stat = type { i32, i32 }
@stderr = global i32 0
@.str = [24 x i8] c"fsize: can't access %s\0A\00"
@.str.1 = [12 x i8] c"%8ld %s %o\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 %27
11: ; preds = %1
%12 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%13 = load i32, i32* %12
%14 = and i32 %13, 57344
%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 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%24 = load i32, i32* %23
%25 = and i32 %24, 57344
%26 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %21, i8* %22, i32 %25)
br label %27
27: ; preds = %19, %7
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32, i32 }
@stderr = global i32 0
@.str = [24 x i8] c"fsize: can't access %s\0A\00"
@.str.1 = [12 x i8] c"%8ld %s %o\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 %20
9: ; preds = %1
%10 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%11 = load i32, i32* %10
%12 = and i32 %11, 57344
%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 ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %18, i8* %0, i32 %12)
br label %20
20: ; preds = %16, %6
ret void
}