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

/* Variables and functions */
int /*<<< orphan*/ O_RDWR;
int fstat(int, struct stat *);
int /*<<< orphan*/ localtime(int /*<<< orphan*/ *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
void getLastModified(char *pathToFile, char *dest) {
  int fd = open(pathToFile, O_RDWR);
  struct stat fileStat;
  if (fstat(fd, &fileStat) == -1) {
    if (1) {
      printf("getLastModified: Failed to get stats on file.\n");
    }
  } else {
    strftime(dest, 30, "%a, %d %b %Y %H:%M:%S", localtime(&fileStat.st_mtime));
  }
}


x86 assembly (clang, -O0):
<getLastModified>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   1070 <fstat@plt>
cmp    $0xffffffff,%eax
jne    119b <getLastModified+0x4b>
lea    0xe6f(%rip),%rdi
call   1040 <printf@plt>
jmp    11c3 <getLastModified+0x73>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x18(%rbp),%rdi
call   1030 <localtime@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%ecx
mov    $0x1e,%esi
lea    0xe71(%rip),%rdx
call   1050 <strftime@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLastModified>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
lea    0x8(%rsp),%rsi
mov    %eax,%edi
call   1070 <fstat@plt>
cmp    $0xffffffff,%eax
je     119d <getLastModified+0x4d>
lea    0x8(%rsp),%rdi
call   1030 <localtime@plt>
lea    0xe78(%rip),%rdx
mov    %rbx,%rdi
mov    $0x1e,%esi
mov    %eax,%ecx
call   1050 <strftime@plt>
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe72(%rip),%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1040 <puts@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@O_RDWR = global i32 0
@.str = [47 x i8] c"getLastModified: Failed to get stats on file.\0A\00"
@.str.1 = [22 x i8] c"%a, %d %b %Y %H:%M:%S\00"
define void @getLastModified(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca %struct.stat
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = load i32, i32* @O_RDWR
%9 = call i32 @open(i8* %7, i32 %8)
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = call i32 @fstat(i32 %10, %struct.stat* %6)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
br label %20
15: ; preds = %2
%16 = load i8*, i8** %4
%17 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%18 = call i32 @localtime(i32* %17)
%19 = call i32 @strftime(i8* %16, i32 30, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %15, %13
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@O_RDWR = global i32 0
@.str.1 = [22 x i8] c"%a, %d %b %Y %H:%M:%S\00"
@str = [46 x i8] c"getLastModified: Failed to get stats on file.\00"
define void @getLastModified(i8* nocapture %0, i8* %1) {
%3 = alloca %struct.stat
%4 = load i32, i32* @O_RDWR
%5 = tail call i32 @open(i8* %0, i32 %4)
%6 = bitcast %struct.stat* %3 to i8*
%7 = call i32 @fstat(i32 %5, %struct.stat* %3)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
br label %15
11: ; preds = %2
%12 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%13 = call i32 @localtime(i32* %12)
%14 = call i32 @strftime(i8* %1, i32 30, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %11, %9
ret void
}