#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 timeval {
  scalar_t__ tv_usec;
  int /*<<< orphan*/ tv_sec;
};
struct stat {
  int /*<<< orphan*/ st_mtime;
  int /*<<< orphan*/ st_atime;
};

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int utimes(char *, struct timeval *);
void setfiletime(char *dst, char *src) {
  struct timeval tm[2];
  struct stat sb;
  int cc;
  cc = stat(src, &sb);
  if (cc >= 0) {
    tm[0].tv_sec = sb.st_atime;
    tm[0].tv_usec = 0;
    tm[1].tv_sec = sb.st_mtime;
    tm[1].tv_usec = 0;
    cc = utimes(dst, tm);
  }
  if (cc < 0)
    fprintf(stderr, "%s: WARNING: could not set mtime (%s)\n", dst,
            strerror(errno));
}


x86 assembly (clang, -O0):
<setfiletime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1050 <stat@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jl     1196 <setfiletime+0x56>
mov    -0x34(%rbp),%eax
mov    %eax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <utimes@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    11d8 <setfiletime+0x98>
mov    0x2e39(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rdx
mov    %rax,%rcx
lea    0xe2d(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setfiletime>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rax
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
mov    %rax,%rdi
call   1050 <stat@plt>
test   %eax,%eax
js     1197 <setfiletime+0x57>
mov    0x8(%rsp),%eax
mov    0xc(%rsp),%ecx
mov    %ecx,0x18(%rsp)
movq   $0x0,0x10(%rsp)
mov    %eax,0x28(%rsp)
movq   $0x0,0x20(%rsp)
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <utimes@plt>
test   %eax,%eax
js     1197 <setfiletime+0x57>
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e42(%rip),%rax
mov    (%rax),%ebp
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe4b(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
add    $0x38,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
%struct.timeval = type { i64, i32 }
%struct.stat = type { i32, i32 }
@stderr = global i32 0
@.str = [39 x i8] c"%s: WARNING: could not set mtime (%s)\0A\00"
@errno = global i32 0
define void @setfiletime(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [2 x %struct.timeval]
%6 = alloca %struct.stat
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
%9 = call i32 @stat(i8* %8, %struct.stat* %6)
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = icmp sge i32 %10, 0
br i1 %11, label %12, label %28
12: ; preds = %2
%13 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 1
%14 = load i32, i32* %13
%15 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %5, i64 0, i64 0
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 1
store i32 %14, i32* %16
%17 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %5, i64 0, i64 0
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %17, i32 0, i32 0
store i64 0, i64* %18
%19 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%20 = load i32, i32* %19
%21 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %5, i64 0, i64 1
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %21, i32 0, i32 1
store i32 %20, i32* %22
%23 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %5, i64 0, i64 1
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %23, i32 0, i32 0
store i64 0, i64* %24
%25 = load i8*, i8** %3
%26 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %5, i64 0, i64 0
%27 = call i32 @utimes(i8* %25, %struct.timeval* %26)
store i32 %27, i32* %7
br label %28
28: ; preds = %12, %2
%29 = load i32, i32* %7
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %37
31: ; preds = %28
%32 = load i32, i32* @stderr
%33 = load i8*, i8** %3
%34 = load i32, i32* @errno
%35 = call i8* @strerror(i32 %34)
%36 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %33, i8* %35)
br label %37
37: ; preds = %31, %28
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i64, i32 }
%struct.stat = type { i32, i32 }
@stderr = global i32 0
@.str = [39 x i8] c"%s: WARNING: could not set mtime (%s)\0A\00"
@errno = global i32 0
define void @setfiletime(i8* %0, i8* nocapture %1) {
%3 = alloca [2 x %struct.timeval]
%4 = alloca %struct.stat
%5 = bitcast [2 x %struct.timeval]* %3 to i8*
%6 = bitcast %struct.stat* %4 to i8*
%7 = call i32 @stat(i8* %1, %struct.stat* %4)
%8 = icmp sgt i32 %7, -1
br i1 %8, label %9, label %21
9: ; preds = %2
%10 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 1
%11 = load i32, i32* %10
%12 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 0
%13 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 0, i32 1
store i32 %11, i32* %13
%14 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 0, i32 0
store i64 0, i64* %14
%15 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%16 = load i32, i32* %15
%17 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 1, i32 1
store i32 %16, i32* %17
%18 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 1, i32 0
store i64 0, i64* %18
%19 = call i32 @utimes(i8* %0, %struct.timeval* %12)
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %2, %9
%22 = load i32, i32* @stderr
%23 = load i32, i32* @errno
%24 = tail call i8* @strerror(i32 %23)
%25 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %24)
br label %26
26: ; preds = %21, %9
ret void
}