#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 futimesat(int, char const *, struct timeval *);
int utimensat(int dfd, const char *pathname, const struct timespec times[2],
              int flags) {
  struct timeval tvs[2];
  if (flags) {
  }
  tvs[0].tv_sec = times[0].tv_sec;
  tvs[0].tv_usec = times[0].tv_nsec / 1000;
  tvs[1].tv_sec = times[1].tv_sec;
  tvs[1].tv_usec = times[1].tv_nsec / 1000;
  return futimesat(dfd, pathname, tvs);
}


x86 assembly (clang, -O0):
<utimensat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1135 <utimensat+0x25>
jmp    1135 <utimensat+0x25>
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1030 <futimesat@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<utimensat>:
sub    $0x18,%rsp
mov    0x4(%rdx),%eax
mov    %eax,0x4(%rsp)
movslq (%rdx),%rax
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
mov    %eax,(%rsp)
mov    0xc(%rdx),%eax
mov    %eax,0xc(%rsp)
movslq 0x8(%rdx),%rax
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
mov    %eax,0x8(%rsp)
mov    %rsp,%rdx
call   1030 <futimesat@plt>
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
%struct.timeval = type { i32, i32 }
define i32 @utimensat(i32 %0, i8* %1, %struct.timespec* nocapture %2, i32 %3) {
%5 = alloca [2 x %struct.timeval]
%6 = bitcast [2 x %struct.timeval]* %5 to i8*
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
%8 = load i32, i32* %7
%9 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %5, i64 0, i64 0
%10 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %5, i64 0, i64 0, i32 1
store i32 %8, i32* %10
%11 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
%12 = load i32, i32* %11
%13 = sdiv i32 %12, 1000
%14 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %5, i64 0, i64 0, i32 0
store i32 %13, i32* %14
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 1, i32 1
%16 = load i32, i32* %15
%17 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %5, i64 0, i64 1, i32 1
store i32 %16, i32* %17
%18 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 1, i32 0
%19 = load i32, i32* %18
%20 = sdiv i32 %19, 1000
%21 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %5, i64 0, i64 1, i32 0
store i32 %20, i32* %21
%22 = call i32 @futimesat(i32 %0, i8* %1, %struct.timeval* %9)
ret i32 %22
}