#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 */
typedef int /*<<< orphan*/ time_t;
struct stat {
  scalar_t__ st_size;
  int /*<<< orphan*/ st_mtime;
  int /*<<< orphan*/ st_mode;
};

/* Variables and functions */
scalar_t__ S_ISDIR(int /*<<< orphan*/);
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ dirwalk(char *, void (*)(char *));
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, long long, char *, char *);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int strlen(char *);
void finfo(char *name) {
  struct stat stbuf;
  time_t filetime;
  char *timestr;
  if (stat(name, &stbuf) == -1) {
    fprintf(stderr, "finfo: cannot access %s\n", name);
    return;
  }
  if (S_ISDIR(stbuf.st_mode))
    dirwalk(name, finfo);
  filetime = stbuf.st_mtime;
  timestr = ctime(&filetime);
  timestr[strlen(timestr) - 1] = '\0';
  printf("%8lld %s (modified %s)\n", (long long)stbuf.st_size, name, timestr);
}


x86 assembly (clang, -O0):
<finfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1080 <stat@plt>
cmp    $0xffffffff,%eax
jne    11b0 <finfo+0x40>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe5a(%rip),%rsi
call   1070 <fprintf@plt>
jmp    121e <finfo+0xae>
mov    -0xc(%rbp),%edi
call   1060 <S_ISDIR@plt>
cmp    $0x0,%rax
je     11d2 <finfo+0x62>
mov    -0x8(%rbp),%rdi
mov    0x2e0b(%rip),%rsi
call   1090 <dirwalk@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
lea    -0x1c(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xe00(%rip),%rdi
call   1050 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<finfo>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
lea    0x8(%rsp),%rsi
call   1080 <stat@plt>
cmp    $0xffffffff,%eax
je     11e9 <finfo+0x79>
mov    0x14(%rsp),%edi
call   1060 <S_ISDIR@plt>
test   %rax,%rax
je     11a6 <finfo+0x36>
mov    0x2e3a(%rip),%rsi
mov    %r14,%rdi
call   1090 <dirwalk@plt>
mov    0x10(%rsp),%eax
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <ctime@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    0x8(%rsp),%rsi
lea    0xe43(%rip),%rdi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1050 <printf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
lea    0xe07(%rip),%rsi
mov    %r14,%rdx
add    $0x18,%rsp
pop    %rbx
pop    %r14
jmp    1070 <fprintf@plt>

LLVM IR (-O0):
%struct.stat = type { i64, i32, i32 }
@stderr = global i32 0
@.str = [25 x i8] c"finfo: cannot access %s\0A\00"
@.str.1 = [24 x i8] c"%8lld %s (modified %s)\0A\00"
define void @finfo(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.stat
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @stat(i8* %6, %struct.stat* %3)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %2
%12 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %36
13: ; preds = %1
%14 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 2
%15 = load i32, i32* %14
%16 = call i64 @S_ISDIR(i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i8*, i8** %2
%20 = call i32 @dirwalk(i8* %19, void (i8*)* @finfo)
br label %21
21: ; preds = %18, %13
%22 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 1
%23 = load i32, i32* %22
store i32 %23, i32* %4
%24 = call i8* @ctime(i32* %4)
store i8* %24, i8** %5
%25 = load i8*, i8** %5
%26 = load i8*, i8** %5
%27 = call i32 @strlen(i8* %26)
%28 = sub nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %25, i64 %29
store i8 0, i8* %30
%31 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%32 = load i64, i64* %31
%33 = load i8*, i8** %2
%34 = load i8*, i8** %5
%35 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i64 %32, i8* %33, i8* %34)
br label %36
36: ; preds = %21, %9
ret void
}

LLVM IR (-O2):
%struct.stat = type { i64, i32, i32 }
@stderr = global i32 0
@.str = [25 x i8] c"finfo: cannot access %s\0A\00"
@.str.1 = [24 x i8] c"%8lld %s (modified %s)\0A\00"
define void @finfo(i8* %0) {
%2 = alloca %struct.stat
%3 = alloca i32
%4 = bitcast %struct.stat* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = call i32 @stat(i8* %0, %struct.stat* %2)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %29
11: ; preds = %1
%12 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 2
%13 = load i32, i32* %12
%14 = tail call i64 @S_ISDIR(i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %11
%17 = tail call i32 @dirwalk(i8* %0, void (i8*)* @finfo)
br label %18
18: ; preds = %16, %11
%19 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 1
%20 = load i32, i32* %19
store i32 %20, i32* %3
%21 = call i8* @ctime(i32* %3)
%22 = call i32 @strlen(i8* %21)
%23 = add nsw i32 %22, -1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %21, i64 %24
store i8 0, i8* %25
%26 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%27 = load i64, i64* %26
%28 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i64 %27, i8* %0, i8* %21)
br label %29
29: ; preds = %18, %8
ret void
}