#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*/ timestr;
struct stat {
  scalar_t__ st_size;
  int /*<<< orphan*/ st_mtime;
};
typedef int /*<<< orphan*/ path;
typedef int /*<<< orphan*/ int64_t;
typedef int /*<<< orphan*/ encoded_name;

/* Variables and functions */
int /*<<< orphan*/ localtime(int /*<<< orphan*/ *);
scalar_t__ lstat(char *, struct stat *);
int /*<<< orphan*/ printf(char *, char *, char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
int /*<<< orphan*/ strencode(char *, int, char *);
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
void file_details(char *dir, char *name) {
  static char encoded_name[1000];
  static char path[2000];
  struct stat sb;
  char timestr[16];
  strencode(encoded_name, sizeof(encoded_name), name);
  (void)snprintf(path, sizeof(path), "%s/%s", dir, name);
  if (lstat(path, &sb) < 0)
    (void)printf("<a href=\"%s\">%-32.32s</a>    ???\n", encoded_name, name);
  else {
    (void)strftime(timestr, sizeof(timestr), "%d%b%Y %H:%M",
                   localtime(&sb.st_mtime));
    (void)printf("<a href=\"%s\">%-32.32s</a>    %15s %14lld\n", encoded_name,
                 name, timestr, (int64_t)sb.st_size);
  }
}


x86 assembly (clang, -O0):
<file_details>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdx
lea    0x2ee5(%rip),%rdi
mov    $0x3e8,%esi
call   1070 <strencode@plt>
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0x32bc(%rip),%rdi
mov    $0x7d0,%esi
lea    0xe60(%rip),%rdx
call   1050 <snprintf@plt>
lea    0x32a4(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <lstat@plt>
cmp    $0x0,%rax
jge    11dd <file_details+0x7d>
mov    -0x10(%rbp),%rdx
lea    0xe3c(%rip),%rdi
lea    0x2e8f(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    122d <file_details+0xcd>
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x20(%rbp),%rdi
add    $0x8,%rdi
call   1030 <localtime@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%ecx
mov    $0x10,%esi
lea    0xe24(%rip),%rdx
call   1080 <strftime@plt>
mov    -0x10(%rbp),%rdx
lea    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %eax,%r8d
lea    0xe16(%rip),%rdi
lea    0x2e3a(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_details>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x2eea(%rip),%rdi
mov    $0x3e8,%esi
mov    %r14,%rdx
call   1070 <strencode@plt>
lea    0x32c6(%rip),%r15
lea    0xe6f(%rip),%rdx
mov    %r15,%rdi
mov    $0x7d0,%esi
mov    %rbx,%rcx
mov    %r14,%r8
call   1050 <snprintf@plt>
mov    %rsp,%rsi
mov    %r15,%rdi
call   1060 <lstat@plt>
test   %rax,%rax
js     1202 <file_details+0xa2>
lea    0x8(%rsp),%rdi
call   1030 <localtime@plt>
lea    0xe63(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x10,%esi
mov    %eax,%ecx
call   1080 <strftime@plt>
mov    (%rsp),%r8d
lea    0xe51(%rip),%rdi
lea    0x2e75(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xdfd(%rip),%rdi
lea    0x2e50(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <printf@plt>

LLVM IR (-O0):
%struct.stat = type { i64, i32 }
@file_details.encoded_name = internal global [1000 x i8] zeroinitializer
@file_details.path = internal global [2000 x i8] zeroinitializer
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [34 x i8] c"<a href=\22%s\22>%-32.32s</a> ???\0A\00"
@.str.2 = [13 x i8] c"%d%b%Y %H:%M\00"
@.str.3 = [42 x i8] c"<a href=\22%s\22>%-32.32s</a> %15s %14lld\0A\00"
define void @file_details(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca %struct.stat
%6 = alloca [16 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i32 @strencode(i8* getelementptr inbounds ([1000 x i8], [1000 x i8]* @file_details.encoded_name, i64 0, i64 0), i32 1000, i8* %7)
%9 = load i8*, i8** %3
%10 = load i8*, i8** %4
%11 = call i32 @snprintf(i8* getelementptr inbounds ([2000 x i8], [2000 x i8]* @file_details.path, i64 0, i64 0), i32 2000, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %10)
%12 = call i64 @lstat(i8* getelementptr inbounds ([2000 x i8], [2000 x i8]* @file_details.path, i64 0, i64 0), %struct.stat* %5)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1000 x i8], [1000 x i8]* @file_details.encoded_name, i64 0, i64 0), i8* %15)
br label %28
17: ; preds = %2
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%19 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 1
%20 = call i32 @localtime(i32* %19)
%21 = call i32 @strftime(i8* %18, i32 16, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = load i8*, i8** %4
%23 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%24 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%25 = load i64, i64* %24
%26 = trunc i64 %25 to i32
%27 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1000 x i8], [1000 x i8]* @file_details.encoded_name, i64 0, i64 0), i8* %22, i8* %23, i32 %26)
br label %28
28: ; preds = %17, %14
ret void
}

LLVM IR (-O2):
%struct.stat = type { i64, i32 }
@file_details.encoded_name = internal global [1000 x i8] zeroinitializer
@file_details.path = internal global [2000 x i8] zeroinitializer
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [34 x i8] c"<a href=\22%s\22>%-32.32s</a> ???\0A\00"
@.str.2 = [13 x i8] c"%d%b%Y %H:%M\00"
@.str.3 = [42 x i8] c"<a href=\22%s\22>%-32.32s</a> %15s %14lld\0A\00"
define void @file_details(i8* %0, i8* %1) {
%3 = alloca %struct.stat
%4 = alloca [16 x i8]
%5 = bitcast %struct.stat* %3 to i8*
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @strencode(i8* getelementptr inbounds ([1000 x i8], [1000 x i8]* @file_details.encoded_name, i64 0, i64 0), i32 1000, i8* %1)
%8 = tail call i32 @snprintf(i8* getelementptr inbounds ([2000 x i8], [2000 x i8]* @file_details.path, i64 0, i64 0), i32 2000, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%9 = call i64 @lstat(i8* getelementptr inbounds ([2000 x i8], [2000 x i8]* @file_details.path, i64 0, i64 0), %struct.stat* %3)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = tail call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1000 x i8], [1000 x i8]* @file_details.encoded_name, i64 0, i64 0), i8* %1)
br label %21
13: ; preds = %2
%14 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%15 = call i32 @localtime(i32* %14)
%16 = call i32 @strftime(i8* %6, i32 16, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%18 = load i64, i64* %17
%19 = trunc i64 %18 to i32
%20 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1000 x i8], [1000 x i8]* @file_details.encoded_name, i64 0, i64 0), i8* %1, i8* %6, i32 %19)
br label %21
21: ; preds = %13, %11
ret void
}