#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 *);
scalar_t__ futimens(int, struct timespec *);
int open(char *, int);
scalar_t__ stat(char *, struct stat *);
int main(int argc, char *argv[]) {
  int i, fd;
  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[i], O_RDWR | O_TRUNC)) < 0) {
      err_ret("%s: open error", argv[i]);
    }
    times[0] = statbuf.st_atim;
    times[1] = statbuf.st_mtim;
    if (futimens(fd, times) < 0)
      err_ret("%s: futimens error", argv[i]);
    close(fd);
  }
  close(fd);
}


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    124c <main+0xfc>
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    11b5 <main+0x65>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe55(%rip),%rdi
call   1070 <err_ret@plt>
jmp    123e <main+0xee>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2e18(%rip),%rax
mov    (%rax),%esi
mov    0x2e27(%rip),%rax
or     (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    11fc <main+0xac>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe18(%rip),%rdi
call   1070 <err_ret@plt>
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    1236 <main+0xe6>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xded(%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    116d <main+0x1d>
mov    -0x18(%rbp),%edi
call   1030 <close@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%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
mov    %edi,%ebp
mov    $0x1,%r15d
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%r13
jmp    1195 <main+0x45>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12d,%edi
call   1030 <close@plt>
add    $0x1,%r15
cmp    %r15,%rbp
je     1224 <main+0xd4>
mov    (%rbx,%r15,8),%rdi
mov    %r14,%rsi
call   1040 <stat@plt>
mov    (%rbx,%r15,8),%rcx
test   %rax,%rax
js     1210 <main+0xc0>
mov    0x2e47(%rip),%rax
mov    (%rax),%esi
mov    0x2e26(%rip),%rax
or     (%rax),%esi
mov    %rcx,%rdi
call   1050 <open@plt>
mov    %eax,%r12d
test   %eax,%eax
jns    11db <main+0x8b>
mov    (%rbx,%r15,8),%rsi
lea    0xe39(%rip),%rdi
call   1070 <err_ret@plt>
mov    0x10(%rsp),%rax
rol    $0x20,%rax
mov    %rax,0x8(%rsp)
mov    %r12d,%edi
mov    %r13,%rsi
call   1060 <futimens@plt>
test   %rax,%rax
jns    1180 <main+0x30>
mov    (%rbx,%r15,8),%rsi
lea    0xe1a(%rip),%rdi
call   1070 <err_ret@plt>
jmp    1180 <main+0x30>
xchg   %ax,%ax
lea    0xde9(%rip),%rdi
mov    %rcx,%rsi
call   1070 <err_ret@plt>
jmp    1188 <main+0x38>
mov    %r12d,%edi
call   1030 <close@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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