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

/* Variables and functions */
int O_RDWR;
int O_TRUNC;
int /*<<< orphan*/ err_ret(char *, char *);
int /*<<< orphan*/ err_sys(char *, char *);
scalar_t__ open(char *, int);
scalar_t__ stat(char *, struct stat *);
scalar_t__ utime(char *, struct utimbuf *);
int main(int argc, char **argv) {
  struct stat statbuf;
  struct utimbuf timebuf;
  while (--argc > 0) {
    if (stat(*++argv, &statbuf) < 0) {
      err_sys("%s: stat error", *argv);
      continue;
    }
    if (open(*argv, O_RDWR | O_TRUNC) < 0) {
      err_ret("%s: open error", *argv);
      continue;
    }
    timebuf.actime = statbuf.st_atime;
    timebuf.modtime = statbuf.st_mtime;
    if (utime(*argv, &timebuf) < 0) {
      err_sys("%s: utime error", *argv);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    1234 <main+0xe4>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
jge    11b6 <main+0x66>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe54(%rip),%rdi
call   1040 <err_sys@plt>
jmp    1166 <main+0x16>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    0x2e1c(%rip),%rax
mov    (%rax),%esi
mov    0x2e2b(%rip),%rax
or     (%rax),%esi
call   1060 <open@plt>
cmp    $0x0,%rax
jge    11f6 <main+0xa6>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe23(%rip),%rdi
call   1070 <err_ret@plt>
jmp    1166 <main+0x16>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <utime@plt>
cmp    $0x0,%rax
jge    122f <main+0xdf>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdf4(%rip),%rdi
call   1040 <err_sys@plt>
jmp    1166 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jl     1211 <main+0xc1>
mov    %rsi,%rbx
mov    %edi,%ebp
add    $0x1,%ebp
add    $0x8,%rbx
lea    0x10(%rsp),%r14
mov    0x2e61(%rip),%r12
mov    0x2e72(%rip),%r15
lea    0x8(%rsp),%r13
jmp    11ab <main+0x5b>
nopl   (%rax)
mov    (%rbx),%rsi
lea    0xe75(%rip),%rdi
call   1070 <err_ret@plt>
add    $0xffffffff,%ebp
add    $0x8,%rbx
cmp    $0x2,%ebp
jbe    1211 <main+0xc1>
mov    (%rbx),%rdi
mov    %r14,%rsi
call   1050 <stat@plt>
mov    (%rbx),%rcx
test   %rax,%rax
js     1200 <main+0xb0>
mov    (%r15),%esi
or     (%r12),%esi
mov    %rcx,%rdi
call   1060 <open@plt>
test   %rax,%rax
js     1190 <main+0x40>
mov    0x10(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    (%rbx),%rdi
mov    %r13,%rsi
call   1030 <utime@plt>
test   %rax,%rax
jns    119f <main+0x4f>
mov    (%rbx),%rsi
lea    0xe28(%rip),%rdi
jmp    120a <main+0xba>
nopl   0x0(%rax,%rax,1)
lea    0xdf9(%rip),%rdi
mov    %rcx,%rsi
call   1040 <err_sys@plt>
jmp    119f <main+0x4f>
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 { i32, i32 }
%struct.utimbuf = type { i32, 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 = [16 x i8] c"%s: utime error\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
%7 = alloca %struct.utimbuf
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %8
8: ; preds = %49, %30, %18, %2
%9 = load i32, i32* %4
%10 = add nsw i32 %9, -1
store i32 %10, i32* %4
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %50
12: ; preds = %8
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i32 1
store i8** %14, i8*** %5
%15 = load i8*, i8** %14
%16 = call i64 @stat(i8* %15, %struct.stat* %6)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %12
%19 = load i8**, i8*** %5
%20 = load i8*, i8** %19
%21 = call i32 @err_sys(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %20)
br label %8
22: ; preds = %12
%23 = load i8**, i8*** %5
%24 = load i8*, i8** %23
%25 = load i32, i32* @O_RDWR
%26 = load i32, i32* @O_TRUNC
%27 = or i32 %25, %26
%28 = call i64 @open(i8* %24, i32 %27)
%29 = icmp slt i64 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %22
%31 = load i8**, i8*** %5
%32 = load i8*, i8** %31
%33 = call i32 @err_ret(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %32)
br label %8
34: ; preds = %22
%35 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 1
%36 = load i32, i32* %35
%37 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %7, i32 0, i32 1
store i32 %36, i32* %37
%38 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%39 = load i32, i32* %38
%40 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %7, i32 0, i32 0
store i32 %39, i32* %40
%41 = load i8**, i8*** %5
%42 = load i8*, i8** %41
%43 = call i64 @utime(i8* %42, %struct.utimbuf* %7)
%44 = icmp slt i64 %43, 0
br i1 %44, label %45, label %49
45: ; preds = %34
%46 = load i8**, i8*** %5
%47 = load i8*, i8** %46
%48 = call i32 @err_sys(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %47)
br label %49
49: ; preds = %45, %34
br label %8
50: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32, i32 }
%struct.utimbuf = type { i32, 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 = [16 x i8] c"%s: utime error\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca %struct.utimbuf
%5 = bitcast %struct.stat* %3 to i8*
%6 = bitcast %struct.utimbuf* %4 to i8*
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %44
8: ; preds = %2
%9 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%10 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %4, i64 0, i32 1
%11 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%12 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %4, i64 0, i32 0
br label %13
13: ; preds = %8, %24
%14 = phi i32 [ %0, %8 ], [ %16, %24 ]
%15 = phi i8** [ %1, %8 ], [ %17, %24 ]
%16 = add nsw i32 %14, -1
%17 = getelementptr inbounds i8*, i8** %15, i64 1
%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 %26
22: ; preds = %13
%23 = call i32 @err_sys(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %24
24: ; preds = %35, %41, %22, %32
%25 = icmp ugt i32 %14, 2
br i1 %25, label %13, label %44
26: ; preds = %13
%27 = load i32, i32* @O_RDWR
%28 = load i32, i32* @O_TRUNC
%29 = or i32 %28, %27
%30 = call i64 @open(i8* %21, i32 %29)
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %26
%33 = load i8*, i8** %17
%34 = call i32 @err_ret(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %33)
br label %24
35: ; preds = %26
%36 = load i32, i32* %9
store i32 %36, i32* %10
%37 = load i32, i32* %11
store i32 %37, i32* %12
%38 = load i8*, i8** %17
%39 = call i64 @utime(i8* %38, %struct.utimbuf* %4)
%40 = icmp slt i64 %39, 0
br i1 %40, label %41, label %24
41: ; preds = %35
%42 = load i8*, i8** %17
%43 = call i32 @err_sys(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %42)
br label %24
44: ; preds = %24, %2
ret i32 0
}