#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 dummy;
};
struct stat {
  struct timespec st_mtim;
  struct timespec st_atim;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int O_CREAT;
int O_RDWR;
int O_TRUNC;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
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;
char *strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    fprintf(stderr, "Usage: %s file1 file2 file3 ... fileN\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  int i;
  for (i = 1; i < argc; i++) {
    struct stat statbuf;
    if (stat(argv[i], &statbuf) < 0) {
      fprintf(stderr, "Error collecting file data for %s: %s\n", argv[i],
              strerror(errno));
      continue;
    }
    int fd;
    if ((fd = open(argv[i], O_RDWR | O_CREAT | O_TRUNC)) < 0) {
      fprintf(stderr, "Couldn't open %s: %s\n", argv[i], strerror(errno));
      continue;
    }
    struct timespec times[2];
    times[0] = statbuf.st_atim;
    times[1] = statbuf.st_mtim;
    if (futimens(fd, times) < 0) {
      fprintf(stderr,
              "Error changing file access and modification times for %s: %s\n",
              argv[i], strerror(errno));
    }
    close(fd);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11bc <main+0x4c>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe59(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    132e <main+0x1be>
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    1235 <main+0xc5>
mov    0x2dd3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%rdx
mov    %rax,%rcx
lea    0xdfe(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1320 <main+0x1b0>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2d90(%rip),%rax
mov    (%rax),%esi
mov    0x2da7(%rip),%rax
or     (%rax),%esi
mov    0x2d96(%rip),%rax
or     (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    12b4 <main+0x144>
mov    0x2d54(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x48(%rbp)
mov    0x2d30(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rdx
mov    %rax,%rcx
lea    0xda6(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1320 <main+0x1b0>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1070 <futimens@plt>
cmp    $0x0,%rax
jge    1318 <main+0x1a8>
mov    0x2ceb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x58(%rbp)
mov    0x2cc7(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x5c(%rbp),%edi
mov    -0x58(%rbp),%rdx
mov    %rax,%rcx
lea    0xd53(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x24(%rbp),%edi
call   1030 <close@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c3 <main+0x53>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jl     12d7 <main+0x167>
mov    %edi,%r13d
mov    $0x1,%r14d
lea    0x10(%rsp),%r15
mov    %r13,(%rsp)
jmp    11b4 <main+0x44>
xchg   %ax,%ax
mov    %ebp,%edi
call   1030 <close@plt>
add    $0x1,%r14
cmp    %r14,%r13
je     12c6 <main+0x156>
mov    (%rbx,%r14,8),%rdi
mov    %r15,%rsi
call   1050 <stat@plt>
test   %rax,%rax
js     1260 <main+0xf0>
mov    (%rbx,%r14,8),%rdi
mov    0x2e24(%rip),%rax
mov    (%rax),%esi
mov    0x2dfb(%rip),%rax
or     (%rax),%esi
mov    0x2e0a(%rip),%rax
or     (%rax),%esi
call   1060 <open@plt>
test   %eax,%eax
js     1290 <main+0x120>
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+0x30>
mov    0x2dab(%rip),%rax
mov    (%rax),%r12d
mov    %r15,%r13
mov    (%rbx,%r14,8),%r15
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %r12d,%edi
lea    0xe25(%rip),%rsi
mov    %r15,%rdx
mov    %r13,%r15
mov    (%rsp),%r13
mov    %rax,%rcx
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11a0 <main+0x30>
nopl   0x0(%rax,%rax,1)
mov    0x2d61(%rip),%rax
mov    (%rax),%ebp
mov    (%rbx,%r14,8),%r12
mov    0x2d4c(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %ebp,%edi
lea    0xda3(%rip),%rsi
jmp    12b4 <main+0x144>
cs nopw 0x0(%rax,%rax,1)
mov    0x2d31(%rip),%rax
mov    (%rax),%ebp
mov    (%rbx,%r14,8),%r12
mov    0x2d1c(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %ebp,%edi
lea    0xd9a(%rip),%rsi
mov    %r12,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11a7 <main+0x37>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cea(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd16(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2cc0(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { %struct.timespec, %struct.timespec }
%struct.timespec = type { i32 }
@stderr = global i32 0
@.str = [39 x i8] c"Usage: %s file1 file2 file3 ... fileN\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [39 x i8] c"Error collecting file data for %s: %s\0A\00"
@errno = global i32 0
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.2 = [22 x i8] c"Couldn't open %s: %s\0A\00"
@.str.3 = [62 x i8] c"Error changing file access and modification times for %s: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.stat
%8 = alloca i32
%9 = alloca [2 x %struct.timespec]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %20
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %2
store i32 1, i32* %6
br label %21
21: ; preds = %92, %20
%22 = load i32, i32* %6
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %95
25: ; preds = %21
%26 = load i8**, i8*** %5
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = call i64 @stat(i8* %30, %struct.stat* %7)
%32 = icmp slt i64 %31, 0
br i1 %32, label %33, label %43
33: ; preds = %25
%34 = load i32, i32* @stderr
%35 = load i8**, i8*** %5
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
%39 = load i8*, i8** %38
%40 = load i32, i32* @errno
%41 = call i8* @strerror(i32 %40)
%42 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* %39, i8* %41)
br label %92
43: ; preds = %25
%44 = load i8**, i8*** %5
%45 = load i32, i32* %6
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %44, i64 %46
%48 = load i8*, i8** %47
%49 = load i32, i32* @O_RDWR
%50 = load i32, i32* @O_CREAT
%51 = or i32 %49, %50
%52 = load i32, i32* @O_TRUNC
%53 = or i32 %51, %52
%54 = call i32 @open(i8* %48, i32 %53)
store i32 %54, i32* %8
%55 = icmp slt i32 %54, 0
br i1 %55, label %56, label %66
56: ; preds = %43
%57 = load i32, i32* @stderr
%58 = load i8**, i8*** %5
%59 = load i32, i32* %6
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8*, i8** %58, i64 %60
%62 = load i8*, i8** %61
%63 = load i32, i32* @errno
%64 = call i8* @strerror(i32 %63)
%65 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %62, i8* %64)
br label %92
66: ; preds = %43
%67 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %9, i64 0, i64 0
%68 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 1
%69 = bitcast %struct.timespec* %67 to i8*
%70 = bitcast %struct.timespec* %68 to i8*
%71 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %9, i64 0, i64 1
%72 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%73 = bitcast %struct.timespec* %71 to i8*
%74 = bitcast %struct.timespec* %72 to i8*
%75 = load i32, i32* %8
%76 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %9, i64 0, i64 0
%77 = call i64 @futimens(i32 %75, %struct.timespec* %76)
%78 = icmp slt i64 %77, 0
br i1 %78, label %79, label %89
79: ; preds = %66
%80 = load i32, i32* @stderr
%81 = load i8**, i8*** %5
%82 = load i32, i32* %6
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8*, i8** %81, i64 %83
%85 = load i8*, i8** %84
%86 = load i32, i32* @errno
%87 = call i8* @strerror(i32 %86)
%88 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0), i8* %85, i8* %87)
br label %89
89: ; preds = %79, %66
%90 = load i32, i32* %8
%91 = call i32 @close(i32 %90)
br label %92
92: ; preds = %89, %56, %33
%93 = load i32, i32* %6
%94 = add nsw i32 %93, 1
store i32 %94, i32* %6
br label %21
95: ; preds = %21
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { %struct.timespec, %struct.timespec }
%struct.timespec = type { i32 }
@stderr = global i32 0
@.str = [39 x i8] c"Usage: %s file1 file2 file3 ... fileN\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [39 x i8] c"Error collecting file data for %s: %s\0A\00"
@errno = global i32 0
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.2 = [22 x i8] c"Couldn't open %s: %s\0A\00"
@.str.3 = [62 x i8] c"Error changing file access and modification times for %s: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca [2 x %struct.timespec]
%5 = icmp slt i32 %0, 2
br i1 %5, label %15, label %6
6: ; preds = %2
%7 = bitcast %struct.stat* %3 to i8*
%8 = bitcast [2 x %struct.timespec]* %4 to i8*
%9 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %4, i64 0, i64 0
%10 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1, i32 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, 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 %21
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %1
%18 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @EXIT_FAILURE
%20 = tail call i32 @exit(i32 %19)
unreachable
21: ; preds = %6, %61
%22 = phi i64 [ 1, %6 ], [ %62, %61 ]
%23 = getelementptr inbounds i8*, i8** %1, i64 %22
%24 = load i8*, i8** %23
%25 = call i64 @stat(i8* %24, %struct.stat* %3)
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %21
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %23
%30 = load i32, i32* @errno
%31 = call i8* @strerror(i32 %30)
%32 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* %29, i8* %31)
br label %61
33: ; preds = %21
%34 = load i8*, i8** %23
%35 = load i32, i32* @O_RDWR
%36 = load i32, i32* @O_CREAT
%37 = or i32 %36, %35
%38 = load i32, i32* @O_TRUNC
%39 = or i32 %37, %38
%40 = call i32 @open(i8* %34, i32 %39)
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %48
42: ; preds = %33
%43 = load i32, i32* @stderr
%44 = load i8*, i8** %23
%45 = load i32, i32* @errno
%46 = call i8* @strerror(i32 %45)
%47 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %44, i8* %46)
br label %61
48: ; preds = %33
%49 = load i32, i32* %10
store i32 %49, i32* %11
%50 = load i32, i32* %12
store i32 %50, i32* %13
%51 = call i64 @futimens(i32 %40, %struct.timespec* %9)
%52 = icmp slt i64 %51, 0
br i1 %52, label %53, label %59
53: ; preds = %48
%54 = load i32, i32* @stderr
%55 = load i8*, i8** %23
%56 = load i32, i32* @errno
%57 = call i8* @strerror(i32 %56)
%58 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0), i8* %55, i8* %57)
br label %59
59: ; preds = %53, %48
%60 = call i32 @close(i32 %40)
br label %61
61: ; preds = %42, %59, %27
%62 = add nuw nsw i64 %22, 1
%63 = icmp eq i64 %62, %14
br i1 %63, label %64, label %21
64: ; preds = %61
ret i32 0
}