#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 {
  int /*<<< orphan*/ st_ctime;
  int /*<<< orphan*/ st_mtime;
  int /*<<< orphan*/ st_atime;
};

/* Variables and functions */
char *ctime(int /*<<< orphan*/ *);
int errno;
scalar_t__ lstat(char *, struct stat *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int filetimes(char *str_path) {
  struct stat buf;
  if (lstat(str_path, &buf) < 0) {
    perror("lstat failed");
    return errno;
  }
  time_t accesstime = buf.st_atime;
  char *timeptr = ctime(&accesstime);
  printf("Access Time: %s", timeptr);
  time_t modifytime = buf.st_mtime;
  timeptr = ctime(&modifytime);
  printf("Modify Time: %s", timeptr);
  time_t statuschangetime = buf.st_ctime;
  timeptr = ctime(&statuschangetime);
  printf("Status Time: %s", timeptr);
  return 0;
}


x86 assembly (clang, -O0):
<filetimes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <lstat@plt>
cmp    $0x0,%rax
jge    1180 <filetimes+0x40>
lea    0xe96(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11f0 <filetimes+0xb0>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
lea    -0x24(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xe6f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x34(%rbp)
lea    -0x34(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xe5c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x38(%rbp)
lea    -0x38(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xe49(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filetimes>:
sub    $0x28,%rsp
lea    0x18(%rsp),%rsi
call   1050 <lstat@plt>
test   %rax,%rax
js     11bd <filetimes+0x7d>
mov    0x20(%rsp),%eax
mov    %eax,0x14(%rsp)
lea    0x14(%rsp),%rdi
call   1030 <ctime@plt>
lea    0xea1(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    0x1c(%rsp),%eax
mov    %eax,0x10(%rsp)
lea    0x10(%rsp),%rdi
call   1030 <ctime@plt>
lea    0xe90(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    0x18(%rsp),%eax
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <ctime@plt>
lea    0xe7f(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret
lea    0xe3c(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.stat = type { i32, i32, i32 }
@.str = [13 x i8] c"lstat failed\00"
@errno = global i32 0
@.str.1 = [16 x i8] c"Access Time: %s\00"
@.str.2 = [16 x i8] c"Modify Time: %s\00"
@.str.3 = [16 x i8] c"Status Time: %s\00"
define i32 @filetimes(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.stat
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
%9 = load i8*, i8** %3
%10 = call i64 @lstat(i8* %9, %struct.stat* %4)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @errno
store i32 %14, i32* %2
br label %31
15: ; preds = %1
%16 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 2
%17 = load i32, i32* %16
store i32 %17, i32* %5
%18 = call i8* @ctime(i32* %5)
store i8* %18, i8** %6
%19 = load i8*, i8** %6
%20 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 1
%22 = load i32, i32* %21
store i32 %22, i32* %7
%23 = call i8* @ctime(i32* %7)
store i8* %23, i8** %6
%24 = load i8*, i8** %6
%25 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%26 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%27 = load i32, i32* %26
store i32 %27, i32* %8
%28 = call i8* @ctime(i32* %8)
store i8* %28, i8** %6
%29 = load i8*, i8** %6
%30 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %29)
store i32 0, i32* %2
br label %31
31: ; preds = %15, %12
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32 }
@.str = [13 x i8] c"lstat failed\00"
@errno = global i32 0
@.str.1 = [16 x i8] c"Access Time: %s\00"
@.str.2 = [16 x i8] c"Modify Time: %s\00"
@.str.3 = [16 x i8] c"Status Time: %s\00"
define i32 @filetimes(i8* nocapture %0) {
%2 = alloca %struct.stat
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast %struct.stat* %2 to i8*
%7 = call i64 @lstat(i8* %0, %struct.stat* %2)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @errno
br label %28
12: ; preds = %1
%13 = bitcast i32* %3 to i8*
%14 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 2
%15 = load i32, i32* %14
store i32 %15, i32* %3
%16 = call i8* @ctime(i32* %3)
%17 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = bitcast i32* %4 to i8*
%19 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 1
%20 = load i32, i32* %19
store i32 %20, i32* %4
%21 = call i8* @ctime(i32* %4)
%22 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%23 = bitcast i32* %5 to i8*
%24 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%25 = load i32, i32* %24
store i32 %25, i32* %5
%26 = call i8* @ctime(i32* %5)
%27 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %12, %9
%29 = phi i32 [ %11, %9 ], [ 0, %12 ]
ret i32 %29
}