#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 utimensat(int /*<<< orphan*/, char const *, struct timespec *,
              int /*<<< orphan*/);
int utimes(const char *file, const struct timeval tvp[2]) {
  struct timespec ts[2];
  if (tvp) {
    ts->tv_sec = tvp->tv_sec;
    ts->tv_nsec = tvp->tv_usec * 1000;
  }
  return utimensat(AT_FDCWD, file, &ts[0], 0);
}


x86 assembly (clang, -O0):
<utimes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1142 <utimes+0x32>
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    0x2e8f(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
lea    -0x20(%rbp),%rdx
xor    %ecx,%ecx
call   1030 <utimensat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<utimes>:
sub    $0x18,%rsp
mov    %rdi,%rax
test   %rsi,%rsi
je     112c <utimes+0x1c>
mov    0x4(%rsi),%ecx
mov    %ecx,0x4(%rsp)
imul   $0x3e8,(%rsi),%ecx
mov    %ecx,(%rsp)
mov    0x2ea5(%rip),%rcx
mov    (%rcx),%edi
mov    %rsp,%rdx
mov    %rax,%rsi
xor    %ecx,%ecx
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
define i32 @utimes(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 %20
8: ; preds = %2
%9 = load %struct.timeval*, %struct.timeval** %4
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 1
%11 = load i32, i32* %10
%12 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %5, i64 0, i64 0
%13 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i32 0, i32 1
store i32 %11, i32* %13
%14 = load %struct.timeval*, %struct.timeval** %4
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = mul nsw i32 %16, 1000
%18 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %5, i64 0, i64 0
%19 = getelementptr inbounds %struct.timespec, %struct.timespec* %18, i32 0, i32 0
store i32 %17, i32* %19
br label %20
20: ; preds = %8, %2
%21 = load i32, i32* @AT_FDCWD
%22 = load i8*, i8** %3
%23 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %5, i64 0, i64 0
%24 = call i32 @utimensat(i32 %21, i8* %22, %struct.timespec* %23, i32 0)
ret i32 %24
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
%struct.timespec = type { i32, i32 }
@AT_FDCWD = global i32 0
define i32 @utimes(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 %14, 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
br label %14
14: ; preds = %6, %2
%15 = load i32, i32* @AT_FDCWD
%16 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %3, i64 0, i64 0
%17 = call i32 @utimensat(i32 %15, i8* %0, %struct.timespec* %16, i32 0)
ret i32 %17
}