#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 tm {
  int tm_year;
  int tm_mon;
  int tm_mday;
  int tm_hour;
  int /*<<< orphan*/ tm_sec;
  int /*<<< orphan*/ tm_min;
};
struct stat {
  int /*<<< orphan*/ st_mtime;
};

/* Variables and functions */
scalar_t__ Ftest(char *);
int /*<<< orphan*/ free(char *);
struct tm *localtime(int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stat(char *, struct stat *);
int /*<<< orphan*/ tprintf(char *, char *, ...);
time_t Fdatetime_t(char *filename, int debug) {
  struct tm *ptr_ts;
  struct stat b;
  char *datetime;
  if (Ftest(filename) != 0) {
    if (debug)
      tprintf("File %s: does not exist\n", filename);
    return (0);
  } else if (!stat(filename, &b)) {
    ptr_ts = localtime(&b.st_mtime);
    datetime = (char *)malloc(16 * sizeof(char));
    sprintf(datetime, "%4d%02d%02d-%02d%02d%02d", ptr_ts->tm_year + 1900,
            ptr_ts->tm_mon + 1, ptr_ts->tm_mday, ptr_ts->tm_hour,
            ptr_ts->tm_min, ptr_ts->tm_sec);
    if (debug)
      tprintf("File %s: last modified at %s\n", filename, datetime);
    free(datetime);
    return (b.st_mtime);
  } else {
    if (debug)
      printf("File %s: cannot display the time\n", filename);
    return (0);
  }
}


x86 assembly (clang, -O0):
<Fdatetime_t>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <Ftest@plt>
cmp    $0x0,%rax
je     11ca <Fdatetime_t+0x4a>
cmpl   $0x0,-0x14(%rbp)
je     11be <Fdatetime_t+0x3e>
mov    -0x10(%rbp),%rsi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1070 <tprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    129d <Fdatetime_t+0x11d>
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1080 <stat@plt>
cmp    $0x0,%eax
jne    127c <Fdatetime_t+0xfc>
lea    -0x28(%rbp),%rdi
call   1040 <localtime@plt>
mov    %rax,-0x20(%rbp)
mov    $0x10,%edi
call   1090 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
add    $0x76c,%edx
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%r8d
mov    -0x20(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x20(%rbp),%rax
mov    0x14(%rax),%r10d
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%eax
lea    0xdde(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   10a0 <sprintf@plt>
cmpl   $0x0,-0x14(%rbp)
je     1268 <Fdatetime_t+0xe8>
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1070 <tprintf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    129d <Fdatetime_t+0x11d>
cmpl   $0x0,-0x14(%rbp)
je     1296 <Fdatetime_t+0x116>
mov    -0x10(%rbp),%rsi
lea    0xdbf(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Fdatetime_t>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%rbx
call   1060 <Ftest@plt>
test   %rax,%rax
je     11b4 <Fdatetime_t+0x34>
test   %r15d,%r15d
je     11df <Fdatetime_t+0x5f>
lea    0xe5d(%rip),%rdi
xor    %ebp,%ebp
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <tprintf@plt>
jmp    1250 <Fdatetime_t+0xd0>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1080 <stat@plt>
test   %eax,%eax
je     11e3 <Fdatetime_t+0x63>
xor    %ebp,%ebp
test   %r15d,%r15d
je     1250 <Fdatetime_t+0xd0>
lea    0xe7b(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
jmp    1250 <Fdatetime_t+0xd0>
xor    %ebp,%ebp
jmp    1250 <Fdatetime_t+0xd0>
mov    %rsp,%rdi
call   1040 <localtime@plt>
mov    %rax,%rbp
mov    $0x10,%edi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    $0x76c,%edx
add    0x0(%rbp),%edx
mov    0x4(%rbp),%ecx
mov    0x8(%rbp),%r8d
add    $0x1,%ecx
mov    0xc(%rbp),%r9d
mov    0x14(%rbp),%eax
mov    0x10(%rbp),%ebp
lea    0xdfb(%rip),%rsi
mov    %r14,%rdi
push   %rbp
push   %rax
call   10a0 <sprintf@plt>
add    $0x10,%rsp
test   %r15d,%r15d
je     1245 <Fdatetime_t+0xc5>
lea    0xdfa(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1070 <tprintf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    (%rsp),%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
%struct.stat = type { i32 }
@.str = [25 x i8] c"File %s: does not exist\0A\00"
@.str.1 = [25 x i8] c"%4d%02d%02d-%02d%02d%02d\00"
@.str.2 = [30 x i8] c"File %s: last modified at %s\0A\00"
@.str.3 = [34 x i8] c"File %s: cannot display the time\0A\00"
define i32 @Fdatetime_t(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca %struct.tm*
%7 = alloca %struct.stat
%8 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
%9 = load i8*, i8** %4
%10 = call i64 @Ftest(i8* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = load i32, i32* %5
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i8*, i8** %4
%17 = call i32 (i8*, i8*, ...) @tprintf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %15, %12
store i32 0, i32* %3
br label %68
19: ; preds = %2
%20 = load i8*, i8** %4
%21 = call i32 @stat(i8* %20, %struct.stat* %7)
%22 = icmp ne i32 %21, 0
br i1 %22, label %61, label %23
23: ; preds = %19
%24 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%25 = call %struct.tm* @localtime(i32* %24)
store %struct.tm* %25, %struct.tm** %6
%26 = call i64 @malloc(i32 16)
%27 = inttoptr i64 %26 to i8*
store i8* %27, i8** %8
%28 = load i8*, i8** %8
%29 = load %struct.tm*, %struct.tm** %6
%30 = getelementptr inbounds %struct.tm, %struct.tm* %29, i32 0, i32 0
%31 = load i32, i32* %30
%32 = add nsw i32 %31, 1900
%33 = load %struct.tm*, %struct.tm** %6
%34 = getelementptr inbounds %struct.tm, %struct.tm* %33, i32 0, i32 1
%35 = load i32, i32* %34
%36 = add nsw i32 %35, 1
%37 = load %struct.tm*, %struct.tm** %6
%38 = getelementptr inbounds %struct.tm, %struct.tm* %37, i32 0, i32 2
%39 = load i32, i32* %38
%40 = load %struct.tm*, %struct.tm** %6
%41 = getelementptr inbounds %struct.tm, %struct.tm* %40, i32 0, i32 3
%42 = load i32, i32* %41
%43 = load %struct.tm*, %struct.tm** %6
%44 = getelementptr inbounds %struct.tm, %struct.tm* %43, i32 0, i32 5
%45 = load i32, i32* %44
%46 = load %struct.tm*, %struct.tm** %6
%47 = getelementptr inbounds %struct.tm, %struct.tm* %46, i32 0, i32 4
%48 = load i32, i32* %47
%49 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %32, i32 %36, i32 %39, i32 %42, i32 %45, i32 %48)
%50 = load i32, i32* %5
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %56
52: ; preds = %23
%53 = load i8*, i8** %4
%54 = load i8*, i8** %8
%55 = call i32 (i8*, i8*, ...) @tprintf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %53, i8* %54)
br label %56
56: ; preds = %52, %23
%57 = load i8*, i8** %8
%58 = call i32 @free(i8* %57)
%59 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%60 = load i32, i32* %59
store i32 %60, i32* %3
br label %68
61: ; preds = %19
%62 = load i32, i32* %5
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %61
%65 = load i8*, i8** %4
%66 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %65)
br label %67
67: ; preds = %64, %61
store i32 0, i32* %3
br label %68
68: ; preds = %67, %56, %18
%69 = load i32, i32* %3
ret i32 %69
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [25 x i8] c"File %s: does not exist\0A\00"
@.str.1 = [25 x i8] c"%4d%02d%02d-%02d%02d%02d\00"
@.str.2 = [30 x i8] c"File %s: last modified at %s\0A\00"
@.str.3 = [34 x i8] c"File %s: cannot display the time\0A\00"
define i32 @Fdatetime_t(i8* %0, i32 %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = tail call i64 @Ftest(i8* %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %2
%8 = icmp eq i32 %1, 0
br i1 %8, label %44, label %9
9: ; preds = %7
%10 = tail call i32 (i8*, i8*, ...) @tprintf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %44
11: ; preds = %2
%12 = call i32 @stat(i8* %0, %struct.stat* %3)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %40
14: ; preds = %11
%15 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%16 = call %struct.tm* @localtime(i32* %15)
%17 = call i64 @malloc(i32 16)
%18 = inttoptr i64 %17 to i8*
%19 = getelementptr inbounds %struct.tm, %struct.tm* %16, i64 0, i32 0
%20 = load i32, i32* %19
%21 = add nsw i32 %20, 1900
%22 = getelementptr inbounds %struct.tm, %struct.tm* %16, i64 0, i32 1
%23 = load i32, i32* %22
%24 = add nsw i32 %23, 1
%25 = getelementptr inbounds %struct.tm, %struct.tm* %16, i64 0, i32 2
%26 = load i32, i32* %25
%27 = getelementptr inbounds %struct.tm, %struct.tm* %16, i64 0, i32 3
%28 = load i32, i32* %27
%29 = getelementptr inbounds %struct.tm, %struct.tm* %16, i64 0, i32 5
%30 = load i32, i32* %29
%31 = getelementptr inbounds %struct.tm, %struct.tm* %16, i64 0, i32 4
%32 = load i32, i32* %31
%33 = call i32 @sprintf(i8* dereferenceable(1) %18, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %24, i32 %26, i32 %28, i32 %30, i32 %32)
%34 = icmp eq i32 %1, 0
br i1 %34, label %37, label %35
35: ; preds = %14
%36 = call i32 (i8*, i8*, ...) @tprintf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %18)
br label %37
37: ; preds = %35, %14
%38 = call i32 @free(i8* %18)
%39 = load i32, i32* %15
br label %44
40: ; preds = %11
%41 = icmp eq i32 %1, 0
br i1 %41, label %44, label %42
42: ; preds = %40
%43 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %44
44: ; preds = %40, %42, %7, %9, %37
%45 = phi i32 [ %39, %37 ], [ 0, %9 ], [ 0, %7 ], [ 0, %42 ], [ 0, %40 ]
ret i32 %45
}