#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 timespec {
  int dummy;
};
struct stat {
  struct timespec st_mtim;
  struct timespec st_atim;
};

/* Variables and functions */
int /*<<< orphan*/ AT_FDCWD;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error(int, int /*<<< orphan*/, char *);
scalar_t__ utimensat(int /*<<< orphan*/, char const *, struct timespec *,
                     int /*<<< orphan*/);
void fix_time(const char *path, struct stat *sb) {
  struct timespec times[] = {sb->st_atim, sb->st_mtim};
  if (utimensat(AT_FDCWD, path, times, 0))
    error(1, errno, "utimes");
}


x86 assembly (clang, -O0):
<fix_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
lea    -0x18(%rbp),%rdx
xor    %ecx,%ecx
call   1030 <utimensat@plt>
cmp    $0x0,%rax
je     117f <fix_time+0x5f>
mov    0x2e74(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xe86(%rip),%rdx
call   1040 <error@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fix_time>:
push   %rax
mov    %rdi,%rax
mov    0x4(%rsi),%ecx
mov    %ecx,(%rsp)
mov    (%rsi),%ecx
mov    %ecx,0x4(%rsp)
mov    0x2e99(%rip),%rcx
mov    (%rcx),%edi
mov    %rsp,%rdx
mov    %rax,%rsi
xor    %ecx,%ecx
call   1030 <utimensat@plt>
test   %rax,%rax
je     1165 <fix_time+0x45>
mov    0x2e8e(%rip),%rax
mov    (%rax),%esi
lea    0xea5(%rip),%rdx
mov    $0x1,%edi
call   1040 <error@plt>
pop    %rax
ret

LLVM IR (-O0):
%struct.stat = type { %struct.timespec, %struct.timespec }
%struct.timespec = type { i32 }
@AT_FDCWD = global i32 0
@errno = global i32 0
@.str = [7 x i8] c"utimes\00"
define void @fix_time(i8* %0, %struct.stat* %1) {
%3 = alloca i8*
%4 = alloca %struct.stat*
%5 = alloca [2 x %struct.timespec]
store i8* %0, i8** %3
store %struct.stat* %1, %struct.stat** %4
%6 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %5, i64 0, i64 0
%7 = load %struct.stat*, %struct.stat** %4
%8 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 1
%9 = bitcast %struct.timespec* %6 to i8*
%10 = bitcast %struct.timespec* %8 to i8*
%11 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 1
%12 = load %struct.stat*, %struct.stat** %4
%13 = getelementptr inbounds %struct.stat, %struct.stat* %12, i32 0, i32 0
%14 = bitcast %struct.timespec* %11 to i8*
%15 = bitcast %struct.timespec* %13 to i8*
%16 = load i32, i32* @AT_FDCWD
%17 = load i8*, i8** %3
%18 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %5, i64 0, i64 0
%19 = call i64 @utimensat(i32 %16, i8* %17, %struct.timespec* %18, i32 0)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %2
%22 = load i32, i32* @errno
%23 = call i32 @error(i32 1, i32 %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %21, %2
ret void
}

LLVM IR (-O2):
%struct.stat = type { %struct.timespec, %struct.timespec }
%struct.timespec = type { i32 }
@AT_FDCWD = global i32 0
@errno = global i32 0
@.str = [7 x i8] c"utimes\00"
define void @fix_time(i8* %0, %struct.stat* nocapture %1) {
%3 = alloca [2 x %struct.timespec]
%4 = bitcast [2 x %struct.timespec]* %3 to i8*
%5 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %3, i64 0, i64 0
%6 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 1, i32 0
%7 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %3, i64 0, i64 0, i32 0
%8 = load i32, i32* %6
store i32 %8, i32* %7
%9 = getelementptr %struct.stat, %struct.stat* %1, i64 0, i32 0, i32 0
%10 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %3, i64 0, i64 1, i32 0
%11 = load i32, i32* %9
store i32 %11, i32* %10
%12 = load i32, i32* @AT_FDCWD
%13 = call i64 @utimensat(i32 %12, i8* %0, %struct.timespec* %5, i32 0)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %2
%16 = load i32, i32* @errno
%17 = call i32 @error(i32 1, i32 %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %15, %2
ret void
}