#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 O_RDWR;
int O_TRUNC;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ err_ret(char *, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ futimens(int, struct timespec *);
int open(char *, int);
scalar_t__ stat(char *, struct stat *);
int main(int argc, char *argv[]) {
  int i = 0;
  int fd = 0;
  struct stat statbuf;
  struct timespec times[2];
  for (i = 1; i < argc; i++) {
    if (stat(argv[i], &statbuf) < 0) {
      err_ret("%s: stat error", argv[i]);
      continue;
    }
    if ((fd = open(argv[1], O_RDWR | O_TRUNC)) < 0) {
      err_ret("%s: open error", argv[i]);
      continue;
    }
    times[0] = statbuf.st_atim;
    times[1] = statbuf.st_mtim;
    if (futimens(fd, times) < 0) {
      err_ret("%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   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    126b <main+0x10b>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <stat@plt>
cmp    $0x0,%rax
jge    11d3 <main+0x73>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe37(%rip),%rdi
call   1070 <err_ret@plt>
jmp    125d <main+0xfd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2dfe(%rip),%rax
mov    (%rax),%esi
mov    0x2e0d(%rip),%rax
or     (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    121b <main+0xbb>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdfe(%rip),%rdi
call   1070 <err_ret@plt>
jmp    125d <main+0xfd>
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   1060 <futimens@plt>
cmp    $0x0,%rax
jge    1255 <main+0xf5>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdce(%rip),%rdi
call   1070 <err_ret@plt>
mov    -0x18(%rbp),%edi
call   1030 <close@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118b <main+0x2b>
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     1245 <main+0xe5>
mov    %rsi,%rbx
mov    %edi,%r12d
mov    $0x1,%r15d
lea    0x10(%rsp),%r14
mov    0x2e69(%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     1245 <main+0xe5>
mov    (%rbx,%r15,8),%rdi
mov    %r14,%rsi
call   1040 <stat@plt>
test   %rax,%rax
js     1220 <main+0xc0>
mov    0x8(%rbx),%rdi
mov    0x0(%r13),%esi
mov    0x2e0c(%rip),%rax
or     (%rax),%esi
call   1050 <open@plt>
test   %eax,%eax
js     1230 <main+0xd0>
mov    %eax,%ebp
mov    0x10(%rsp),%rax
rol    $0x20,%rax
mov    %rax,0x8(%rsp)
mov    %ebp,%edi
lea    0x8(%rsp),%rsi
call   1060 <futimens@plt>
test   %rax,%rax
jns    11a0 <main+0x40>
mov    (%rbx,%r15,8),%rsi
lea    0xe13(%rip),%rdi
call   1070 <err_ret@plt>
jmp    11a0 <main+0x40>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rbx,%r15,8),%rsi
lea    0xdd5(%rip),%rdi
jmp    123b <main+0xdb>
nopl   (%rax)
mov    (%rbx,%r15,8),%rsi
lea    0xdd4(%rip),%rdi
call   1070 <err_ret@plt>
jmp    11a7 <main+0x47>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { %struct.timespec, %struct.timespec }
%struct.timespec = type { i32 }
@.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 0, i32* %6
store i32 0, i32* %7
store i32 1, i32* %6
br label %10
10: ; preds = %68, %2
%11 = load i32, i32* %6
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %71
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 %29
22: ; preds = %14
%23 = load i8**, i8*** %5
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 @err_ret(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %27)
br label %68
29: ; preds = %14
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = load i32, i32* @O_RDWR
%34 = load i32, i32* @O_TRUNC
%35 = or i32 %33, %34
%36 = call i32 @open(i8* %32, i32 %35)
store i32 %36, i32* %7
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %29
%39 = load i8**, i8*** %5
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %39, i64 %41
%43 = load i8*, i8** %42
%44 = call i32 @err_ret(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %43)
br label %68
45: ; preds = %29
%46 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %9, i64 0, i64 0
%47 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 1
%48 = bitcast %struct.timespec* %46 to i8*
%49 = bitcast %struct.timespec* %47 to i8*
%50 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %9, i64 0, i64 1
%51 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%52 = bitcast %struct.timespec* %50 to i8*
%53 = bitcast %struct.timespec* %51 to i8*
%54 = load i32, i32* %7
%55 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %9, i64 0, i64 0
%56 = call i64 @futimens(i32 %54, %struct.timespec* %55)
%57 = icmp slt i64 %56, 0
br i1 %57, label %58, label %65
58: ; preds = %45
%59 = load i8**, i8*** %5
%60 = load i32, i32* %6
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8*, i8** %59, i64 %61
%63 = load i8*, i8** %62
%64 = call i32 @err_ret(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %63)
br label %65
65: ; preds = %58, %45
%66 = load i32, i32* %7
%67 = call i32 @close(i32 %66)
br label %68
68: ; preds = %65, %38, %22
%69 = load i32, i32* %6
%70 = add nsw i32 %69, 1
store i32 %70, i32* %6
br label %10
71: ; preds = %10
%72 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.stat = type { %struct.timespec, %struct.timespec }
%struct.timespec = type { i32 }
@.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 %48
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %4, i64 0, i64 0
%11 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1, i32 0
%12 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %4, i64 0, i64 0, i32 0
%13 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0, i32 0
%14 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %4, i64 0, i64 1, i32 0
%15 = zext i32 %0 to i64
br label %16
16: ; preds = %8, %45
%17 = phi i64 [ 1, %8 ], [ %46, %45 ]
%18 = getelementptr inbounds i8*, i8** %1, i64 %17
%19 = load i8*, i8** %18
%20 = call i64 @stat(i8* %19, %struct.stat* %3)
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = load i8*, i8** %18
%24 = call i32 @err_ret(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %23)
br label %45
25: ; preds = %16
%26 = load i8*, i8** %9
%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 %35
32: ; preds = %25
%33 = load i8*, i8** %18
%34 = call i32 @err_ret(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %33)
br label %45
35: ; preds = %25
%36 = load i32, i32* %11
store i32 %36, i32* %12
%37 = load i32, i32* %13
store i32 %37, i32* %14
%38 = call i64 @futimens(i32 %30, %struct.timespec* %10)
%39 = icmp slt i64 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %35
%41 = load i8*, i8** %18
%42 = call i32 @err_ret(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %41)
br label %43
43: ; preds = %40, %35
%44 = call i32 @close(i32 %30)
br label %45
45: ; preds = %43, %32, %22
%46 = add nuw nsw i64 %17, 1
%47 = icmp eq i64 %46, %15
br i1 %47, label %48, label %16
48: ; preds = %45, %2
%49 = call i32 @exit(i32 0)
unreachable
}