#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 */
typedef struct TYPE_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct timeval {
  int tv_usec;
  int /*<<< orphan*/ tv_sec;
};
struct TYPE_4__ {
  int tv_nsec;
};
struct TYPE_3__ {
  int tv_nsec;
};
struct stat {
  TYPE_2__ st_mtim;
  TYPE_1__ st_atim;
  int /*<<< orphan*/ st_mtime;
  int /*<<< orphan*/ st_atime;
};

/* Variables and functions */
int utimes(char const *, struct timeval *);
int settimes(const char *path, const struct stat *st) {
  struct timeval tv[2];
  tv[0].tv_sec = st->st_atime;
  tv[1].tv_sec = st->st_mtime;
  tv[0].tv_usec = st->st_atim.tv_nsec / 1000;
  tv[1].tv_usec = st->st_mtim.tv_nsec / 1000;
  return utimes(path, tv);
}


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

x86 assembly (clang, -O2):
<settimes>:
sub    $0x18,%rsp
mov    0xc(%rsi),%eax
mov    %eax,0x4(%rsp)
mov    0x8(%rsi),%eax
mov    %eax,0xc(%rsp)
movslq 0x4(%rsi),%rax
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
mov    %eax,(%rsp)
movslq (%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 <utimes@plt>
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
%struct.stat = type { %struct.TYPE_4__, %struct.TYPE_3__, i32, i32 }
%struct.TYPE_4__ = type { i32 }
%struct.TYPE_3__ = type { i32 }
%struct.timeval = type { i32, i32 }
define i32 @settimes(i8* nocapture %0, %struct.stat* nocapture %1) {
%3 = alloca [2 x %struct.timeval]
%4 = bitcast [2 x %struct.timeval]* %3 to i8*
%5 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 3
%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.stat, %struct.stat* %1, i64 0, i32 2
%10 = load i32, i32* %9
%11 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 1, i32 1
store i32 %10, i32* %11
%12 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 1, i32 0
%13 = load i32, i32* %12
%14 = sdiv i32 %13, 1000
%15 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 0, i32 0
store i32 %14, i32* %15
%16 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0, 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 @utimes(i8* %0, %struct.timeval* %7)
ret i32 %20
}