#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 {
  scalar_t__ modtime;
  scalar_t__ actime;
};
struct timeval {
  long tv_usec;
  long tv_sec;
};

/* Variables and functions */
int utimes(char const *, struct timeval *);
int utime(const char *file, const struct utimbuf *times) {
  struct timeval timevals[2];
  if (times != NULL) {
    timevals[0].tv_usec = 0L;
    timevals[1].tv_usec = 0L;
    timevals[0].tv_sec = (long int)times->actime;
    timevals[1].tv_sec = (long int)times->modtime;
  }
  return utimes(file, times ? timevals : NULL);
}


x86 assembly (clang, -O0):
<utime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1152 <utime+0x42>
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1172 <utime+0x62>
lea    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    117d <utime+0x6d>
xor    %eax,%eax
mov    %rax,-0x40(%rbp)
jmp    117d <utime+0x6d>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1030 <utimes@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<utime>:
sub    $0x28,%rsp
test   %rsi,%rsi
je     113b <utime+0x2b>
movq   $0x0,(%rsp)
movq   $0x0,0x10(%rsp)
mov    0x8(%rsi),%rax
mov    %rax,0x8(%rsp)
mov    (%rsi),%rax
mov    %rax,0x18(%rsp)
test   %rsi,%rsi
mov    %rsp,%rax
cmove  %rsi,%rax
mov    %rax,%rsi
call   1030 <utimes@plt>
add    $0x28,%rsp
ret

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

LLVM IR (-O2):
%struct.utimbuf = type { i64, i64 }
%struct.timeval = type { i64, i64 }
define i32 @utime(i8* nocapture %0, %struct.utimbuf* %1) {
%3 = alloca [2 x %struct.timeval]
%4 = bitcast [2 x %struct.timeval]* %3 to i8*
%5 = icmp eq %struct.utimbuf* %1, null
br i1 %5, label %15, label %6
6: ; preds = %2
%7 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 0, i32 0
store i64 0, i64* %7
%8 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 1, i32 0
store i64 0, i64* %8
%9 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %1, i64 0, i32 1
%10 = load i64, i64* %9
%11 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 0, i32 1
store i64 %10, i64* %11
%12 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %1, i64 0, i32 0
%13 = load i64, i64* %12
%14 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 1, i32 1
store i64 %13, i64* %14
br label %15
15: ; preds = %6, %2
%16 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %3, i64 0, i64 0
%17 = select i1 %5, %struct.timeval* null, %struct.timeval* %16
%18 = call i32 @utimes(i8* %0, %struct.timeval* %17)
ret i32 %18
}