#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);
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);
    name[len] = 0;
    if (name[len - 1] == '/' || name[len - 1] == '\\')
      name[len - 1] = 0;
    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   1060 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    0xe46(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     12af <mz_os_get_file_date+0x13f>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
add    $0x1,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x40(%rbp),%rdx
call   1040 <strncpy@plt>
mov    -0x38(%rbp),%rax
mov    -0x40(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x38(%rbp),%rax
mov    -0x40(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
je     1236 <mz_os_get_file_date+0xc6>
mov    -0x38(%rbp),%rax
mov    -0x40(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
jne    1246 <mz_os_get_file_date+0xd6>
mov    -0x38(%rbp),%rax
mov    -0x40(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x38(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1080 <stat@plt>
cmp    $0x0,%rax
jne    12a6 <mz_os_get_file_date+0x136>
cmpq   $0x0,-0x10(%rbp)
je     1273 <mz_os_get_file_date+0x103>
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     1289 <mz_os_get_file_date+0x119>
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x20(%rbp)
je     129f <mz_os_get_file_date+0x12f>
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   1060 <memset@plt>
lea    0xe5e(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     123b <mz_os_get_file_date+0xcb>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rax,%rbp
lea    0x1(%rax),%rdi
call   1090 <malloc@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1040 <strncpy@plt>
movb   $0x0,0x0(%r13,%rbp,1)
mov    -0x1(%r13,%rbp,1),%al
cmp    $0x5c,%al
je     11eb <mz_os_get_file_date+0x7b>
cmp    $0x2f,%al
jne    11f1 <mz_os_get_file_date+0x81>
movb   $0x0,-0x1(%r13,%rbp,1)
lea    0x8(%rsp),%rsi
mov    %r13,%rdi
call   1080 <stat@plt>
mov    $0xffffff98,%ebx
test   %rax,%rax
jne    1231 <mz_os_get_file_date+0xc1>
test   %r12,%r12
je     1216 <mz_os_get_file_date+0xa6>
mov    0x10(%rsp),%rax
mov    %rax,(%r12)
test   %r15,%r15
je     1223 <mz_os_get_file_date+0xb3>
mov    0x8(%rsp),%rax
mov    %rax,(%r15)
xor    %ebx,%ebx
test   %r14,%r14
je     1231 <mz_os_get_file_date+0xc1>
movq   $0x0,(%r14)
mov    %r13,%rdi
call   1030 <free@plt>
jmp    1240 <mz_os_get_file_date+0xd0>
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 %78
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 = call i32 @strncpy(i8* %24, i8* %25, i64 %26)
%28 = load i8*, i8** %10
%29 = load i64, i64* %11
%30 = getelementptr inbounds i8, i8* %28, i64 %29
store i8 0, i8* %30
%31 = load i8*, i8** %10
%32 = load i64, i64* %11
%33 = sub i64 %32, 1
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 47
br i1 %37, label %46, label %38
38: ; preds = %17
%39 = load i8*, i8** %10
%40 = load i64, i64* %11
%41 = sub i64 %40, 1
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 92
br i1 %45, label %46, label %51
46: ; preds = %38, %17
%47 = load i8*, i8** %10
%48 = load i64, i64* %11
%49 = sub i64 %48, 1
%50 = getelementptr inbounds i8, i8* %47, i64 %49
store i8 0, i8* %50
br label %51
51: ; preds = %46, %38
%52 = load i8*, i8** %10
%53 = call i64 @stat(i8* %52, %struct.stat* %9)
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %75
55: ; preds = %51
%56 = load i64*, i64** %6
%57 = icmp ne i64* %56, null
br i1 %57, label %58, label %62
58: ; preds = %55
%59 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 1
%60 = load i64, i64* %59
%61 = load i64*, i64** %6
store i64 %60, i64* %61
br label %62
62: ; preds = %58, %55
%63 = load i64*, i64** %7
%64 = icmp ne i64* %63, null
br i1 %64, label %65, label %69
65: ; preds = %62
%66 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%67 = load i64, i64* %66
%68 = load i64*, i64** %7
store i64 %67, i64* %68
br label %69
69: ; preds = %65, %62
%70 = load i64*, i64** %8
%71 = icmp ne i64* %70, null
br i1 %71, label %72, label %74
72: ; preds = %69
%73 = load i64*, i64** %8
store i64 0, i64* %73
br label %74
74: ; preds = %72, %69
store i32 0, i32* %12
br label %75
75: ; preds = %74, %51
%76 = load i8*, i8** %10
%77 = call i32 @free(i8* %76)
br label %78
78: ; preds = %75, %4
%79 = load i32, i32* %12
ret i32 %79
}

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 %40, 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 %11)
%16 = getelementptr inbounds i8, i8* %14, i64 %11
store i8 0, i8* %16
%17 = add i64 %11, -1
%18 = getelementptr inbounds i8, i8* %14, i64 %17
%19 = load i8, i8* %18
switch i8 %19, label %21 [
i8 47, label %20
i8 92, label %20
]
20: ; preds = %10, %10
store i8 0, i8* %18
br label %21
21: ; preds = %10, %20
%22 = call i64 @stat(i8* %14, %struct.stat* %5)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %37
24: ; preds = %21
%25 = icmp eq i64* %1, null
br i1 %25, label %29, label %26
26: ; preds = %24
%27 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 1
%28 = load i64, i64* %27
store i64 %28, i64* %1
br label %29
29: ; preds = %26, %24
%30 = icmp eq i64* %2, null
br i1 %30, label %34, label %31
31: ; preds = %29
%32 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 0
%33 = load i64, i64* %32
store i64 %33, i64* %2
br label %34
34: ; preds = %31, %29
%35 = icmp eq i64* %3, null
br i1 %35, label %37, label %36
36: ; preds = %34
store i64 0, i64* %3
br label %37
37: ; preds = %34, %36, %21
%38 = phi i32 [ -104, %21 ], [ 0, %36 ], [ 0, %34 ]
%39 = call i32 @free(i8* %14)
br label %40
40: ; preds = %37, %4
%41 = phi i32 [ %38, %37 ], [ -104, %4 ]
ret i32 %41
}