#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 */
long determine_size(long, long);
int /*<<< orphan*/ do_subtree(long *, long *, long, long, long, long);
long *malloc(long);
int /*<<< orphan*/ srand(int);
void make_fractal_tree(long median_file_size, long maximum_file_size,
                       long median_dir_nr_files, long max_dir_nr_files,
                       long median_dir_branching, long max_dir_branching,
                       long nr_files) {
  long *sizes_start;
  long *sizes_end;
  long *sizes_index;
  long remaining_files = nr_files;
  sizes_index = sizes_start = malloc(nr_files * sizeof(long));
  for (; remaining_files > 0;) {
    *sizes_index = determine_size(median_dir_nr_files, max_dir_nr_files);
    if (*sizes_index == 0)
      *sizes_index = 1;
    *sizes_index =
        (*sizes_index < remaining_files) ? *sizes_index : remaining_files;
    remaining_files -= *sizes_index;
    sizes_index++;
  }
  sizes_end = (sizes_index-- > sizes_start) ? sizes_index : sizes_start;
  sizes_index = sizes_start;
  srand(1);
  do_subtree(sizes_start, sizes_end, median_file_size, maximum_file_size,
             median_dir_branching, max_dir_branching);
}


x86 assembly (clang, -O0):
<make_fractal_tree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    0x10(%rbp),%rdi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x50(%rbp)
jle    1213 <make_fractal_tree+0xd3>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <determine_size@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x48(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11bc <make_fractal_tree+0x7c>
mov    -0x48(%rbp),%rax
movq   $0x1,(%rax)
mov    -0x48(%rbp),%rax
mov    (%rax),%rax
cmp    -0x50(%rbp),%rax
jge    11dd <make_fractal_tree+0x9d>
mov    -0x48(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
jmp    11e5 <make_fractal_tree+0xa5>
mov    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rcx
mov    -0x48(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x48(%rbp),%rax
mov    (%rax),%rcx
mov    -0x50(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x48(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x48(%rbp)
jmp    1181 <make_fractal_tree+0x41>
mov    -0x48(%rbp),%rax
mov    %rax,%rcx
add    $0xfffffffffffffff8,%rcx
mov    %rcx,-0x48(%rbp)
cmp    -0x38(%rbp),%rax
jbe    1239 <make_fractal_tree+0xf9>
mov    -0x48(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    1241 <make_fractal_tree+0x101>
mov    -0x38(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    $0x1,%edi
call   1030 <srand@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
call   1060 <do_subtree@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_fractal_tree>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,0x20(%rsp)
mov    %r8,0x18(%rsp)
mov    %rcx,%rbp
mov    %rdx,%r14
mov    %rsi,0x10(%rsp)
mov    %rdi,0x8(%rsp)
mov    0x60(%rsp),%r15
lea    0x0(,%r15,8),%rdi
call   1040 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rbx
test   %r15,%r15
jle    11b5 <make_fractal_tree+0x75>
mov    $0x1,%r13d
mov    %r12,%rbx
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rbp,%rsi
call   1050 <determine_size@plt>
test   %rax,%rax
cmove  %r13,%rax
cmp    %r15,%rax
cmovge %r15,%rax
mov    %rax,(%rbx)
add    $0x8,%rbx
sub    %rax,%r15
jg     1190 <make_fractal_tree+0x50>
lea    -0x8(%rbx),%rbp
cmp    %r12,%rbx
cmovbe %r12,%rbp
mov    $0x1,%edi
call   1030 <srand@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    0x8(%rsp),%rdx
mov    0x10(%rsp),%rcx
mov    0x18(%rsp),%r8
mov    0x20(%rsp),%r9
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <do_subtree@plt>

LLVM IR (-O0):
define void @make_fractal_tree(i64 %0, i64 %1, i64 %2, i64 %3, i64 %4, i64 %5, i64 %6) {
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64*
%16 = alloca i64*
%17 = alloca i64*
%18 = alloca i64
store i64 %0, i64* %8
store i64 %1, i64* %9
store i64 %2, i64* %10
store i64 %3, i64* %11
store i64 %4, i64* %12
store i64 %5, i64* %13
store i64 %6, i64* %14
%19 = load i64, i64* %14
store i64 %19, i64* %18
%20 = load i64, i64* %14
%21 = mul i64 %20, 8
%22 = call i64* @malloc(i64 %21)
store i64* %22, i64** %15
store i64* %22, i64** %17
br label %23
23: ; preds = %46, %7
%24 = load i64, i64* %18
%25 = icmp sgt i64 %24, 0
br i1 %25, label %26, label %55
26: ; preds = %23
%27 = load i64, i64* %10
%28 = load i64, i64* %11
%29 = call i64 @determine_size(i64 %27, i64 %28)
%30 = load i64*, i64** %17
store i64 %29, i64* %30
%31 = load i64*, i64** %17
%32 = load i64, i64* %31
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %26
%35 = load i64*, i64** %17
store i64 1, i64* %35
br label %36
36: ; preds = %34, %26
%37 = load i64*, i64** %17
%38 = load i64, i64* %37
%39 = load i64, i64* %18
%40 = icmp slt i64 %38, %39
br i1 %40, label %41, label %44
41: ; preds = %36
%42 = load i64*, i64** %17
%43 = load i64, i64* %42
br label %46
44: ; preds = %36
%45 = load i64, i64* %18
br label %46
46: ; preds = %44, %41
%47 = phi i64 [ %43, %41 ], [ %45, %44 ]
%48 = load i64*, i64** %17
store i64 %47, i64* %48
%49 = load i64*, i64** %17
%50 = load i64, i64* %49
%51 = load i64, i64* %18
%52 = sub nsw i64 %51, %50
store i64 %52, i64* %18
%53 = load i64*, i64** %17
%54 = getelementptr inbounds i64, i64* %53, i32 1
store i64* %54, i64** %17
br label %23
55: ; preds = %23
%56 = load i64*, i64** %17
%57 = getelementptr inbounds i64, i64* %56, i32 -1
store i64* %57, i64** %17
%58 = load i64*, i64** %15
%59 = icmp ugt i64* %56, %58
br i1 %59, label %60, label %62
60: ; preds = %55
%61 = load i64*, i64** %17
br label %64
62: ; preds = %55
%63 = load i64*, i64** %15
br label %64
64: ; preds = %62, %60
%65 = phi i64* [ %61, %60 ], [ %63, %62 ]
store i64* %65, i64** %16
%66 = load i64*, i64** %15
store i64* %66, i64** %17
%67 = call i32 @srand(i32 1)
%68 = load i64*, i64** %15
%69 = load i64*, i64** %16
%70 = load i64, i64* %8
%71 = load i64, i64* %9
%72 = load i64, i64* %12
%73 = load i64, i64* %13
%74 = call i32 @do_subtree(i64* %68, i64* %69, i64 %70, i64 %71, i64 %72, i64 %73)
ret void
}

LLVM IR (-O2):
define void @make_fractal_tree(i64 %0, i64 %1, i64 %2, i64 %3, i64 %4, i64 %5, i64 %6) {
%8 = shl i64 %6, 3
%9 = tail call i64* @malloc(i64 %8)
%10 = icmp sgt i64 %6, 0
br i1 %10, label %11, label %22
11: ; preds = %7, %11
%12 = phi i64 [ %19, %11 ], [ %6, %7 ]
%13 = phi i64* [ %20, %11 ], [ %9, %7 ]
%14 = tail call i64 @determine_size(i64 %2, i64 %3)
%15 = icmp eq i64 %14, 0
%16 = select i1 %15, i64 1, i64 %14
%17 = icmp slt i64 %16, %12
%18 = select i1 %17, i64 %16, i64 %12
store i64 %18, i64* %13
%19 = sub nsw i64 %12, %18
%20 = getelementptr inbounds i64, i64* %13, i64 1
%21 = icmp sgt i64 %19, 0
br i1 %21, label %11, label %22
22: ; preds = %11, %7
%23 = phi i64* [ %9, %7 ], [ %20, %11 ]
%24 = getelementptr inbounds i64, i64* %23, i64 -1
%25 = icmp ugt i64* %23, %9
%26 = select i1 %25, i64* %24, i64* %9
%27 = tail call i32 @srand(i32 1)
%28 = tail call i32 @do_subtree(i64* %9, i64* %26, i64 %0, i64 %1, i64 %4, i64 %5)
ret void
}