#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 utimbuf {
  int /*<<< orphan*/ modtime;
  int /*<<< orphan*/ actime;
};
struct timespec {
  void *tv_nsec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ AT_FDCWD;
void *UTIME_NOW;
int utimensat(int /*<<< orphan*/, char const *, struct timespec *,
              int /*<<< orphan*/);
int utime(const char *path, const struct utimbuf *times) {
  struct timespec ts[2];
  if (times) {
    ts[0].tv_sec = times->actime;
    ts[0].tv_nsec = 0;
    ts[1].tv_sec = times->modtime;
    ts[1].tv_nsec = 0;
  } else {
    ts[0].tv_nsec = UTIME_NOW;
    ts[1].tv_nsec = UTIME_NOW;
  }
  return utimensat(AT_FDCWD, path, ts, 0);
}


x86 assembly (clang, -O0):
<utime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1153 <utime+0x43>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
jmp    116f <utime+0x5f>
mov    0x2e9e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    0x2e90(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
lea    -0x30(%rbp),%rdx
xor    %ecx,%ecx
call   1030 <utimensat@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<utime>:
sub    $0x28,%rsp
mov    %rdi,%rax
test   %rsi,%rsi
je     112d <utime+0x1d>
mov    0x4(%rsi),%ecx
mov    %ecx,0x8(%rsp)
mov    (%rsi),%ecx
mov    %ecx,0x18(%rsp)
xor    %ecx,%ecx
jmp    1137 <utime+0x27>
mov    0x2ec4(%rip),%rcx
mov    (%rcx),%rcx
mov    %rcx,(%rsp)
mov    %rcx,0x10(%rsp)
mov    0x2e89(%rip),%rcx
mov    (%rcx),%edi
mov    %rsp,%rdx
mov    %rax,%rsi
xor    %ecx,%ecx
call   1030 <utimensat@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.utimbuf = type { i32, i32 }
%struct.timespec = type { i8*, i32 }
@UTIME_NOW = global i8* null
@AT_FDCWD = global i32 0
define i32 @utime(i8* %0, %struct.utimbuf* %1) {
%3 = alloca i8*
%4 = alloca %struct.utimbuf*
%5 = alloca [2 x %struct.timespec]
store i8* %0, i8** %3
store %struct.utimbuf* %1, %struct.utimbuf** %4
%6 = load %struct.utimbuf*, %struct.utimbuf** %4
%7 = icmp ne %struct.utimbuf* %6, null
br i1 %7, label %8, label %23
8: ; preds = %2
%9 = load %struct.utimbuf*, %struct.utimbuf** %4
%10 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %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 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %5, i64 0, i64 0
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %14, i32 0, i32 0
store i8* null, i8** %15
%16 = load %struct.utimbuf*, %struct.utimbuf** %4
%17 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %5, i64 0, i64 1
%20 = getelementptr inbounds %struct.timespec, %struct.timespec* %19, i32 0, i32 1
store i32 %18, i32* %20
%21 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %5, i64 0, i64 1
%22 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 0
store i8* null, i8** %22
br label %30
23: ; preds = %2
%24 = load i8*, i8** @UTIME_NOW
%25 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %5, i64 0, i64 0
%26 = getelementptr inbounds %struct.timespec, %struct.timespec* %25, i32 0, i32 0
store i8* %24, i8** %26
%27 = load i8*, i8** @UTIME_NOW
%28 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %5, i64 0, i64 1
%29 = getelementptr inbounds %struct.timespec, %struct.timespec* %28, i32 0, i32 0
store i8* %27, i8** %29
br label %30
30: ; preds = %23, %8
%31 = load i32, i32* @AT_FDCWD
%32 = load i8*, i8** %3
%33 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %5, i64 0, i64 0
%34 = call i32 @utimensat(i32 %31, i8* %32, %struct.timespec* %33, i32 0)
ret i32 %34
}

LLVM IR (-O2):
%struct.utimbuf = type { i32, i32 }
%struct.timespec = type { i8*, i32 }
@UTIME_NOW = global i8* null
@AT_FDCWD = global i32 0
define i32 @utime(i8* %0, %struct.utimbuf* %1) {
%3 = alloca [2 x %struct.timespec]
%4 = bitcast [2 x %struct.timespec]* %3 to i8*
%5 = icmp eq %struct.utimbuf* %1, null
br i1 %5, label %13, label %6
6: ; preds = %2
%7 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %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.utimbuf, %struct.utimbuf* %1, i64 0, i32 0
%11 = load i32, i32* %10
%12 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %3, i64 0, i64 1, i32 1
store i32 %11, i32* %12
br label %15
13: ; preds = %2
%14 = load i8*, i8** @UTIME_NOW
br label %15
15: ; preds = %13, %6
%16 = phi i8* [ %14, %13 ], [ null, %6 ]
%17 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %3, i64 0, i64 0, i32 0
store i8* %16, i8** %17
%18 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %3, i64 0, i64 1, i32 0
store i8* %16, i8** %18
%19 = load i32, i32* @AT_FDCWD
%20 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %3, i64 0, i64 0
%21 = call i32 @utimensat(i32 %19, i8* %0, %struct.timespec* %20, i32 0)
ret i32 %21
}