#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 futimens(int, struct timespec *);
int futimes(int fd, const struct timeval tv[2]) {
  struct timespec times[2];
  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 futimens(fd, times);
}


x86 assembly (clang, -O0):
<futimes>:
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
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    -0x4(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1030 <futimens@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<futimes>:
sub    $0x18,%rsp
mov    0x4(%rsi),%eax
mov    %eax,0x4(%rsp)
imul   $0x3e8,(%rsi),%eax
mov    %eax,(%rsp)
mov    0xc(%rsi),%eax
mov    %eax,0xc(%rsp)
imul   $0x3e8,0x8(%rsi),%eax
mov    %eax,0x8(%rsp)
mov    %rsp,%rsi
call   1030 <futimens@plt>
add    $0x18,%rsp
ret

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

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