#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__ actime;
  scalar_t__ modtime;
};
struct timeval {
  int tv_usec;
  scalar_t__ tv_sec;
};
struct stat {
  int /*<<< orphan*/ st_ctime;
  scalar_t__ st_mtime;
  scalar_t__ st_atime;
};

/* Variables and functions */
int /*<<< orphan*/ close(int);
int open_file(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, scalar_t__, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ stat(char *, struct stat *);
int /*<<< orphan*/ unlink(char *);
int utime(char *, struct utimbuf *);
int utimes(char *, struct timeval *);
void mod_ftime0() {
  int fd;
  int ret;
  struct stat sbuf;
  struct utimbuf tbuf;
  char pname[] = "test.exe";
  struct timeval tv0[2];
  fd = open_file(pname);
  close(fd);
  stat(pname, &sbuf);
  printf("atime %ld mtime %ld ctime %ld\n", sbuf.st_atime, sbuf.st_mtime,
         sbuf.st_ctime);
  tbuf.actime = sbuf.st_atime + 10;
  tbuf.modtime = sbuf.st_mtime + 10;
  ret = utime(pname, &tbuf);
  if (ret < 0) {
    perror("utime fail:");
    return;
  }
  tv0[0].tv_sec = tbuf.actime;
  tv0[0].tv_usec = 88;
  tv0[1].tv_sec = tbuf.actime;
  tv0[1].tv_usec = 88;
  ret = utimes(pname, tv0);
  if (ret < 0) {
    perror("utimes fail:");
    return;
  }
  stat(pname, &sbuf);
  printf("atime %ld mtime %ld ctime %ld\n", sbuf.st_atime, sbuf.st_mtime,
         sbuf.st_ctime);
  unlink(pname);
}


x86 assembly (clang, -O0):
<mod_ftime0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0xe71(%rip),%rax
mov    %rax,-0x39(%rbp)
mov    0xe6f(%rip),%al
mov    %al,-0x31(%rbp)
lea    -0x39(%rbp),%rdi
call   1050 <open_file@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1070 <close@plt>
lea    -0x39(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1090 <stat@plt>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%ecx
lea    0xe3a(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0xa,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
add    $0xa,%rax
mov    %rax,-0x28(%rbp)
lea    -0x39(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <utime@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1217 <mod_ftime0+0x97>
lea    0xe1b(%rip),%rdi
call   10a0 <perror@plt>
jmp    128d <mod_ftime0+0x10d>
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
movl   $0x58,-0x60(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
movl   $0x58,-0x50(%rbp)
lea    -0x39(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1080 <utimes@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1260 <mod_ftime0+0xe0>
lea    0xdde(%rip),%rdi
call   10a0 <perror@plt>
jmp    128d <mod_ftime0+0x10d>
lea    -0x39(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1090 <stat@plt>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%ecx
lea    0xd8a(%rip),%rdi
call   1060 <printf@plt>
lea    -0x39(%rbp),%rdi
call   1040 <unlink@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mod_ftime0>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
movabs $0x6578652e74736574,%rax
65 78 65
mov    %rax,0x8(%rsp)
movb   $0x0,0x10(%rsp)
lea    0x8(%rsp),%r14
mov    %r14,%rdi
call   1050 <open_file@plt>
mov    %eax,%edi
call   1070 <close@plt>
lea    0x18(%rsp),%rsi
mov    %r14,%rdi
call   1090 <stat@plt>
mov    0x28(%rsp),%rbx
mov    0x20(%rsp),%r15
mov    0x18(%rsp),%ecx
lea    0xe36(%rip),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1060 <printf@plt>
add    $0xa,%rbx
mov    %rbx,0x30(%rsp)
add    $0xa,%r15
mov    %r15,0x38(%rsp)
lea    0x30(%rsp),%rsi
mov    %r14,%rdi
call   1030 <utime@plt>
test   %eax,%eax
js     126c <mod_ftime0+0xec>
mov    %rbx,0x48(%rsp)
movl   $0x58,0x40(%rsp)
mov    %rbx,0x58(%rsp)
movl   $0x58,0x50(%rsp)
lea    0x8(%rsp),%rdi
lea    0x40(%rsp),%rsi
call   1080 <utimes@plt>
test   %eax,%eax
js     127a <mod_ftime0+0xfa>
lea    0x8(%rsp),%rbx
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1090 <stat@plt>
mov    0x28(%rsp),%rsi
mov    0x20(%rsp),%rdx
mov    0x18(%rsp),%ecx
lea    0xdb4(%rip),%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1040 <unlink@plt>
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xdb5(%rip),%rdi
call   10a0 <perror@plt>
jmp    1262 <mod_ftime0+0xe2>
lea    0xdb3(%rip),%rdi
call   10a0 <perror@plt>
jmp    1262 <mod_ftime0+0xe2>

LLVM IR (-O0):
%struct.stat = type { i32, i64, i64 }
%struct.utimbuf = type { i64, i64 }
%struct.timeval = type { i32, i64 }
@__const.mod_ftime0.pname = [9 x i8] c"test.exe\00"
@.str = [31 x i8] c"atime %ld mtime %ld ctime %ld\0A\00"
@.str.1 = [12 x i8] c"utime fail:\00"
@.str.2 = [13 x i8] c"utimes fail:\00"
define void @mod_ftime0() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.stat
%4 = alloca %struct.utimbuf
%5 = alloca [9 x i8]
%6 = alloca [2 x %struct.timeval]
%7 = bitcast [9 x i8]* %5 to i8*
%8 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%9 = call i32 @open_file(i8* %8)
store i32 %9, i32* %1
%10 = load i32, i32* %1
%11 = call i32 @close(i32 %10)
%12 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%13 = call i32 @stat(i8* %12, %struct.stat* %3)
%14 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 2
%15 = load i64, i64* %14
%16 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 1
%17 = load i64, i64* %16
%18 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%19 = load i32, i32* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i64 %15, i64 %17, i32 %19)
%21 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 2
%22 = load i64, i64* %21
%23 = add nsw i64 %22, 10
%24 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %4, i32 0, i32 0
store i64 %23, i64* %24
%25 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 1
%26 = load i64, i64* %25
%27 = add nsw i64 %26, 10
%28 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %4, i32 0, i32 1
store i64 %27, i64* %28
%29 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%30 = call i32 @utime(i8* %29, %struct.utimbuf* %4)
store i32 %30, i32* %2
%31 = load i32, i32* %2
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %0
%34 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %67
35: ; preds = %0
%36 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %4, i32 0, i32 0
%37 = load i64, i64* %36
%38 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %6, i64 0, i64 0
%39 = getelementptr inbounds %struct.timeval, %struct.timeval* %38, i32 0, i32 1
store i64 %37, i64* %39
%40 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %6, i64 0, i64 0
%41 = getelementptr inbounds %struct.timeval, %struct.timeval* %40, i32 0, i32 0
store i32 88, i32* %41
%42 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %4, i32 0, i32 0
%43 = load i64, i64* %42
%44 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %6, i64 0, i64 1
%45 = getelementptr inbounds %struct.timeval, %struct.timeval* %44, i32 0, i32 1
store i64 %43, i64* %45
%46 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %6, i64 0, i64 1
%47 = getelementptr inbounds %struct.timeval, %struct.timeval* %46, i32 0, i32 0
store i32 88, i32* %47
%48 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%49 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %6, i64 0, i64 0
%50 = call i32 @utimes(i8* %48, %struct.timeval* %49)
store i32 %50, i32* %2
%51 = load i32, i32* %2
%52 = icmp slt i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %35
%54 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %67
55: ; preds = %35
%56 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%57 = call i32 @stat(i8* %56, %struct.stat* %3)
%58 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 2
%59 = load i64, i64* %58
%60 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 1
%61 = load i64, i64* %60
%62 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%63 = load i32, i32* %62
%64 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i64 %59, i64 %61, i32 %63)
%65 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%66 = call i32 @unlink(i8* %65)
br label %67
67: ; preds = %55, %53, %33
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32, i64, i64 }
%struct.utimbuf = type { i64, i64 }
%struct.timeval = type { i32, i64 }
@__const.mod_ftime0.pname = [9 x i8] c"test.exe\00"
@.str = [31 x i8] c"atime %ld mtime %ld ctime %ld\0A\00"
@.str.1 = [12 x i8] c"utime fail:\00"
@.str.2 = [13 x i8] c"utimes fail:\00"
define void @mod_ftime0() {
%1 = alloca %struct.stat
%2 = alloca %struct.utimbuf
%3 = alloca [9 x i8]
%4 = alloca [2 x %struct.timeval]
%5 = bitcast %struct.stat* %1 to i8*
%6 = bitcast %struct.utimbuf* %2 to i8*
%7 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%8 = bitcast [2 x %struct.timeval]* %4 to i8*
%9 = call i32 @open_file(i8* %7)
%10 = call i32 @close(i32 %9)
%11 = call i32 @stat(i8* %7, %struct.stat* %1)
%12 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 2
%13 = load i64, i64* %12
%14 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 1
%15 = load i64, i64* %14
%16 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%17 = load i32, i32* %16
%18 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i64 %13, i64 %15, i32 %17)
%19 = add nsw i64 %13, 10
%20 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %2, i64 0, i32 0
store i64 %19, i64* %20
%21 = add nsw i64 %15, 10
%22 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %2, i64 0, i32 1
store i64 %21, i64* %22
%23 = call i32 @utime(i8* %7, %struct.utimbuf* %2)
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %0
%26 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %44
27: ; preds = %0
%28 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %4, i64 0, i64 0
%29 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %4, i64 0, i64 0, i32 1
store i64 %19, i64* %29
%30 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %4, i64 0, i64 0, i32 0
store i32 88, i32* %30
%31 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %4, i64 0, i64 1, i32 1
store i64 %19, i64* %31
%32 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %4, i64 0, i64 1, i32 0
store i32 88, i32* %32
%33 = call i32 @utimes(i8* %7, %struct.timeval* %28)
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %27
%36 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %44
37: ; preds = %27
%38 = call i32 @stat(i8* %7, %struct.stat* %1)
%39 = load i64, i64* %12
%40 = load i64, i64* %14
%41 = load i32, i32* %16
%42 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i64 %39, i64 %40, i32 %41)
%43 = call i32 @unlink(i8* %7)
br label %44
44: ; preds = %37, %35, %25
ret void
}