#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 futimes(int, struct timeval *);
int futimens(int fd, const struct timespec ts[2]) {
  struct timeval tv[2];
  tv[0].tv_sec = ts[0].tv_sec;
  tv[0].tv_usec = ts[0].tv_nsec / 1000;
  tv[1].tv_sec = ts[1].tv_sec;
  tv[1].tv_usec = ts[1].tv_nsec / 1000;
  return (futimes(fd, tv));
}


x86 assembly (clang, -O0):
<futimens>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1030 <futimes@plt>
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
%struct.timeval = type { i32, i32 }
define i32 @futimens(i32 %0, %struct.timespec* %1) {
%3 = alloca i32
%4 = alloca %struct.timespec*
%5 = alloca [2 x %struct.timeval]
store i32 %0, i32* %3
store %struct.timespec* %1, %struct.timespec** %4
%6 = load %struct.timespec*, %struct.timespec** %4
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 1
%9 = load i32, i32* %8
%10 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %5, i64 0, i64 0
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 1
store i32 %9, i32* %11
%12 = load %struct.timespec*, %struct.timespec** %4
%13 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i64 0
%14 = getelementptr inbounds %struct.timespec, %struct.timespec* %13, i32 0, i32 0
%15 = load i32, i32* %14
%16 = sdiv i32 %15, 1000
%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 i32 %16, i32* %18
%19 = load %struct.timespec*, %struct.timespec** %4
%20 = getelementptr inbounds %struct.timespec, %struct.timespec* %19, i64 1
%21 = getelementptr inbounds %struct.timespec, %struct.timespec* %20, i32 0, i32 1
%22 = load i32, i32* %21
%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 1
store i32 %22, i32* %24
%25 = load %struct.timespec*, %struct.timespec** %4
%26 = getelementptr inbounds %struct.timespec, %struct.timespec* %25, i64 1
%27 = getelementptr inbounds %struct.timespec, %struct.timespec* %26, i32 0, i32 0
%28 = load i32, i32* %27
%29 = sdiv i32 %28, 1000
%30 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %5, i64 0, i64 1
%31 = getelementptr inbounds %struct.timeval, %struct.timeval* %30, i32 0, i32 0
store i32 %29, i32* %31
%32 = load i32, i32* %3
%33 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %5, i64 0, i64 0
%34 = call i32 @futimes(i32 %32, %struct.timeval* %33)
ret i32 %34
}

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