#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 */

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int PATH_MAX;
int /*<<< orphan*/ cleanup_directory_content(char *, int, int);
int /*<<< orphan*/ collector_init();
int /*<<< orphan*/ collector_print();
int /*<<< orphan*/ generate_directory_content(char *, int, int);
int /*<<< orphan*/ init_filename_generator();
int /*<<< orphan*/ printf(char *, char *);
size_t strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(int argc, char *argv[]) {
  if (argc == 1) {
    printf("Usage: %s [test_dir] ... [test_dir]\n", argv[0]);
    return EXIT_FAILURE;
  }
  int i;
  for (i = 1; i < argc; ++i) {
    char test_path[PATH_MAX];
    strncpy(test_path, argv[i], PATH_MAX);
    size_t test_path_len = strlen(test_path);
    if (test_path[test_path_len - 1] != '/') {
      test_path[test_path_len + 1] = 0;
      test_path[test_path_len] = '/';
    }
    printf("test_path is \"%s\"\n", test_path);
    collector_init();
    init_filename_generator();
    generate_directory_content(test_path, 5, 3);
    init_filename_generator();
    cleanup_directory_content(test_path, 5, 3);
    collector_print();
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11c4 <main+0x44>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe52(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12ce <main+0x14e>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12c2 <main+0x142>
mov    0x2e12(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    0x2dda(%rip),%rax
mov    (%rax),%edx
call   1030 <strncpy@plt>
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
mov    %rcx,-0x30(%rbp)
mov    -0x30(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
je     125b <main+0xdb>
mov    -0x38(%rbp),%rax
mov    -0x30(%rbp),%rcx
movb   $0x0,0x1(%rax,%rcx,1)
mov    -0x30(%rbp),%rcx
movb   $0x2f,(%rax,%rcx,1)
mov    -0x38(%rbp),%rsi
lea    0xdbf(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <collector_init@plt>
mov    $0x0,%al
call   1080 <init_filename_generator@plt>
mov    -0x38(%rbp),%rdi
mov    $0x5,%esi
mov    $0x3,%edx
call   10a0 <generate_directory_content@plt>
mov    $0x0,%al
call   1080 <init_filename_generator@plt>
mov    -0x38(%rbp),%rdi
mov    $0x5,%esi
mov    $0x3,%edx
call   1090 <cleanup_directory_content@plt>
mov    $0x0,%al
call   1070 <collector_print@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11cb <main+0x4b>
mov    0x2d07(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
cmp    $0x1,%edi
jne    11b1 <main+0x31>
mov    (%r15),%rsi
lea    0xe60(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e2c(%rip),%rax
jmp    1287 <main+0x107>
mov    0x2e18(%rip),%rax
jle    1287 <main+0x107>
mov    %edi,%eax
mov    %rax,-0x30(%rbp)
mov    $0x1,%r12d
mov    0x2e1f(%rip),%r14
jmp    123c <main+0xbc>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xe3e(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <collector_init@plt>
xor    %eax,%eax
call   1080 <init_filename_generator@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x3,%edx
call   10a0 <generate_directory_content@plt>
xor    %eax,%eax
call   1080 <init_filename_generator@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x3,%edx
call   1090 <cleanup_directory_content@plt>
xor    %eax,%eax
call   1070 <collector_print@plt>
mov    %r13,%rsp
add    $0x1,%r12
cmp    %r12,-0x30(%rbp)
je     1280 <main+0x100>
mov    %rsp,%r13
mov    (%r14),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    (%r15,%r12,8),%rsi
mov    (%r14),%edx
mov    %rbx,%rdi
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmpb   $0x2f,-0x1(%rax,%rbx,1)
je     11e0 <main+0x60>
movw   $0x2f,(%rbx,%rax,1)
jmp    11e0 <main+0x60>
mov    0x2d49(%rip),%rax
mov    (%rax),%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Usage: %s [test_dir] ... [test_dir]\0A\00"
@EXIT_FAILURE = global i32 0
@PATH_MAX = global i32 0
@.str.1 = [19 x i8] c"test_path is \22%s\22\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %18
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 ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i32, i32* @EXIT_FAILURE
store i32 %17, i32* %3
br label %62
18: ; preds = %2
store i32 1, i32* %6
br label %19
19: ; preds = %57, %18
%20 = load i32, i32* %6
%21 = load i32, i32* %4
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %60
23: ; preds = %19
%24 = load i32, i32* @PATH_MAX
%25 = zext i32 %24 to i64
%26 = call i8* @llvm.stacksave()
store i8* %26, i8** %7
%27 = alloca i8, i64 %25
store i64 %25, i64* %8
%28 = load i8**, i8*** %5
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = load i32, i32* @PATH_MAX
%34 = call i32 @strncpy(i8* %27, i8* %32, i32 %33)
%35 = call i64 @strlen(i8* %27)
store i64 %35, i64* %9
%36 = load i64, i64* %9
%37 = sub i64 %36, 1
%38 = getelementptr inbounds i8, i8* %27, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 47
br i1 %41, label %42, label %48
42: ; preds = %23
%43 = load i64, i64* %9
%44 = add i64 %43, 1
%45 = getelementptr inbounds i8, i8* %27, i64 %44
store i8 0, i8* %45
%46 = load i64, i64* %9
%47 = getelementptr inbounds i8, i8* %27, i64 %46
store i8 47, i8* %47
br label %48
48: ; preds = %42, %23
%49 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%50 = call i32 (...) @collector_init()
%51 = call i32 (...) @init_filename_generator()
%52 = call i32 @generate_directory_content(i8* %27, i32 5, i32 3)
%53 = call i32 (...) @init_filename_generator()
%54 = call i32 @cleanup_directory_content(i8* %27, i32 5, i32 3)
%55 = call i32 (...) @collector_print()
%56 = load i8*, i8** %7
br label %57
57: ; preds = %48
%58 = load i32, i32* %6
%59 = add nsw i32 %58, 1
store i32 %59, i32* %6
br label %19
60: ; preds = %19
%61 = load i32, i32* @EXIT_SUCCESS
store i32 %61, i32* %3
br label %62
62: ; preds = %60, %12
%63 = load i32, i32* %3
ret i32 %63
}

LLVM IR (-O2):
@.str = [37 x i8] c"Usage: %s [test_dir] ... [test_dir]\0A\00"
@EXIT_FAILURE = global i32 0
@PATH_MAX = global i32 0
@.str.1 = [19 x i8] c"test_path is \22%s\22\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %40
6: ; preds = %4
%7 = zext i32 %0 to i64
br label %11
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %40
11: ; preds = %6, %30
%12 = phi i64 [ 1, %6 ], [ %38, %30 ]
%13 = load i32, i32* @PATH_MAX
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
%16 = alloca i8, i64 %14
%17 = getelementptr inbounds i8*, i8** %1, i64 %12
%18 = load i8*, i8** %17
%19 = load i32, i32* @PATH_MAX
%20 = call i32 @strncpy(i8* %16, i8* %18, i32 %19)
%21 = call i64 @strlen(i8* %16)
%22 = add i64 %21, -1
%23 = getelementptr inbounds i8, i8* %16, i64 %22
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 47
br i1 %25, label %30, label %26
26: ; preds = %11
%27 = add i64 %21, 1
%28 = getelementptr inbounds i8, i8* %16, i64 %27
store i8 0, i8* %28
%29 = getelementptr inbounds i8, i8* %16, i64 %21
store i8 47, i8* %29
br label %30
30: ; preds = %26, %11
%31 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%32 = call i32 (...) @collector_init()
%33 = call i32 (...) @init_filename_generator()
%34 = call i32 @generate_directory_content(i8* %16, i32 5, i32 3)
%35 = call i32 (...) @init_filename_generator()
%36 = call i32 @cleanup_directory_content(i8* %16, i32 5, i32 3)
%37 = call i32 (...) @collector_print()
%38 = add nuw nsw i64 %12, 1
%39 = icmp eq i64 %38, %7
br i1 %39, label %40, label %11
40: ; preds = %30, %4, %8
%41 = phi i32* [ @EXIT_FAILURE, %8 ], [ @EXIT_SUCCESS, %4 ], [ @EXIT_SUCCESS, %30 ]
%42 = load i32, i32* %41
ret i32 %42
}