#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;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ sleep(int);
scalar_t__ stat(char *, struct stat *);
int main(int argc, char *argv[]) {
  struct stat watchStat;
  struct stat targetStat;
  if (argc != 3) {
    puts("Error: provide a watch directory and target directory");
    return 1;
  } else if (stat(argv[1], &watchStat) < 0 || stat(argv[2], &targetStat) < 0) {
    printf("Error reading the watch / target directory %s / %s\n", argv[1],
           argv[2]);
    return 1;
  }
  while (true) {
    puts("Checking target directory");
    sleep(5);
  }
  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   $0x3,-0x8(%rbp)
je     1178 <main+0x38>
lea    0xe99(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fb <main+0xbb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
jl     11ae <main+0x6e>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
jge    11d6 <main+0x96>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fb <main+0xbb>
jmp    11db <main+0x9b>
jmp    11e0 <main+0xa0>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
mov    $0x5,%edi
call   1060 <sleep@plt>
jmp    11e0 <main+0xa0>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x3,%edi
jne    1194 <main+0x54>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0x8(%rsp),%rsi
call   1050 <stat@plt>
test   %rax,%rax
js     11a2 <main+0x62>
mov    0x10(%rbx),%rdi
mov    %rsp,%rsi
call   1050 <stat@plt>
test   %rax,%rax
js     11a2 <main+0x62>
lea    0xef2(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0x5,%edi
call   1060 <sleep@plt>
jmp    1180 <main+0x40>
lea    0xe65(%rip),%rdi
call   1030 <puts@plt>
jmp    11b6 <main+0x76>
mov    0x8(%rbx),%rsi
mov    0x10(%rbx),%rdx
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [54 x i8] c"Error: provide a watch directory and target directory\00"
@.str.1 = [52 x i8] c"Error reading the watch / target directory %s / %s\0A\00"
@.str.2 = [26 x i8] c"Checking target directory\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
%7 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 3
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @puts(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %37
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @stat(i8* %15, %struct.stat* %6)
%17 = icmp slt i64 %16, 0
br i1 %17, label %24, label %18
18: ; preds = %12
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i64 @stat(i8* %21, %struct.stat* %7)
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %18, %12
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i8* %27, i8* %30)
store i32 1, i32* %3
br label %37
32: ; preds = %18
br label %33
33: ; preds = %32
br label %34
34: ; preds = %33, %34
%35 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 @sleep(i32 5)
br label %34
37: ; preds = %24, %10
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [54 x i8] c"Error: provide a watch directory and target directory\00"
@.str.1 = [52 x i8] c"Error reading the watch / target directory %s / %s\0A\00"
@.str.2 = [26 x i8] c"Checking target directory\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca %struct.stat
%5 = bitcast %struct.stat* %3 to i8*
%6 = bitcast %struct.stat* %4 to i8*
%7 = icmp eq i32 %0, 3
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
br label %28
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = call i64 @stat(i8* %12, %struct.stat* %3)
%14 = icmp slt i64 %13, 0
br i1 %14, label %20, label %15
15: ; preds = %10
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = call i64 @stat(i8* %17, %struct.stat* %4)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %15, %10
%21 = load i8*, i8** %11
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i8* %21, i8* %23)
br label %28
25: ; preds = %15, %25
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 @sleep(i32 5)
br label %25
28: ; preds = %20, %8
ret i32 1
}