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

/* Variables and functions */
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ memset(struct stat *, int /*<<< orphan*/, int);
int /*<<< orphan*/ mz_path_remove_slash(char *);
scalar_t__ stat(char *, struct stat *);
scalar_t__ strcmp(char const *, char *);
size_t strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char const *, size_t);
int32_t mz_os_get_file_date(const char *path, time_t *modified_date,
                            time_t *accessed_date, time_t *creation_date) {
  struct stat path_stat;
  char *name = NULL;
  size_t len = 0;
  int32_t err = (-104);
  memset(&path_stat, 0, sizeof(path_stat));
  if (strcmp(path, "-") != 0) {
    len = strlen(path);
    name = (char *)malloc(len + 1);
    strncpy(name, path, len + 1);
    mz_path_remove_slash(name);
    if (stat(name, &path_stat) == 0) {
      if (modified_date != NULL)
        *modified_date = path_stat.st_mtime;
      if (accessed_date != NULL)
        *accessed_date = path_stat.st_atime;
      if (creation_date != NULL)
        *creation_date = 0;
      err = (0);
    }
    free(name);
  }
  return err;
}


x86 assembly (clang, -O0):
<mz_os_get_file_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movl   $0xffffff98,-0x44(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1070 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    0xe36(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     127e <mz_os_get_file_date+0xfe>
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
add    $0x1,%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x40(%rbp),%rdx
add    $0x1,%rdx
call   1040 <strncpy@plt>
mov    -0x38(%rbp),%rdi
call   1050 <mz_path_remove_slash@plt>
mov    -0x38(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1090 <stat@plt>
cmp    $0x0,%rax
jne    1275 <mz_os_get_file_date+0xf5>
cmpq   $0x0,-0x10(%rbp)
je     1242 <mz_os_get_file_date+0xc2>
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     1258 <mz_os_get_file_date+0xd8>
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x20(%rbp)
je     126e <mz_os_get_file_date+0xee>
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x0,-0x44(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x44(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mz_os_get_file_date>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1070 <memset@plt>
lea    0xe4e(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1236 <mz_os_get_file_date+0xb6>
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%rbp
mov    %rbp,%rdi
call   10a0 <malloc@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1040 <strncpy@plt>
mov    %r13,%rdi
call   1050 <mz_path_remove_slash@plt>
lea    0x8(%rsp),%rsi
mov    %r13,%rdi
call   1090 <stat@plt>
mov    $0xffffff98,%ebx
test   %rax,%rax
jne    122c <mz_os_get_file_date+0xac>
test   %r12,%r12
je     1211 <mz_os_get_file_date+0x91>
mov    0x10(%rsp),%rax
mov    %rax,(%r12)
test   %r15,%r15
je     121e <mz_os_get_file_date+0x9e>
mov    0x8(%rsp),%rax
mov    %rax,(%r15)
xor    %ebx,%ebx
test   %r14,%r14
je     122c <mz_os_get_file_date+0xac>
movq   $0x0,(%r14)
mov    %r13,%rdi
call   1030 <free@plt>
jmp    123b <mz_os_get_file_date+0xbb>
mov    $0xffffff98,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i64, i64 }
@.str = [2 x i8] c"-\00"
define i32 @mz_os_get_file_date(i8* %0, i64* %1, i64* %2, i64* %3) {
%5 = alloca i8*
%6 = alloca i64*
%7 = alloca i64*
%8 = alloca i64*
%9 = alloca %struct.stat
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32
store i8* %0, i8** %5
store i64* %1, i64** %6
store i64* %2, i64** %7
store i64* %3, i64** %8
store i8* null, i8** %10
store i64 0, i64* %11
store i32 -104, i32* %12
%13 = call i32 @memset(%struct.stat* %9, i32 0, i32 16)
%14 = load i8*, i8** %5
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %57
17: ; preds = %4
%18 = load i8*, i8** %5
%19 = call i64 @strlen(i8* %18)
store i64 %19, i64* %11
%20 = load i64, i64* %11
%21 = add i64 %20, 1
%22 = call i64 @malloc(i64 %21)
%23 = inttoptr i64 %22 to i8*
store i8* %23, i8** %10
%24 = load i8*, i8** %10
%25 = load i8*, i8** %5
%26 = load i64, i64* %11
%27 = add i64 %26, 1
%28 = call i32 @strncpy(i8* %24, i8* %25, i64 %27)
%29 = load i8*, i8** %10
%30 = call i32 @mz_path_remove_slash(i8* %29)
%31 = load i8*, i8** %10
%32 = call i64 @stat(i8* %31, %struct.stat* %9)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %54
34: ; preds = %17
%35 = load i64*, i64** %6
%36 = icmp ne i64* %35, null
br i1 %36, label %37, label %41
37: ; preds = %34
%38 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 1
%39 = load i64, i64* %38
%40 = load i64*, i64** %6
store i64 %39, i64* %40
br label %41
41: ; preds = %37, %34
%42 = load i64*, i64** %7
%43 = icmp ne i64* %42, null
br i1 %43, label %44, label %48
44: ; preds = %41
%45 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%46 = load i64, i64* %45
%47 = load i64*, i64** %7
store i64 %46, i64* %47
br label %48
48: ; preds = %44, %41
%49 = load i64*, i64** %8
%50 = icmp ne i64* %49, null
br i1 %50, label %51, label %53
51: ; preds = %48
%52 = load i64*, i64** %8
store i64 0, i64* %52
br label %53
53: ; preds = %51, %48
store i32 0, i32* %12
br label %54
54: ; preds = %53, %17
%55 = load i8*, i8** %10
%56 = call i32 @free(i8* %55)
br label %57
57: ; preds = %54, %4
%58 = load i32, i32* %12
ret i32 %58
}

LLVM IR (-O2):
%struct.stat = type { i64, i64 }
@.str = [2 x i8] c"-\00"
define i32 @mz_os_get_file_date(i8* %0, i64* writeonly %1, i64* writeonly %2, i64* writeonly %3) {
%5 = alloca %struct.stat
%6 = bitcast %struct.stat* %5 to i8*
%7 = call i32 @memset(%struct.stat* %5, i32 0, i32 16)
%8 = call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %35, label %10
10: ; preds = %4
%11 = call i64 @strlen(i8* dereferenceable(1) %0)
%12 = add i64 %11, 1
%13 = call i64 @malloc(i64 %12)
%14 = inttoptr i64 %13 to i8*
%15 = call i32 @strncpy(i8* %14, i8* %0, i64 %12)
%16 = call i32 @mz_path_remove_slash(i8* %14)
%17 = call i64 @stat(i8* %14, %struct.stat* %5)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %32
19: ; preds = %10
%20 = icmp eq i64* %1, null
br i1 %20, label %24, label %21
21: ; preds = %19
%22 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 1
%23 = load i64, i64* %22
store i64 %23, i64* %1
br label %24
24: ; preds = %21, %19
%25 = icmp eq i64* %2, null
br i1 %25, label %29, label %26
26: ; preds = %24
%27 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 0
%28 = load i64, i64* %27
store i64 %28, i64* %2
br label %29
29: ; preds = %26, %24
%30 = icmp eq i64* %3, null
br i1 %30, label %32, label %31
31: ; preds = %29
store i64 0, i64* %3
br label %32
32: ; preds = %29, %31, %10
%33 = phi i32 [ -104, %10 ], [ 0, %31 ], [ 0, %29 ]
%34 = call i32 @free(i8* %14)
br label %35
35: ; preds = %32, %4
%36 = phi i32 [ %33, %32 ], [ -104, %4 ]
ret i32 %36
}