#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, 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]);
      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   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1261 <main+0x101>
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    11c5 <main+0x65>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe45(%rip),%rdi
call   1070 <err_ret@plt>
jmp    1253 <main+0xf3>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2e08(%rip),%rax
mov    (%rax),%esi
mov    0x2e17(%rip),%rax
or     (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    1211 <main+0xb1>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe08(%rip),%rdi
call   1070 <err_ret@plt>
jmp    1253 <main+0xf3>
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    124b <main+0xeb>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdd8(%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    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     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>
mov    (%rbx,%r15,8),%rcx
test   %rax,%rax
js     1220 <main+0xc0>
mov    0x0(%r13),%esi
mov    0x2e0c(%rip),%rax
or     (%rax),%esi
mov    %rcx,%rdi
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    0xe10(%rip),%rdi
call   1070 <err_ret@plt>
jmp    11a0 <main+0x40>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xdd9(%rip),%rdi
mov    %rcx,%rsi
jmp    123b <main+0xdb>
nopl   0x0(%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 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 %70
47: ; preds = %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, %40, %22
%71 = load i32, i32* %6
%72 = add nsw i32 %71, 1
store i32 %72, i32* %6
br label %10
73: ; preds = %10
%74 = 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 %46
8: ; preds = %2
%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 %15
15: ; preds = %8, %43
%16 = phi i64 [ 1, %8 ], [ %44, %43 ]
%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
%21 = load i8*, i8** %17
br i1 %20, label %22, label %24
22: ; preds = %15
%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 = %15
%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 %43
33: ; preds = %24
%34 = load i32, i32* %10
store i32 %34, i32* %11
%35 = load i32, i32* %12
store i32 %35, i32* %13
%36 = call i64 @futimens(i32 %28, %struct.timespec* %9)
%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, %30, %22
%44 = add nuw nsw i64 %16, 1
%45 = icmp eq i64 %44, %14
br i1 %45, label %46, label %15
46: ; preds = %43, %2
%47 = call i32 @exit(i32 0)
unreachable
}