#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 */
typedef void *time_t;
struct timespec {
  void *tv_nsec;
  void *tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ AT_FDCWD;
int /*<<< orphan*/ AT_SYMLINK_NOFOLLOW;
void *atoll(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int utimensat(int /*<<< orphan*/, char *, struct timespec *,
              int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  struct timespec times[2];
  if (argc != 6) {
    fprintf(stderr,
            "Usage: utimens_nofollow path atime atime_nsec mtime mtime_nsec\n");
    return 1;
  }
  times[0].tv_sec = (time_t)atoll(argv[2]);
  times[0].tv_nsec = atoll(argv[3]);
  times[1].tv_sec = (time_t)atoll(argv[4]);
  times[1].tv_nsec = atoll(argv[5]);
  if (utimensat(AT_FDCWD, argv[1], times, AT_SYMLINK_NOFOLLOW) == -1) {
    perror("failed to utimensat the given path");
    return 2;
  }
  return 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)
cmpl   $0x6,-0x8(%rbp)
je     1181 <main+0x41>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1210 <main+0xd0>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <atoll@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1040 <atoll@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1040 <atoll@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   1040 <atoll@plt>
mov    %rax,-0x20(%rbp)
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    -0x30(%rbp),%rdx
mov    0x2df7(%rip),%rax
mov    (%rax),%ecx
call   1030 <utimensat@plt>
cmp    $0xffffffff,%eax
jne    1209 <main+0xc9>
lea    0xe48(%rip),%rdi
call   1060 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    1210 <main+0xd0>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
cmp    $0x6,%edi
jne    11be <main+0x7e>
mov    %rsi,%rbx
mov    0x10(%rsi),%rdi
call   1040 <atoll@plt>
mov    %rax,0x8(%rsp)
mov    0x18(%rbx),%rdi
call   1040 <atoll@plt>
mov    %rax,(%rsp)
mov    0x20(%rbx),%rdi
call   1040 <atoll@plt>
mov    %rax,0x18(%rsp)
mov    0x28(%rbx),%rdi
call   1040 <atoll@plt>
mov    %rax,0x10(%rsp)
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rsi
mov    0x2e40(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdx
call   1030 <utimensat@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
jne    11d8 <main+0x98>
lea    0xe8e(%rip),%rdi
call   1060 <perror@plt>
mov    $0x2,%eax
jmp    11d8 <main+0x98>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
lea    0xe32(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timespec = type { i8*, i8* }
@stderr = global i32 0
@.str = [64 x i8] c"Usage: utimens_nofollow path atime atime_nsec mtime mtime_nsec\0A\00"
@AT_FDCWD = global i32 0
@AT_SYMLINK_NOFOLLOW = global i32 0
@.str.1 = [35 x i8] c"failed to utimensat the given path\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x %struct.timespec]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 6
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %48
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 2
%15 = load i8*, i8** %14
%16 = call i8* @atoll(i8* %15)
%17 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %6, i64 0, i64 0
%18 = getelementptr inbounds %struct.timespec, %struct.timespec* %17, i32 0, i32 1
store i8* %16, i8** %18
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 3
%21 = load i8*, i8** %20
%22 = call i8* @atoll(i8* %21)
%23 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %6, i64 0, i64 0
%24 = getelementptr inbounds %struct.timespec, %struct.timespec* %23, i32 0, i32 0
store i8* %22, i8** %24
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 4
%27 = load i8*, i8** %26
%28 = call i8* @atoll(i8* %27)
%29 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %6, i64 0, i64 1
%30 = getelementptr inbounds %struct.timespec, %struct.timespec* %29, i32 0, i32 1
store i8* %28, i8** %30
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 5
%33 = load i8*, i8** %32
%34 = call i8* @atoll(i8* %33)
%35 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %6, i64 0, i64 1
%36 = getelementptr inbounds %struct.timespec, %struct.timespec* %35, i32 0, i32 0
store i8* %34, i8** %36
%37 = load i32, i32* @AT_FDCWD
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %6, i64 0, i64 0
%42 = load i32, i32* @AT_SYMLINK_NOFOLLOW
%43 = call i32 @utimensat(i32 %37, i8* %40, %struct.timespec* %41, i32 %42)
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %47
45: ; preds = %12
%46 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
store i32 2, i32* %3
br label %48
47: ; preds = %12
store i32 0, i32* %3
br label %48
48: ; preds = %47, %45, %9
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
%struct.timespec = type { i8*, i8* }
@stderr = global i32 0
@.str = [64 x i8] c"Usage: utimens_nofollow path atime atime_nsec mtime mtime_nsec\0A\00"
@AT_FDCWD = global i32 0
@AT_SYMLINK_NOFOLLOW = global i32 0
@.str.1 = [35 x i8] c"failed to utimensat the given path\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x %struct.timespec]
%4 = bitcast [2 x %struct.timespec]* %3 to i8*
%5 = icmp eq i32 %0, 6
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
br label %35
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i8* @atoll(i8* %11)
%13 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %3, i64 0, i64 0
%14 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %3, i64 0, i64 0, i32 1
store i8* %12, i8** %14
%15 = getelementptr inbounds i8*, i8** %1, i64 3
%16 = load i8*, i8** %15
%17 = tail call i8* @atoll(i8* %16)
%18 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %3, i64 0, i64 0, i32 0
store i8* %17, i8** %18
%19 = getelementptr inbounds i8*, i8** %1, i64 4
%20 = load i8*, i8** %19
%21 = tail call i8* @atoll(i8* %20)
%22 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %3, i64 0, i64 1, i32 1
store i8* %21, i8** %22
%23 = getelementptr inbounds i8*, i8** %1, i64 5
%24 = load i8*, i8** %23
%25 = tail call i8* @atoll(i8* %24)
%26 = getelementptr inbounds [2 x %struct.timespec], [2 x %struct.timespec]* %3, i64 0, i64 1, i32 0
store i8* %25, i8** %26
%27 = load i32, i32* @AT_FDCWD
%28 = getelementptr inbounds i8*, i8** %1, i64 1
%29 = load i8*, i8** %28
%30 = load i32, i32* @AT_SYMLINK_NOFOLLOW
%31 = call i32 @utimensat(i32 %27, i8* %29, %struct.timespec* %13, i32 %30)
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %35
33: ; preds = %9
%34 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %35
35: ; preds = %9, %33, %6
%36 = phi i32 [ 1, %6 ], [ 2, %33 ], [ 0, %9 ]
ret i32 %36
}