#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 tm {
  int dummy;
};
struct stat {
  scalar_t__ st_mtime;
};
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ _pr_error(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ fileno(int /*<<< orphan*/ *);
scalar_t__ fstat(int /*<<< orphan*/, struct stat *);
int /*<<< orphan*/ localtime_r(scalar_t__ *, struct tm *);
int /*<<< orphan*/ *stdin;
size_t strftime(char *, int, char *, struct tm *);
scalar_t__ time(int /*<<< orphan*/ *);
char const *_do_mtime(FILE *fp, char const *filename) {
  static char buf[18];
  struct stat st;
  struct tm tm;
  if (fp == stdin)
    st.st_mtime = time(NULL);
  else if (fstat(fileno(fp), &st) != 0) {
    st.st_mtime = 0;
    _pr_error(filename, 0);
  }
  localtime_r(&st.st_mtime, &tm);
  buf[strftime(buf, sizeof(buf), "%b %e %H:%M %Y", &tm)] = '\0';
  return buf;
}


x86 assembly (clang, -O0):
<_do_mtime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2e6d(%rip),%rcx
cmp    (%rcx),%rax
jne    1196 <_do_mtime+0x36>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %rax,-0x18(%rbp)
jmp    11cc <_do_mtime+0x6c>
mov    -0x8(%rbp),%rdi
call   1050 <fileno@plt>
mov    %eax,%edi
lea    -0x18(%rbp),%rsi
call   1080 <fstat@plt>
cmp    $0x0,%rax
je     11c7 <_do_mtime+0x67>
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1070 <_pr_error@plt>
jmp    11cc <_do_mtime+0x6c>
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <localtime_r@plt>
lea    0x2e80(%rip),%rdi
mov    $0x12,%esi
lea    0xe14(%rip),%rdx
lea    -0x20(%rbp),%rcx
call   1060 <strftime@plt>
mov    %rax,%rcx
lea    0x2e61(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e56(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_do_mtime>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2e7a(%rip),%rax
cmp    %rdi,(%rax)
je     11a1 <_do_mtime+0x41>
mov    %rsi,%rbx
call   1050 <fileno@plt>
lea    0x8(%rsp),%rsi
mov    %eax,%edi
call   1080 <fstat@plt>
test   %rax,%rax
je     11ad <_do_mtime+0x4d>
movq   $0x0,0x8(%rsp)
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <_pr_error@plt>
jmp    11ad <_do_mtime+0x4d>
xor    %edi,%edi
call   1040 <time@plt>
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%r14
mov    %r14,%rsi
call   1030 <localtime_r@plt>
lea    0x2e9a(%rip),%rbx
lea    0xe33(%rip),%rdx
mov    %rbx,%rdi
mov    $0x12,%esi
mov    %r14,%rcx
call   1060 <strftime@plt>
movb   $0x0,(%rax,%rbx,1)
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.stat = type { i64 }
%struct.tm = type { i32 }
@_do_mtime.buf = internal global [18 x i8] zeroinitializer
@stdin = global i32* null
@.str = [15 x i8] c"%b %e %H:%M %Y\00"
define i8* @_do_mtime(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca %struct.stat
%6 = alloca %struct.tm
store i32* %0, i32** %3
store i8* %1, i8** %4
%7 = load i32*, i32** %3
%8 = load i32*, i32** @stdin
%9 = icmp eq i32* %7, %8
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = call i64 @time(i32* null)
%12 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
store i64 %11, i64* %12
br label %23
13: ; preds = %2
%14 = load i32*, i32** %3
%15 = call i32 @fileno(i32* %14)
%16 = call i64 @fstat(i32 %15, %struct.stat* %5)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %13
%19 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
store i64 0, i64* %19
%20 = load i8*, i8** %4
%21 = call i32 @_pr_error(i8* %20, i32 0)
br label %22
22: ; preds = %18, %13
br label %23
23: ; preds = %22, %10
%24 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%25 = call i32 @localtime_r(i64* %24, %struct.tm* %6)
%26 = call i64 @strftime(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @_do_mtime.buf, i64 0, i64 0), i32 18, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), %struct.tm* %6)
%27 = getelementptr inbounds [18 x i8], [18 x i8]* @_do_mtime.buf, i64 0, i64 %26
store i8 0, i8* %27
ret i8* getelementptr inbounds ([18 x i8], [18 x i8]* @_do_mtime.buf, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.stat = type { i64 }
%struct.tm = type { i32 }
@_do_mtime.buf = internal global [18 x i8] zeroinitializer
@stdin = global i32* null
@.str = [15 x i8] c"%b %e %H:%M %Y\00"
define i8* @_do_mtime(i32* nocapture %0, i8* %1) {
%3 = alloca %struct.stat
%4 = alloca %struct.tm
%5 = bitcast %struct.stat* %3 to i8*
%6 = bitcast %struct.tm* %4 to i8*
%7 = load i32*, i32** @stdin
%8 = icmp eq i32* %7, %0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = tail call i64 @time(i32* null)
%11 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
store i64 %10, i64* %11
br label %19
12: ; preds = %2
%13 = tail call i32 @fileno(i32* %0)
%14 = call i64 @fstat(i32 %13, %struct.stat* %3)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
store i64 0, i64* %17
%18 = tail call i32 @_pr_error(i8* %1, i32 0)
br label %19
19: ; preds = %12, %16, %9
%20 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%21 = call i32 @localtime_r(i64* %20, %struct.tm* %4)
%22 = call i64 @strftime(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @_do_mtime.buf, i64 0, i64 0), i32 18, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), %struct.tm* %4)
%23 = getelementptr inbounds [18 x i8], [18 x i8]* @_do_mtime.buf, i64 0, i64 %22
store i8 0, i8* %23
ret i8* getelementptr inbounds ([18 x i8], [18 x i8]* @_do_mtime.buf, i64 0, i64 0)
}