#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 stat {
  int dummy;
};
typedef int pid_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int check_changes(int, struct stat *);
int check_end_child_status(int);
int /*<<< orphan*/ close_and_exit(int, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int open_and_stat(char *, struct stat *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int testfutimes(int, int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int ret;
  int fd;
  pid_t pid;
  struct stat prev_stat;
  if (argc != 2) {
    printf("usage: %s path\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  fd = open_and_stat(argv[1], &prev_stat);
  if (fd == -1)
    exit(EXIT_FAILURE);
  pid = fork();
  if (pid == -1) {
    perror("fork");
    ret = -1;
    goto exit;
  }
  if (pid == 0) {
    ret = testfutimes(fd, NULL);
  } else {
    ret = check_end_child_status(pid);
    if (ret)
      goto exit;
    ret = check_changes(fd, &prev_stat);
    if (ret)
      goto exit;
  }
exit:
  close_and_exit(fd, ret);
  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)
cmpl   $0x2,-0x8(%rbp)
je     11d1 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe42(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <open_and_stat@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    11fd <main+0x6d>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    $0x0,%al
call   10a0 <fork@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1229 <main+0x99>
lea    0xdf8(%rip),%rdi
call   1070 <perror@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    1289 <main+0xf9>
cmpl   $0x0,-0x1c(%rbp)
jne    1247 <main+0xb7>
mov    -0x18(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
call   10b0 <testfutimes@plt>
mov    %eax,-0x14(%rbp)
jmp    1284 <main+0xf4>
mov    -0x1c(%rbp),%edi
call   1060 <check_end_child_status@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1261 <main+0xd1>
jmp    1289 <main+0xf9>
mov    -0x18(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1090 <check_changes@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     127f <main+0xef>
jmp    1289 <main+0xf9>
jmp    1284 <main+0xf4>
jmp    1289 <main+0xf9>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1030 <close_and_exit@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jne    1205 <main+0x75>
mov    0x8(%rsi),%rdi
lea    0x8(%rsp),%rsi
call   1040 <open_and_stat@plt>
cmp    $0xffffffff,%eax
je     1214 <main+0x84>
mov    %eax,%ebx
xor    %eax,%eax
call   10a0 <fork@plt>
test   %eax,%eax
je     11d8 <main+0x48>
cmp    $0xffffffff,%eax
je     11f2 <main+0x62>
mov    %eax,%edi
call   1060 <check_end_child_status@plt>
test   %eax,%eax
jne    11e1 <main+0x51>
lea    0x8(%rsp),%rsi
mov    %ebx,%edi
call   1090 <check_changes@plt>
jmp    11e1 <main+0x51>
mov    %ebx,%edi
xor    %esi,%esi
call   10b0 <testfutimes@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1030 <close_and_exit@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe17(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%eax
jmp    11e1 <main+0x51>
mov    (%rsi),%rsi
lea    0xdf1(%rip),%rdi
call   1050 <printf@plt>
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [16 x i8] c"usage: %s path\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [5 x i8] c"fork\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 i32
%9 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @open_and_stat(i8* %22, %struct.stat* %9)
store i32 %23, i32* %7
%24 = load i32, i32* %7
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %29
26: ; preds = %19
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %19
%30 = call i32 (...) @fork()
store i32 %30, i32* %8
%31 = load i32, i32* %8
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %6
br label %55
35: ; preds = %29
%36 = load i32, i32* %8
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = load i32, i32* %7
%40 = call i32 @testfutimes(i32 %39, i32* null)
store i32 %40, i32* %6
br label %54
41: ; preds = %35
%42 = load i32, i32* %8
%43 = call i32 @check_end_child_status(i32 %42)
store i32 %43, i32* %6
%44 = load i32, i32* %6
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %41
br label %55
47: ; preds = %41
%48 = load i32, i32* %7
%49 = call i32 @check_changes(i32 %48, %struct.stat* %9)
store i32 %49, i32* %6
%50 = load i32, i32* %6
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %47
br label %55
53: ; preds = %47
br label %54
54: ; preds = %53, %38
br label %55
55: ; preds = %54, %52, %46, %33
%56 = load i32, i32* %7
%57 = load i32, i32* %6
%58 = call i32 @close_and_exit(i32 %56, i32 %57)
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [16 x i8] c"usage: %s path\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [5 x i8] c"fork\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @open_and_stat(i8* %13, %struct.stat* %3)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %11
%20 = call i32 (...) @fork()
switch i32 %20, label %25 [
i32 -1, label %21
i32 0, label %23
]
21: ; preds = %19
%22 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %30
23: ; preds = %19
%24 = call i32 @testfutimes(i32 %14, i32* null)
br label %30
25: ; preds = %19
%26 = call i32 @check_end_child_status(i32 %20)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 @check_changes(i32 %14, %struct.stat* %3)
br label %30
30: ; preds = %28, %23, %25, %21
%31 = phi i32 [ -1, %21 ], [ %24, %23 ], [ %26, %25 ], [ %29, %28 ]
%32 = call i32 @close_and_exit(i32 %14, i32 %31)
ret i32 0
}