#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 {
  int tv_usec;
  int /*<<< orphan*/ tv_sec;
};
struct timespec {
  int tv_nsec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ AT_FDCWD;
int /*<<< orphan*/ AT_SYMLINK_NOFOLLOW;
int utimensat(int /*<<< orphan*/, char const *, struct timespec *,
              int /*<<< orphan*/);
int lutimes(const char *filename, const struct timeval tv[2]) {
  struct timespec times[2];
  if (tv) {
    times[0].tv_sec = tv[0].tv_sec;
    times[0].tv_nsec = tv[0].tv_usec * 1000;
    times[1].tv_sec = tv[1].tv_sec;
    times[1].tv_nsec = tv[1].tv_usec * 1000;
  }
  return utimensat(AT_FDCWD, filename, tv ? times : 0, AT_SYMLINK_NOFOLLOW);
}


x86 assembly (clang, -O0):
<lutimes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     115a <lutimes+0x4a>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
imul   $0x3e8,(%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
imul   $0x3e8,0x8(%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e6f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1186 <lutimes+0x76>
lea    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1191 <lutimes+0x81>
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
jmp    1191 <lutimes+0x81>
mov    -0x28(%rbp),%rsi
mov    -0x2c(%rbp),%edi
mov    -0x38(%rbp),%rdx
mov    0x2e3d(%rip),%rax
mov    (%rax),%ecx
call   1030 <utimensat@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lutimes>:
sub    $0x18,%rsp
mov    %rdi,%rax
test   %rsi,%rsi
je     113e <lutimes+0x2e>
mov    0x4(%rsi),%ecx
mov    %ecx,0x4(%rsp)
imul   $0x3e8,(%rsi),%ecx
mov    %ecx,(%rsp)
mov    0xc(%rsi),%ecx
mov    %ecx,0xc(%rsp)
imul   $0x3e8,0x8(%rsi),%ecx
mov    %ecx,0x8(%rsp)
test   %rsi,%rsi
mov    0x2e88(%rip),%rcx
mov    (%rcx),%edi
mov    %rsp,%rdx
cmove  %rsi,%rdx
mov    0x2e88(%rip),%rcx
mov    (%rcx),%ecx
mov    %rax,%rsi
call   1030 <utimensat@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
%struct.timespec = type { i32, i32 }
@AT_FDCWD = global i32 0
@AT_SYMLINK_NOFOLLOW = global i32 0
define i32 @lutimes(i8* %0, %struct.timeval* %1) {
%3 = alloca i8*
%4 = alloca %struct.timeval*
%5 = alloca [2 x %struct.timespec]
store i8* %0, i8** %3
store %struct.timeval* %1, %struct.timeval** %4
%6 = load %struct.timeval*, %struct.timeval** %4
%7 = icmp ne %struct.timeval* %6, null
br i1 %7, label %8, label %35
8: ; preds = %2
%9 = load %struct.timeval*, %struct.timeval** %4
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i64 0
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 1
%12 = load i32, i32* %11
%13 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %5, i64 0, i64 0
%14 = getelementptr inbounds %struct.timespec, %struct.timespec* %13, i32 0, i32 1
store i32 %12, i32* %14
%15 = load %struct.timeval*, %struct.timeval** %4
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i64 0
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = mul nsw i32 %18, 1000
%20 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %5, i64 0, i64 0
%21 = getelementptr inbounds %struct.timespec, %struct.timespec* %20, i32 0, i32 0
store i32 %19, i32* %21
%22 = load %struct.timeval*, %struct.timeval** %4
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %22, i64 1
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %23, i32 0, i32 1
%25 = load i32, i32* %24
%26 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %5, i64 0, i64 1
%27 = getelementptr inbounds %struct.timespec, %struct.timespec* %26, i32 0, i32 1
store i32 %25, i32* %27
%28 = load %struct.timeval*, %struct.timeval** %4
%29 = getelementptr inbounds %struct.timeval, %struct.timeval* %28, i64 1
%30 = getelementptr inbounds %struct.timeval, %struct.timeval* %29, i32 0, i32 0
%31 = load i32, i32* %30
%32 = mul nsw i32 %31, 1000
%33 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %5, i64 0, i64 1
%34 = getelementptr inbounds %struct.timespec, %struct.timespec* %33, i32 0, i32 0
store i32 %32, i32* %34
br label %35
35: ; preds = %8, %2
%36 = load i32, i32* @AT_FDCWD
%37 = load i8*, i8** %3
%38 = load %struct.timeval*, %struct.timeval** %4
%39 = icmp ne %struct.timeval* %38, null
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %5, i64 0, i64 0
br label %43
42: ; preds = %35
br label %43
43: ; preds = %42, %40
%44 = phi %struct.timespec* [ %41, %40 ], [ null, %42 ]
%45 = load i32, i32* @AT_SYMLINK_NOFOLLOW
%46 = call i32 @utimensat(i32 %36, i8* %37, %struct.timespec* %44, i32 %45)
ret i32 %46
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
%struct.timespec = type { i32, i32 }
@AT_FDCWD = global i32 0
@AT_SYMLINK_NOFOLLOW = global i32 0
define i32 @lutimes(i8* %0, %struct.timeval* %1) {
%3 = alloca [2 x %struct.timespec]
%4 = bitcast [2 x %struct.timespec]* %3 to i8*
%5 = icmp eq %struct.timeval* %1, null
br i1 %5, label %21, label %6
6: ; preds = %2
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%8 = load i32, i32* %7
%9 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %3, i64 0, i64 0, i32 1
store i32 %8, i32* %9
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%11 = load i32, i32* %10
%12 = mul nsw i32 %11, 1000
%13 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %3, i64 0, i64 0, i32 0
store i32 %12, i32* %13
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 1, i32 1
%15 = load i32, i32* %14
%16 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %3, i64 0, i64 1, i32 1
store i32 %15, i32* %16
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 1, i32 0
%18 = load i32, i32* %17
%19 = mul nsw i32 %18, 1000
%20 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %3, i64 0, i64 1, i32 0
store i32 %19, i32* %20
br label %21
21: ; preds = %6, %2
%22 = load i32, i32* @AT_FDCWD
%23 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %3, i64 0, i64 0
%24 = select i1 %5, %struct.timespec* null, %struct.timespec* %23
%25 = load i32, i32* @AT_SYMLINK_NOFOLLOW
%26 = call i32 @utimensat(i32 %22, i8* %0, %struct.timespec* %24, i32 %25)
ret i32 %26
}