#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 /*<<< orphan*/ printf(char *, ...);
void print_statistics(int depth, int read_bucket_inserted,
                      int write_bucket_inserted, int write_bucket_duplicates,
                      int duplicates_within, int duplicates_toplayers,
                      double expanded, double upper_bound, int goal_depth,
                      int elements_written) {
  printf("\n\t******************** Depth %d Generated ********************\n",
         depth);
  printf("\t* Read in depth %d    = %u\n", depth - 1, read_bucket_inserted);
  printf("\t* Inserted            = %d\n", write_bucket_inserted);
  printf("\t* Duplicates:          \n");
  printf("\t*             Buffers = %d - \n", write_bucket_duplicates);
  printf("\t*      External Merge = %d - \n", duplicates_within);
  printf("\t*     Previous Layers = %d - \n", duplicates_toplayers);
  printf("\t*     ---------------------------\n");
  printf("\t*  D = %d  *Remaining = %u\n", depth,
         write_bucket_inserted - write_bucket_duplicates - duplicates_within -
             duplicates_toplayers);
  printf("\t*     Expanded So Far = %.0f \n", expanded);
  printf("\t*     Best goal cost  = %.2f at depth %d \n", upper_bound,
         goal_depth);
  if (elements_written != (write_bucket_inserted - write_bucket_duplicates -
                           duplicates_within - duplicates_toplayers)) {
    printf("\t*       ERROR: Incorrect number of elements written: It shoud be "
           "%d \n",
           elements_written);
    printf("\t*   Possible cause: MAX_IO_BUFFERS is too low for the final "
           "merge!\n ");
    printf("\t*   There are more buffers than %d for final merge\n", 1000);
  }
  printf("\t************************************************************\n");
}


