#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 timespec {
  int /*<<< orphan*/ tv_sec;
};
struct stat {
  int /*<<< orphan*/ st_mtime;
  int /*<<< orphan*/ st_atime;
};

/* Variables and functions */
int O_RDWR;
int O_TRUNC;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ futimens(int, struct timespec *);
int open(char *, int);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int i, fd;
  struct stat statbuf;
  struct timespec time[2];
  for (i = 1; i < argc; i++) {
    if (stat(argv[i], &statbuf) < 0) {
      fprintf(stderr, "%s: stat error", argv[i]);
      continue;
    }
    if ((fd = open(argv[i], O_RDWR | O_TRUNC)) < 0) {
      fprintf(stderr, "%s: open error", argv[i]);
      continue;
    }
    time[0].tv_sec = statbuf.st_atime;
    time[1].tv_sec = statbuf.st_mtime;
    if (futimens(fd, time) < 0)
      fprintf(stderr, "%s: futimens error", argv[i]);
    close(fd);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    127c <main+0x11c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
jge    11ce <main+0x6e>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe3c(%rip),%rsi
call   1040 <fprintf@plt>
jmp    126e <main+0x10e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2dff(%rip),%rax
mov    (%rax),%esi
mov    0x2e0e(%rip),%rax
or     (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    1223 <main+0xc3>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xdf6(%rip),%rsi
call   1040 <fprintf@plt>
jmp    126e <main+0x10e>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   1070 <futimens@plt>
cmp    $0x0,%rax
jge    1266 <main+0x106>
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xdbd(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%edi
call   1030 <close@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117d <main+0x1d>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jl     1259 <main+0xf9>
mov    %rsi,%rbx
mov    %edi,%r12d
mov    $0x1,%r15d
lea    0x10(%rsp),%r14
mov    0x2e41(%rip),%r13
jmp    11b4 <main+0x54>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1030 <close@plt>
add    $0x1,%r15
cmp    %r15,%r12
je     1259 <main+0xf9>
mov    (%rbx,%r15,8),%rdi
mov    %r14,%rsi
call   1050 <stat@plt>
test   %rax,%rax
js     1220 <main+0xc0>
mov    (%rbx,%r15,8),%rdi
mov    0x2e28(%rip),%rax
mov    (%rax),%esi
mov    0x2e07(%rip),%rax
or     (%rax),%esi
call   1060 <open@plt>
test   %eax,%eax
js     1240 <main+0xe0>
mov    %eax,%ebp
mov    0x10(%rsp),%rax
rol    $0x20,%rax
mov    %rax,0x8(%rsp)
mov    %ebp,%edi
lea    0x8(%rsp),%rsi
call   1070 <futimens@plt>
test   %rax,%rax
jns    11a0 <main+0x40>
mov    0x0(%r13),%edi
mov    (%rbx,%r15,8),%rdx
lea    0xe0a(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11a0 <main+0x40>
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13),%edi
mov    (%rbx,%r15,8),%rdx
lea    0xdd1(%rip),%rsi
jmp    124f <main+0xef>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13),%edi
mov    (%rbx,%r15,8),%rdx
lea    0xdc0(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11a7 <main+0x47>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32, i32 }
%struct.timespec = type { i32 }
@stderr = global i32 0
@.str = [15 x i8] c"%s: stat error\00"
@O_RDWR = global i32 0
@O_TRUNC = global i32 0
@.str.1 = [15 x i8] c"%s: open error\00"
@.str.2 = [19 x i8] c"%s: futimens error\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.stat
%9 = alloca [2 x %struct.timespec]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %10
10: ; preds = %73, %2
%11 = load i32, i32* %6
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %76
14: ; preds = %10
%15 = load i8**, i8*** %5
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = call i64 @stat(i8* %19, %struct.stat* %8)
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %30
22: ; preds = %14
%23 = load i32, i32* @stderr
%24 = load i8**, i8*** %5
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %28)
br label %73
30: ; preds = %14
%31 = load i8**, i8*** %5
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = load i32, i32* @O_RDWR
%37 = load i32, i32* @O_TRUNC
%38 = or i32 %36, %37
%39 = call i32 @open(i8* %35, i32 %38)
store i32 %39, i32* %7
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %49
41: ; preds = %30
%42 = load i32, i32* @stderr
%43 = load i8**, i8*** %5
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %43, i64 %45
%47 = load i8*, i8** %46
%48 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %47)
br label %73
49: ; preds = %30
%50 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 1
%51 = load i32, i32* %50
%52 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %9, i64 0, i64 0
%53 = getelementptr inbounds %struct.timespec, %struct.timespec* %52, i32 0, i32 0
store i32 %51, i32* %53
%54 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%55 = load i32, i32* %54
%56 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %9, i64 0, i64 1
%57 = getelementptr inbounds %struct.timespec, %struct.timespec* %56, i32 0, i32 0
store i32 %55, i32* %57
%58 = load i32, i32* %7
%59 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %9, i64 0, i64 0
%60 = call i64 @futimens(i32 %58, %struct.timespec* %59)
%61 = icmp slt i64 %60, 0
br i1 %61, label %62, label %70
62: ; preds = %49
%63 = load i32, i32* @stderr
%64 = load i8**, i8*** %5
%65 = load i32, i32* %6
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8*, i8** %64, i64 %66
%68 = load i8*, i8** %67
%69 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %68)
br label %70
70: ; preds = %62, %49
%71 = load i32, i32* %7
%72 = call i32 @close(i32 %71)
br label %73
73: ; preds = %70, %41, %22
%74 = load i32, i32* %6
%75 = add nsw i32 %74, 1
store i32 %75, i32* %6
br label %10
76: ; preds = %10
%77 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i32, i32 }
%struct.timespec = type { i32 }
@stderr = global i32 0
@.str = [15 x i8] c"%s: stat error\00"
@O_RDWR = global i32 0
@O_TRUNC = global i32 0
@.str.1 = [15 x i8] c"%s: open error\00"
@.str.2 = [19 x i8] c"%s: futimens error\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca [2 x %struct.timespec]
%5 = bitcast %struct.stat* %3 to i8*
%6 = bitcast [2 x %struct.timespec]* %4 to i8*
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %50
8: ; preds = %2
%9 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%10 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %4, i64 0, i64 0
%11 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %4, i64 0, i64 0, i32 0
%12 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%13 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %4, i64 0, i64 1, i32 0
%14 = zext i32 %0 to i64
br label %15
15: ; preds = %8, %47
%16 = phi i64 [ 1, %8 ], [ %48, %47 ]
%17 = getelementptr inbounds i8*, i8** %1, i64 %16
%18 = load i8*, i8** %17
%19 = call i64 @stat(i8* %18, %struct.stat* %3)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %15
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %17
%24 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %23)
br label %47
25: ; preds = %15
%26 = load i8*, i8** %17
%27 = load i32, i32* @O_RDWR
%28 = load i32, i32* @O_TRUNC
%29 = or i32 %28, %27
%30 = call i32 @open(i8* %26, i32 %29)
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %25
%33 = load i32, i32* @stderr
%34 = load i8*, i8** %17
%35 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %34)
br label %47
36: ; preds = %25
%37 = load i32, i32* %9
store i32 %37, i32* %11
%38 = load i32, i32* %12
store i32 %38, i32* %13
%39 = call i64 @futimens(i32 %30, %struct.timespec* %10)
%40 = icmp slt i64 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %36
%42 = load i32, i32* @stderr
%43 = load i8*, i8** %17
%44 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %43)
br label %45
45: ; preds = %41, %36
%46 = call i32 @close(i32 %30)
br label %47
47: ; preds = %45, %32, %21
%48 = add nuw nsw i64 %16, 1
%49 = icmp eq i64 %48, %14
br i1 %49, label %50, label %15
50: ; preds = %47, %2
%51 = call i32 @exit(i32 0)
unreachable
}