#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 dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int errno;
int /*<<< orphan*/ exit(int);
scalar_t__ fileownership(char *);
scalar_t__ filepermissions(char *);
scalar_t__ filesizes(char *);
scalar_t__ filetimes(char *);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, ...);
struct dirent *readdir(int /*<<< orphan*/ *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  DIR *p_dir;
  struct dirent *p_dirent;
  if ((argc < 2) || (strcmp(argv[1], "-h") == 0) || (argc > 3)) {
    printf("Usage: %s <dir name>\n", argv[0]);
    printf("-h \t Show help\n");
    printf("-vvv \t Be Very Verbose (default)\n");
    printf("-P \t Be Precise\n");
    exit(1);
  }
  if ((p_dir = opendir(argv[1])) == NULL) {
    printf("opendir(%s) failed\n", argv[1]);
    exit(1);
  }
  while ((p_dirent = readdir(p_dir)) != NULL) {
    char *str_path = p_dirent->d_name;
    if (str_path == NULL) {
      printf("Null pointer found!\n");
      exit(2);
    }
    if (filepermissions(str_path) != 0)
      printf("Something went wrong! Errno: %d\n", errno);
    if (fileownership(str_path) != 0)
      printf("Something went wrong! Errno: %d\n", errno);
    if (filesizes(str_path) != 0)
      printf("Something went wrong! Errno: %d\n", errno);
    if (!((argv[2]) && strcmp(argv[2], "-p")))
      if (filetimes(str_path) != 0)
        printf("[filetimes]: Something went wrong! Errno: %d\n", errno);
  }
  closedir(p_dir);
  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   $0x2,-0x8(%rbp)
jl     11e8 <main+0x48>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe31(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     11e8 <main+0x48>
cmpl   $0x3,-0x8(%rbp)
jle    1231 <main+0x91>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <opendir@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    126c <main+0xcc>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    1271 <main+0xd1>
mov    -0x18(%rbp),%rdi
call   1090 <readdir@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1395 <main+0x1f5>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12b6 <main+0x116>
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x2,%edi
call   10c0 <exit@plt>
mov    -0x28(%rbp),%rdi
call   1060 <filepermissions@plt>
cmp    $0x0,%rax
je     12e0 <main+0x140>
mov    0x2d10(%rip),%rax
mov    (%rax),%esi
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1070 <fileownership@plt>
cmp    $0x0,%rax
je     130a <main+0x16a>
mov    0x2ce6(%rip),%rax
mov    (%rax),%esi
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   10a0 <filesizes@plt>
cmp    $0x0,%rax
je     1334 <main+0x194>
mov    0x2cbc(%rip),%rax
mov    (%rax),%esi
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     1361 <main+0x1c1>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd33(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1390 <main+0x1f0>
mov    -0x28(%rbp),%rdi
call   10b0 <filetimes@plt>
cmp    $0x0,%rax
je     138b <main+0x1eb>
mov    0x2c65(%rip),%rax
mov    (%rax),%esi
lea    0xd04(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1390 <main+0x1f0>
jmp    1271 <main+0xd1>
mov    -0x18(%rbp),%rdi
call   1050 <closedir@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
cmp    $0x2,%edi
jl     130b <main+0x15b>
mov    %edi,%ebx
mov    0x8(%r14),%rdi
lea    0xe2c(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x3,%ebx
ja     130b <main+0x15b>
test   %rax,%rax
je     130b <main+0x15b>
mov    0x8(%r14),%rdi
call   1040 <opendir@plt>
test   %rax,%rax
je     134a <main+0x19a>
mov    %rax,%rbx
mov    %rax,%rdi
call   10a0 <readdir@plt>
test   %rax,%rax
je     12dc <main+0x12c>
mov    0x2dc8(%rip),%r15
lea    0xe0e(%rip),%r12
lea    0xe17(%rip),%r13
jmp    1241 <main+0x91>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   10a0 <readdir@plt>
test   %rax,%rax
je     12dc <main+0x12c>
mov    (%rax),%rbp
test   %rbp,%rbp
je     12f5 <main+0x145>
mov    %rbp,%rdi
call   1070 <filepermissions@plt>
test   %rax,%rax
je     1267 <main+0xb7>
mov    (%r15),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
call   1080 <fileownership@plt>
test   %rax,%rax
je     1281 <main+0xd1>
mov    (%r15),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
call   10b0 <filesizes@plt>
test   %rax,%rax
je     129b <main+0xeb>
mov    (%r15),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%r14),%rdi
test   %rdi,%rdi
je     12b5 <main+0x105>
mov    %r12,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
jne    1230 <main+0x80>
mov    %rbp,%rdi
call   10c0 <filetimes@plt>
test   %rax,%rax
je     1230 <main+0x80>
mov    (%r15),%esi
lea    0xd60(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1230 <main+0x80>
mov    %rbx,%rdi
call   1060 <closedir@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd62(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%edi
call   10d0 <exit@plt>
mov    (%r14),%rsi
lea    0xcee(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd4f(%rip),%rdi
call   1030 <puts@plt>
lea    0xd52(%rip),%rdi
call   1030 <puts@plt>
lea    0xd67(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    0x8(%r14),%rsi
lea    0xcc4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [3 x i8] c"-h\00"
@.str.1 = [22 x i8] c"Usage: %s <dir name>\0A\00"
@.str.2 = [16 x i8] c"-h \09 Show help\0A\00"
@.str.3 = [34 x i8] c"-vvv \09 Be Very Verbose (default)\0A\00"
@.str.4 = [17 x i8] c"-P \09 Be Precise\0A\00"
@.str.5 = [20 x i8] c"opendir(%s) failed\0A\00"
@.str.6 = [21 x i8] c"Null pointer found!\0A\00"
@.str.7 = [33 x i8] c"Something went wrong! Errno: %d\0A\00"
@errno = global i32 0
@.str.8 = [3 x i8] c"-p\00"
@.str.9 = [46 x i8] c"[filetimes]: Something went wrong! Errno: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca %struct.dirent*
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %20, label %11
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %11
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 3
br i1 %19, label %20, label %29
20: ; preds = %17, %11, %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %17
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32* @opendir(i8* %32)
store i32* %33, i32** %6
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %41
35: ; preds = %29
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %38)
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %29
br label %42
42: ; preds = %95, %41
%43 = load i32*, i32** %6
%44 = call %struct.dirent* @readdir(i32* %43)
store %struct.dirent* %44, %struct.dirent** %7
%45 = icmp ne %struct.dirent* %44, null
br i1 %45, label %46, label %96
46: ; preds = %42
%47 = load %struct.dirent*, %struct.dirent** %7
%48 = getelementptr inbounds %struct.dirent, %struct.dirent* %47, i32 0, i32 0
%49 = load i8*, i8** %48
store i8* %49, i8** %8
%50 = load i8*, i8** %8
%51 = icmp eq i8* %50, null
br i1 %51, label %52, label %55
52: ; preds = %46
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%54 = call i32 @exit(i32 2)
unreachable
55: ; preds = %46
%56 = load i8*, i8** %8
%57 = call i64 @filepermissions(i8* %56)
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %55
%60 = load i32, i32* @errno
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i32 %60)
br label %62
62: ; preds = %59, %55
%63 = load i8*, i8** %8
%64 = call i64 @fileownership(i8* %63)
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %62
%67 = load i32, i32* @errno
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i32 %67)
br label %69
69: ; preds = %66, %62
%70 = load i8*, i8** %8
%71 = call i64 @filesizes(i8* %70)
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %76
73: ; preds = %69
%74 = load i32, i32* @errno
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i32 %74)
br label %76
76: ; preds = %73, %69
%77 = load i8**, i8*** %5
%78 = getelementptr inbounds i8*, i8** %77, i64 2
%79 = load i8*, i8** %78
%80 = icmp ne i8* %79, null
br i1 %80, label %81, label %87
81: ; preds = %76
%82 = load i8**, i8*** %5
%83 = getelementptr inbounds i8*, i8** %82, i64 2
%84 = load i8*, i8** %83
%85 = call i64 @strcmp(i8* %84, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%86 = icmp ne i64 %85, 0
br i1 %86, label %95, label %87
87: ; preds = %81, %76
%88 = load i8*, i8** %8
%89 = call i64 @filetimes(i8* %88)
%90 = icmp ne i64 %89, 0
br i1 %90, label %91, label %94
91: ; preds = %87
%92 = load i32, i32* @errno
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.9, i64 0, i64 0), i32 %92)
br label %94
94: ; preds = %91, %87
br label %95
95: ; preds = %94, %81
br label %42
96: ; preds = %42
%97 = load i32*, i32** %6
%98 = call i32 @closedir(i32* %97)
ret i32 0
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [3 x i8] c"-h\00"
@.str.1 = [22 x i8] c"Usage: %s <dir name>\0A\00"
@.str.5 = [20 x i8] c"opendir(%s) failed\0A\00"
@.str.7 = [33 x i8] c"Something went wrong! Errno: %d\0A\00"
@errno = global i32 0
@.str.8 = [3 x i8] c"-p\00"
@.str.9 = [46 x i8] c"[filetimes]: Something went wrong! Errno: %d\0A\00"
@str = [20 x i8] c"Null pointer found!\00"
@str.10 = [15 x i8] c"-h \09 Show help\00"
@str.11 = [33 x i8] c"-vvv \09 Be Very Verbose (default)\00"
@str.12 = [16 x i8] c"-P \09 Be Precise\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %11, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
%9 = icmp ugt i32 %0, 3
%10 = or i1 %9, %8
br i1 %10, label %11, label %18
11: ; preds = %4, %2
%12 = load i8*, i8** %1
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.10, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.11, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.12, i64 0, i64 0))
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %4
%19 = load i8*, i8** %5
%20 = tail call i32* @opendir(i8* %19)
%21 = icmp eq i32* %20, null
br i1 %21, label %27, label %22
22: ; preds = %18
%23 = tail call %struct.dirent* @readdir(i32* %20)
%24 = icmp eq %struct.dirent* %23, null
br i1 %24, label %72, label %25
25: ; preds = %22
%26 = getelementptr inbounds i8*, i8** %1, i64 2
br label %31
27: ; preds = %18
%28 = load i8*, i8** %5
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %28)
%30 = tail call i32 @exit(i32 1)
unreachable
31: ; preds = %25, %69
%32 = phi %struct.dirent* [ %23, %25 ], [ %70, %69 ]
%33 = getelementptr inbounds %struct.dirent, %struct.dirent* %32, i64 0, i32 0
%34 = load i8*, i8** %33
%35 = icmp eq i8* %34, null
br i1 %35, label %36, label %39
36: ; preds = %31
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%38 = tail call i32 @exit(i32 2)
unreachable
39: ; preds = %31
%40 = tail call i64 @filepermissions(i8* %34)
%41 = icmp eq i64 %40, 0
br i1 %41, label %45, label %42
42: ; preds = %39
%43 = load i32, i32* @errno
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %42, %39
%46 = tail call i64 @fileownership(i8* %34)
%47 = icmp eq i64 %46, 0
br i1 %47, label %51, label %48
48: ; preds = %45
%49 = load i32, i32* @errno
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %48, %45
%52 = tail call i64 @filesizes(i8* %34)
%53 = icmp eq i64 %52, 0
br i1 %53, label %57, label %54
54: ; preds = %51
%55 = load i32, i32* @errno
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i32 %55)
br label %57
57: ; preds = %54, %51
%58 = load i8*, i8** %26
%59 = icmp eq i8* %58, null
br i1 %59, label %63, label %60
60: ; preds = %57
%61 = tail call i64 @strcmp(i8* %58, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %69
63: ; preds = %60, %57
%64 = tail call i64 @filetimes(i8* %34)
%65 = icmp eq i64 %64, 0
br i1 %65, label %69, label %66
66: ; preds = %63
%67 = load i32, i32* @errno
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.9, i64 0, i64 0), i32 %67)
br label %69
69: ; preds = %63, %66, %60
%70 = tail call %struct.dirent* @readdir(i32* %20)
%71 = icmp eq %struct.dirent* %70, null
br i1 %71, label %72, label %31
72: ; preds = %69, %22
%73 = tail call i32 @closedir(i32* %20)
ret i32 0
}