x86 assembly (clang, -O0):
<print_statistics>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9d,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
mov    -0x4(%rbp),%esi
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
sub    $0x1,%esi
mov    -0x8(%rbp),%edx
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xeef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xf07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xf16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xf25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
mov    -0xc(%rbp),%edx
sub    -0x10(%rbp),%edx
sub    -0x14(%rbp),%edx
sub    -0x18(%rbp),%edx
lea    0xf3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xf48(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
mov    0x10(%rbp),%esi
lea    0xf52(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x18(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x10(%rbp),%ecx
sub    -0x14(%rbp),%ecx
sub    -0x18(%rbp),%ecx
cmp    %ecx,%eax
je     1253 <print_statistics+0x143>
mov    0x18(%rbp),%esi
lea    0xf56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfc7(%rip),%rdi
mov    $0x3e8,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfe9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_statistics>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %r9d,%r12d
mov    %r8d,%r14d
mov    %ecx,%ebx
mov    %edx,%ebp
mov    %esi,%r15d
mov    %edi,%r13d
mov    0x58(%rsp),%eax
mov    %eax,0x4(%rsp)
mov    0x50(%rsp),%eax
mov    %eax,(%rsp)
lea    0xea0(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x1(%r13),%esi
lea    0xecb(%rip),%rdi
mov    %r15d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed7(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x106f(%rip),%rdi
call   1030 <puts@plt>
lea    0xed8(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee8(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef7(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x104a(%rip),%rdi
call   1030 <puts@plt>
add    %r14d,%ebx
add    %r12d,%ebx
sub    %ebx,%ebp
lea    0xef2(%rip),%rdi
mov    %r13d,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xefc(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xf08(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    (%rsp),%esi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
cmp    %esi,%ebp
je     1256 <print_statistics+0x136>
lea    0xf15(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf4e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf86(%rip),%rdi
mov    $0x3e8,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xfe4(%rip),%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [64 x i8] c"\0A\09******************** Depth %d Generated ********************\0A\00"
@.str.1 = [29 x i8] c"\09* Read in depth %d = %u\0A\00"
@.str.2 = [29 x i8] c"\09* Inserted = %d\0A\00"
@.str.3 = [26 x i8] c"\09* Duplicates: \0A\00"
@.str.4 = [32 x i8] c"\09* Buffers = %d - \0A\00"
@.str.5 = [32 x i8] c"\09* External Merge = %d - \0A\00"
@.str.6 = [32 x i8] c"\09* Previous Layers = %d - \0A\00"
@.str.7 = [36 x i8] c"\09* ---------------------------\0A\00"
@.str.8 = [29 x i8] c"\09* D = %d *Remaining = %u\0A\00"
@.str.9 = [32 x i8] c"\09* Expanded So Far = %.0f \0A\00"
@.str.10 = [44 x i8] c"\09* Best goal cost = %.2f at depth %d \0A\00"
@.str.11 = [71 x i8] c"\09* ERROR: Incorrect number of elements written: It shoud be %d \0A\00"
@.str.12 = [70 x i8] c"\09* Possible cause: MAX_IO_BUFFERS is too low for the final merge!\0A \00"
@.str.13 = [53 x i8] c"\09* There are more buffers than %d for final merge\0A\00"
@.str.14 = [63 x i8] c"\09************************************************************\0A\00"
define void @print_statistics(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, double %6, double %7, i32 %8, i32 %9) {
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca double
%18 = alloca double
%19 = alloca i32
%20 = alloca i32
store i32 %0, i32* %11
store i32 %1, i32* %12
store i32 %2, i32* %13
store i32 %3, i32* %14
store i32 %4, i32* %15
store i32 %5, i32* %16
store double %6, double* %17
store double %7, double* %18
store i32 %8, i32* %19
store i32 %9, i32* %20
%21 = load i32, i32* %11
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %11
%24 = sub nsw i32 %23, 1
%25 = load i32, i32* %12
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %24, i32 %25)
%27 = load i32, i32* %13
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%30 = load i32, i32* %14
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %15
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %16
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
%37 = load i32, i32* %11
%38 = load i32, i32* %13
%39 = load i32, i32* %14
%40 = sub nsw i32 %38, %39
%41 = load i32, i32* %15
%42 = sub nsw i32 %40, %41
%43 = load i32, i32* %16
%44 = sub nsw i32 %42, %43
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i32 %37, i32 %44)
%46 = load double, double* %17
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0), double %46)
%48 = load double, double* %18
%49 = load i32, i32* %19
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.10, i64 0, i64 0), double %48, i32 %49)
%51 = load i32, i32* %20
%52 = load i32, i32* %13
%53 = load i32, i32* %14
%54 = sub nsw i32 %52, %53
%55 = load i32, i32* %15
%56 = sub nsw i32 %54, %55
%57 = load i32, i32* %16
%58 = sub nsw i32 %56, %57
%59 = icmp ne i32 %51, %58
br i1 %59, label %60, label %65
60: ; preds = %10
%61 = load i32, i32* %20
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.11, i64 0, i64 0), i32 %61)
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.12, i64 0, i64 0))
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.13, i64 0, i64 0), i32 1000)
br label %65
65: ; preds = %60, %10
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.14, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [64 x i8] c"\0A\09******************** Depth %d Generated ********************\0A\00"
@.str.1 = [29 x i8] c"\09* Read in depth %d = %u\0A\00"
@.str.2 = [29 x i8] c"\09* Inserted = %d\0A\00"
@.str.4 = [32 x i8] c"\09* Buffers = %d - \0A\00"
@.str.5 = [32 x i8] c"\09* External Merge = %d - \0A\00"
@.str.6 = [32 x i8] c"\09* Previous Layers = %d - \0A\00"
@.str.8 = [29 x i8] c"\09* D = %d *Remaining = %u\0A\00"
@.str.9 = [32 x i8] c"\09* Expanded So Far = %.0f \0A\00"
@.str.10 = [44 x i8] c"\09* Best goal cost = %.2f at depth %d \0A\00"
@.str.11 = [71 x i8] c"\09* ERROR: Incorrect number of elements written: It shoud be %d \0A\00"
@.str.12 = [70 x i8] c"\09* Possible cause: MAX_IO_BUFFERS is too low for the final merge!\0A \00"
@.str.13 = [53 x i8] c"\09* There are more buffers than %d for final merge\0A\00"
@str = [25 x i8] c"\09* Duplicates: \00"
@str.15 = [35 x i8] c"\09* ---------------------------\00"
@str.16 = [62 x i8] c"\09************************************************************\00"
define void @print_statistics(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, double %6, double %7, i32 %8, i32 %9) {
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i32 %0)
%12 = add nsw i32 %0, -1
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %1)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %2)
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %3)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %4)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 %5)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.15, i64 0, i64 0))
%20 = add i32 %3, %4
%21 = add i32 %20, %5
%22 = sub i32 %2, %21
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i32 %0, i32 %22)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0), double %6)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.10, i64 0, i64 0), double %7, i32 %8)
%26 = icmp eq i32 %22, %9
br i1 %26, label %31, label %27
27: ; preds = %10
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @.str.11, i64 0, i64 0), i32 %9)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @.str.12, i64 0, i64 0))
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.13, i64 0, i64 0), i32 1000)
br label %31
31: ; preds = %27, %10
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.16, i64 0, i64 0))
ret void
}