#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 */
typedef scalar_t__ time_t;
struct utimbuf {
  int actime;
  int modtime;
};
struct stat {
  scalar_t__ st_atime;
  scalar_t__ st_mtime;
};

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ close(int);
int mkstemp(char *);
scalar_t__ stat(char *, struct stat *);
scalar_t__ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ unlink(char *);
scalar_t__ utime(char *, struct utimbuf *);
int main(void) {
  char file[] = "/tmp/utime-test.XXXXXX";
  int tmp_fd;
  struct utimbuf utm = {
      .actime = 23,
      .modtime = 42,
  };
  struct stat st;
  time_t now;
  tmp_fd = mkstemp(file);
  close(tmp_fd);
  assert(utime(file, &utm) == 0);
  assert(stat(file, &st) == 0);
  assert(st.st_atime == utm.actime);
  assert(st.st_mtime == utm.modtime);
  now = time(NULL);
  assert(utime(file, NULL) == 0);
  assert(stat(file, &st) == 0);
  assert(st.st_atime == st.st_mtime);
  assert(st.st_atime >= now);
  assert(st.st_atime - now < 10);
  unlink(file);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe7a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe77(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe75(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xe6f(%rip),%ax
mov    %ax,-0xc(%rbp)
mov    0xe67(%rip),%al
mov    %al,-0xa(%rbp)
mov    0xe5f(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    -0x20(%rbp),%rdi
call   1090 <mkstemp@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1050 <close@plt>
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <utime@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1070 <stat@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x40(%rbp),%rax
movslq -0x30(%rbp),%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %rax,-0x48(%rbp)
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <utime@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1070 <stat@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x40(%rbp),%rax
cmp    -0x38(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x40(%rbp),%rax
cmp    -0x48(%rbp),%rax
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x40(%rbp),%rax
sub    -0x48(%rbp),%rax
cmp    $0xa,%rax
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x20(%rbp),%rdi
call   1040 <unlink@plt>
mov    0x2d07(%rip),%rax
mov    (%rax),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
movaps 0xe80(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movabs $0x5858585858582e,%rax
mov    %rax,0x2f(%rsp)
movabs $0x2a00000017,%rax
mov    %rax,0x18(%rsp)
lea    0x20(%rsp),%r15
mov    %r15,%rdi
call   1090 <mkstemp@plt>
mov    %eax,%edi
call   1050 <close@plt>
lea    0x18(%rsp),%rsi
mov    %r15,%rdi
call   1030 <utime@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
lea    0x8(%rsp),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1070 <stat@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpq   $0x17,0x8(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpq   $0x2a,0x10(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
call   1080 <time@plt>
mov    %rax,%rbx
mov    %r15,%rdi
xor    %esi,%esi
call   1030 <utime@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1070 <stat@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
mov    0x8(%rsp),%rax
xor    %edi,%edi
cmp    0x10(%rsp),%rax
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmp    %rbx,0x8(%rsp)
setge  %dil
call   1060 <assert@plt>
mov    0x8(%rsp),%rax
sub    %rbx,%rax
xor    %edi,%edi
cmp    $0xa,%rax
setl   %dil
call   1060 <assert@plt>
mov    %r15,%rdi
call   1040 <unlink@plt>
mov    0x2d48(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.utimbuf = type { i32, i32 }
%struct.stat = type { i64, i64 }
@__const.main.file = [23 x i8] c"/tmp/utime-test.XXXXXX\00"
@__const.main.utm = %struct.utimbuf { i32 23, i32 42 }
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [23 x i8]
%3 = alloca i32
%4 = alloca %struct.utimbuf
%5 = alloca %struct.stat
%6 = alloca i64
store i32 0, i32* %1
%7 = bitcast [23 x i8]* %2 to i8*
%8 = bitcast %struct.utimbuf* %4 to i8*
%9 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%10 = call i32 @mkstemp(i8* %9)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = call i32 @close(i32 %11)
%13 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%14 = call i64 @utime(i8* %13, %struct.utimbuf* %4)
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%19 = call i64 @stat(i8* %18, %struct.stat* %5)
%20 = icmp eq i64 %19, 0
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%24 = load i64, i64* %23
%25 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %4, i32 0, i32 0
%26 = load i32, i32* %25
%27 = sext i32 %26 to i64
%28 = icmp eq i64 %24, %27
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 1
%32 = load i64, i64* %31
%33 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %4, i32 0, i32 1
%34 = load i32, i32* %33
%35 = sext i32 %34 to i64
%36 = icmp eq i64 %32, %35
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = call i64 @time(i32* null)
store i64 %39, i64* %6
%40 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%41 = call i64 @utime(i8* %40, %struct.utimbuf* null)
%42 = icmp eq i64 %41, 0
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%46 = call i64 @stat(i8* %45, %struct.stat* %5)
%47 = icmp eq i64 %46, 0
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%51 = load i64, i64* %50
%52 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 1
%53 = load i64, i64* %52
%54 = icmp eq i64 %51, %53
%55 = zext i1 %54 to i32
%56 = call i32 @assert(i32 %55)
%57 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%58 = load i64, i64* %57
%59 = load i64, i64* %6
%60 = icmp sge i64 %58, %59
%61 = zext i1 %60 to i32
%62 = call i32 @assert(i32 %61)
%63 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%64 = load i64, i64* %63
%65 = load i64, i64* %6
%66 = sub nsw i64 %64, %65
%67 = icmp slt i64 %66, 10
%68 = zext i1 %67 to i32
%69 = call i32 @assert(i32 %68)
%70 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%71 = call i32 @unlink(i8* %70)
%72 = load i32, i32* @EXIT_SUCCESS
ret i32 %72
}

LLVM IR (-O2):
%struct.utimbuf = type { i32, i32 }
%struct.stat = type { i64, i64 }
@__const.main.file = [23 x i8] c"/tmp/utime-test.XXXXXX\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [23 x i8]
%2 = alloca i64
%3 = bitcast i64* %2 to %struct.utimbuf*
%4 = alloca %struct.stat
%5 = getelementptr inbounds [23 x i8], [23 x i8]* %1, i64 0, i64 0
%6 = bitcast i64* %2 to i8*
store i64 180388626455, i64* %2
%7 = bitcast %struct.stat* %4 to i8*
%8 = call i32 @mkstemp(i8* %5)
%9 = call i32 @close(i32 %8)
%10 = call i64 @utime(i8* %5, %struct.utimbuf* %3)
%11 = icmp eq i64 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = call i64 @stat(i8* %5, %struct.stat* %4)
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%19 = load i64, i64* %18
%20 = icmp eq i64 %19, 23
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 1
%24 = load i64, i64* %23
%25 = icmp eq i64 %24, 42
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = call i64 @time(i32* null)
%29 = call i64 @utime(i8* %5, %struct.utimbuf* null)
%30 = icmp eq i64 %29, 0
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = call i64 @stat(i8* %5, %struct.stat* %4)
%34 = icmp eq i64 %33, 0
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = load i64, i64* %18
%38 = load i64, i64* %23
%39 = icmp eq i64 %37, %38
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
%42 = load i64, i64* %18
%43 = icmp sge i64 %42, %28
%44 = zext i1 %43 to i32
%45 = call i32 @assert(i32 %44)
%46 = load i64, i64* %18
%47 = sub nsw i64 %46, %28
%48 = icmp slt i64 %47, 10
%49 = zext i1 %48 to i32
%50 = call i32 @assert(i32 %49)
%51 = call i32 @unlink(i8* %5)
%52 = load i32, i32* @EXIT_SUCCESS
ret i32 %52
}