#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 /*<<< orphan*/ st_mtime;
  int /*<<< orphan*/ st_atime;
  int /*<<< orphan*/ st_ctime;
};
struct dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, char *, char *, char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int stat(char *, struct stat *);
char *strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void ls_dirtime(DIR *dir, struct dirent *dirent, struct stat fileStat,
                char *currDir) {
  currDir = strcat(currDir, "/");
  while (NULL != (dirent = readdir(dir))) {
    if (strcmp(dirent->d_name, ".") != 0 && strcmp(dirent->d_name, "..") != 0) {
      char path[1024];
      strcpy(path, currDir);
      strcat(path, dirent->d_name);
      if (stat(path, &fileStat) == -1) {
        perror("stat");
        exit(EXIT_FAILURE);
      }
      printf("File Name - %s \nLast Status Change -  %sLast Access Time   -  "
             "%sLast Modified Time -  %s \n",
             dirent->d_name, ctime(&fileStat.st_ctime),
             ctime(&fileStat.st_atime), ctime(&fileStat.st_mtime));
      memset(path, 0, 255);
    }
  }
}


x86 assembly (clang, -O0):
<ls_dirtime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xe29(%rip),%rsi
call   10b0 <strcat@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1090 <readdir@plt>
mov    %rax,%rcx
mov    %rcx,-0x30(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
je     1306 <ls_dirtime+0x166>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
lea    0xdfa(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1301 <ls_dirtime+0x161>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
lea    0xddc(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1301 <ls_dirtime+0x161>
lea    -0x440(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x440(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    (%rax),%rsi
call   10b0 <strcat@plt>
lea    -0x440(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1080 <stat@plt>
cmp    $0xffffffff,%eax
jne    128b <ls_dirtime+0xeb>
lea    0xd8d(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2d5c(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x458(%rbp)
lea    -0x10(%rbp),%rdi
add    $0x8,%rdi
call   1040 <ctime@plt>
mov    %rax,-0x450(%rbp)
lea    -0x10(%rbp),%rdi
add    $0x4,%rdi
call   1040 <ctime@plt>
mov    %rax,-0x448(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <ctime@plt>
mov    -0x458(%rbp),%rsi
mov    -0x450(%rbp),%rdx
mov    -0x448(%rbp),%rcx
mov    %rax,%r8
lea    0xd21(%rip),%rdi
call   1050 <printf@plt>
lea    -0x440(%rbp),%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1060 <memset@plt>
jmp    11e0 <ls_dirtime+0x40>
add    $0x460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ls_dirtime>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    %r8,%rbp
mov    %rdi,%r13
mov    %rdx,(%rsp)
mov    %ecx,0x8(%rsp)
mov    %r8,%rdi
call   1050 <strlen@plt>
mov    %rbp,0x10(%rsp)
movw   $0x2f,0x0(%rbp,%rax,1)
mov    %r13,%rdi
call   10a0 <readdir@plt>
test   %rax,%rax
je     12d8 <ls_dirtime+0x128>
mov    %rax,%rbp
lea    0xe03(%rip),%rbx
lea    0x20(%rsp),%r12
mov    %rsp,%r14
jmp    1224 <ls_dirtime+0x74>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   10a0 <readdir@plt>
mov    %rax,%rbp
test   %rax,%rax
je     12d8 <ls_dirtime+0x128>
mov    0x0(%rbp),%rdi
mov    %rbx,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1210 <ls_dirtime+0x60>
mov    0x0(%rbp),%rdi
lea    0xdc0(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1210 <ls_dirtime+0x60>
mov    %rbx,%r15
mov    %r12,%rdi
mov    0x10(%rsp),%rsi
call   1030 <strcpy@plt>
mov    0x0(%rbp),%rsi
mov    %r12,%rdi
call   10c0 <strcat@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1090 <stat@plt>
cmp    $0xffffffff,%eax
je     12ea <ls_dirtime+0x13a>
mov    %r14,%rbx
mov    0x0(%rbp),%rax
mov    %rax,0x18(%rsp)
lea    0x8(%rsp),%rdi
call   1040 <ctime@plt>
mov    %rax,%rbp
lea    0x4(%rsp),%rdi
call   1040 <ctime@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <ctime@plt>
lea    0xd5d(%rip),%rdi
mov    0x18(%rsp),%rsi
mov    %rbp,%rdx
mov    %r14,%rcx
mov    %rax,%r8
call   1060 <printf@plt>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1070 <memset@plt>
mov    %rbx,%r14
mov    %r15,%rbx
jmp    1210 <ls_dirtime+0x60>
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd12(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2ce3(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.dirent = type { i8* }
%struct.stat = type { i32, i32, i32 }
@.str = [2 x i8] c"/\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [3 x i8] c"..\00"
@.str.3 = [5 x i8] c"stat\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [91 x i8] c"File Name - %s \0ALast Status Change - %sLast Access Time - %sLast Modified Time - %s \0A\00"
define void @ls_dirtime(i32* %0, %struct.dirent* %1, i64 %2, i32 %3, i8* %4) {
%6 = alloca %struct.stat
%7 = alloca { i64, i32 }
%8 = alloca i32*
%9 = alloca %struct.dirent*
%10 = alloca i8*
%11 = alloca [1024 x i8]
%12 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %7, i32 0, i32 0
store i64 %2, i64* %12
%13 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %7, i32 0, i32 1
store i32 %3, i32* %13
%14 = bitcast %struct.stat* %6 to i8*
%15 = bitcast { i64, i32 }* %7 to i8*
store i32* %0, i32** %8
store %struct.dirent* %1, %struct.dirent** %9
store i8* %4, i8** %10
%16 = load i8*, i8** %10
%17 = call i8* @strcat(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %17, i8** %10
br label %18
18: ; preds = %63, %5
%19 = load i32*, i32** %8
%20 = call %struct.dirent* @readdir(i32* %19)
store %struct.dirent* %20, %struct.dirent** %9
%21 = icmp ne %struct.dirent* null, %20
br i1 %21, label %22, label %64
22: ; preds = %18
%23 = load %struct.dirent*, %struct.dirent** %9
%24 = getelementptr inbounds %struct.dirent, %struct.dirent* %23, i32 0, i32 0
%25 = load i8*, i8** %24
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %63
28: ; preds = %22
%29 = load %struct.dirent*, %struct.dirent** %9
%30 = getelementptr inbounds %struct.dirent, %struct.dirent* %29, i32 0, i32 0
%31 = load i8*, i8** %30
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %63
34: ; preds = %28
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%36 = load i8*, i8** %10
%37 = call i32 @strcpy(i8* %35, i8* %36)
%38 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%39 = load %struct.dirent*, %struct.dirent** %9
%40 = getelementptr inbounds %struct.dirent, %struct.dirent* %39, i32 0, i32 0
%41 = load i8*, i8** %40
%42 = call i8* @strcat(i8* %38, i8* %41)
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%44 = call i32 @stat(i8* %43, %struct.stat* %6)
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %50
46: ; preds = %34
%47 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%48 = load i32, i32* @EXIT_FAILURE
%49 = call i32 @exit(i32 %48)
unreachable
50: ; preds = %34
%51 = load %struct.dirent*, %struct.dirent** %9
%52 = getelementptr inbounds %struct.dirent, %struct.dirent* %51, i32 0, i32 0
%53 = load i8*, i8** %52
%54 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 2
%55 = call i8* @ctime(i32* %54)
%56 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 1
%57 = call i8* @ctime(i32* %56)
%58 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%59 = call i8* @ctime(i32* %58)
%60 = call i32 @printf(i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.4, i64 0, i64 0), i8* %53, i8* %55, i8* %57, i8* %59)
%61 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%62 = call i32 @memset(i8* %61, i32 0, i32 255)
br label %63
63: ; preds = %50, %28, %22
br label %18
64: ; preds = %18
ret void
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
%struct.stat = type { i32, i32, i32 }
@.str.1 = [2 x i8] c".\00"
@.str.2 = [3 x i8] c"..\00"
@.str.3 = [5 x i8] c"stat\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [91 x i8] c"File Name - %s \0ALast Status Change - %sLast Access Time - %sLast Modified Time - %s \0A\00"
define void @ls_dirtime(i32* %0, %struct.dirent* nocapture readnone %1, i64 %2, i32 %3, i8* %4) {
%6 = alloca %struct.stat
%7 = alloca [1024 x i8]
%8 = bitcast %struct.stat* %6 to i64*
store i64 %2, i64* %8
%9 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 2
store i32 %3, i32* %9
%10 = tail call i64 @strlen(i8* dereferenceable(1) %4)
%11 = getelementptr i8, i8* %4, i64 %10
%12 = bitcast i8* %11 to i16*
store i16 47, i16* %12
%13 = call %struct.dirent* @readdir(i32* %0)
%14 = icmp eq %struct.dirent* %13, null
br i1 %14, label %49, label %15
15: ; preds = %5
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%17 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 1
%18 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 0
br label %19
19: ; preds = %15, %46
%20 = phi %struct.dirent* [ %13, %15 ], [ %47, %46 ]
%21 = getelementptr inbounds %struct.dirent, %struct.dirent* %20, i64 0, i32 0
%22 = load i8*, i8** %21
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %46, label %25
25: ; preds = %19
%26 = load i8*, i8** %21
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %46, label %29
29: ; preds = %25
%30 = call i32 @strcpy(i8* %16, i8* %4)
%31 = load i8*, i8** %21
%32 = call i8* @strcat(i8* %16, i8* dereferenceable(1) %31)
%33 = call i32 @stat(i8* %16, %struct.stat* %6)
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %39
35: ; preds = %29
%36 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %29
%40 = load i8*, i8** %21
%41 = call i8* @ctime(i32* %9)
%42 = call i8* @ctime(i32* %17)
%43 = call i8* @ctime(i32* %18)
%44 = call i32 @printf(i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.4, i64 0, i64 0), i8* %40, i8* %41, i8* %42, i8* %43)
%45 = call i32 @memset(i8* %16, i32 0, i32 255)
br label %46
46: ; preds = %39, %25, %19
%47 = call %struct.dirent* @readdir(i32* %0)
%48 = icmp eq %struct.dirent* %47, null
br i1 %48, label %49, label %19
49: ; preds = %46, %5
ret void
}