#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 */
scalar_t__ FP_ZERO;
int box_counter(double const *const *, int, int, double, int *);
scalar_t__ fpclassify(double);
double log(double);
scalar_t__ pow(double, double);
double generalized_dimension(const double *const *data, int t, int n,
                             double epsilon, double q, int *box_num) {
  double dim;
  int box_count[t];
  const int num = box_counter(data, t, n, epsilon, box_count);
  if (fpclassify(q - 1.0) == FP_ZERO) {
    dim = 0;
    for (int i = 0; i < num; i++) {
      double mu = box_count[i] / (double)t;
      dim += mu * log(mu);
    }
    dim /= log(epsilon);
  } else {
    dim = 0;
    for (int i = 0; i < num; i++) {
      double mu = box_count[i] / (double)t;
      dim += pow(mu, q);
    }
    dim = log(dim) / (log(epsilon) * (q - 1));
  }
  if (box_num != NULL)
    *box_num = num;
  return dim;
}


x86 assembly (clang, -O0):
<generalized_dimension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
movsd  -0x18(%rbp),%xmm0
call   1030 <box_counter@plt>
mov    %eax,-0x44(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe52(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1040 <fpclassify@plt>
mov    0x2e2a(%rip),%rcx
cmp    (%rcx),%rax
jne    1259 <generalized_dimension+0x119>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    1239 <generalized_dimension+0xf9>
mov    -0x68(%rbp),%rax
movslq -0x48(%rbp),%rcx
cvtsi2sdl (%rax,%rcx,4),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1050 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x70(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    11d6 <generalized_dimension+0x96>
movsd  -0x18(%rbp),%xmm0
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    12fa <generalized_dimension+0x1ba>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    12bb <generalized_dimension+0x17b>
mov    -0x68(%rbp),%rax
movslq -0x54(%rbp),%rcx
cvtsi2sdl (%rax,%rcx,4),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1060 <pow@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1268 <generalized_dimension+0x128>
movsd  -0x30(%rbp),%xmm0
call   1050 <log@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  0xd17(%rip),%xmm3
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     130e <generalized_dimension+0x1ce>
mov    -0x44(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generalized_dimension>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rcx,%r14
movsd  %xmm1,-0x30(%rbp)
mov    %esi,%r12d
mov    %esi,%eax
mov    %rsp,%r13
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
movsd  %xmm0,-0x48(%rbp)
mov    %r13,%rcx
call   1030 <box_counter@plt>
mov    %eax,%r15d
movsd  0xe75(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
call   1040 <fpclassify@plt>
mov    0x2e47(%rip),%rcx
cmp    (%rcx),%rax
jne    1207 <generalized_dimension+0xc7>
test   %r15d,%r15d
jle    122e <generalized_dimension+0xee>
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    %r15d,%r12d
xorpd  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sdl 0x0(%r13,%rbx,4),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
call   1050 <log@plt>
mulsd  -0x38(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,-0x30(%rbp)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11d0 <generalized_dimension+0x90>
jmp    1237 <generalized_dimension+0xf7>
test   %r15d,%r15d
jle    125c <generalized_dimension+0x11c>
cvtsi2sd %r12d,%xmm2
mov    %r15d,%r12d
cmp    $0x1,%r15d
movsd  -0x30(%rbp),%xmm1
mov    %r12,-0x50(%rbp)
jne    1265 <generalized_dimension+0x125>
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
jmp    12e8 <generalized_dimension+0x1a8>
xorpd  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1050 <log@plt>
movsd  -0x30(%rbp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
test   %r14,%r14
jne    134c <generalized_dimension+0x20c>
jmp    134f <generalized_dimension+0x20f>
xorpd  %xmm0,%xmm0
jmp    1321 <generalized_dimension+0x1e1>
and    $0xfffffffe,%r12d
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
movsd  %xmm2,-0x40(%rbp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
cvtsi2sdl 0x0(%r13,%rbx,4),%xmm0
divsd  %xmm2,%xmm0
movsd  -0x30(%rbp),%xmm1
call   1060 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
cvtsi2sdl 0x4(%r13,%rbx,4),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
call   1060 <pow@plt>
movsd  -0x40(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  -0x38(%rbp),%xmm0
add    $0x2,%rbx
cmp    %rbx,%r12
jne    1280 <generalized_dimension+0x140>
testb  $0x1,-0x50(%rbp)
je     1321 <generalized_dimension+0x1e1>
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
cvtsi2sdl 0x0(%r13,%rbx,4),%xmm0
divsd  %xmm2,%xmm0
call   1060 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  -0x38(%rbp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1050 <log@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1050 <log@plt>
movsd  -0x58(%rbp),%xmm1
mulsd  %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
divsd  %xmm1,%xmm0
test   %r14,%r14
je     134f <generalized_dimension+0x20f>
mov    %r15d,(%r14)
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@FP_ZERO = global i64 0
define double @generalized_dimension(double** %0, i32 %1, i32 %2, double %3, double %4, i32* %5) {
%7 = alloca double**
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca i32*
%13 = alloca double
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i32
%17 = alloca i32
%18 = alloca double
%19 = alloca i32
%20 = alloca double
store double** %0, double*** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store double %3, double* %10
store double %4, double* %11
store i32* %5, i32** %12
%21 = load i32, i32* %8
%22 = zext i32 %21 to i64
%23 = call i8* @llvm.stacksave()
store i8* %23, i8** %14
%24 = alloca i32, i64 %22
store i64 %22, i64* %15
%25 = load double**, double*** %7
%26 = load i32, i32* %8
%27 = load i32, i32* %9
%28 = load double, double* %10
%29 = call i32 @box_counter(double** %25, i32 %26, i32 %27, double %28, i32* %24)
store i32 %29, i32* %16
%30 = load double, double* %11
%31 = fsub double %30, 1.000000e+00
%32 = call i64 @fpclassify(double %31)
%33 = load i64, i64* @FP_ZERO
%34 = icmp eq i64 %32, %33
br i1 %34, label %35, label %62
35: ; preds = %6
store double 0.000000e+00, double* %13
store i32 0, i32* %17
br label %36
36: ; preds = %54, %35
%37 = load i32, i32* %17
%38 = load i32, i32* %16
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %57
40: ; preds = %36
%41 = load i32, i32* %17
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %24, i64 %42
%44 = load i32, i32* %43
%45 = sitofp i32 %44 to double
%46 = load i32, i32* %8
%47 = sitofp i32 %46 to double
%48 = fdiv double %45, %47
store double %48, double* %18
%49 = load double, double* %18
%50 = load double, double* %18
%51 = call double @log(double %50)
%52 = load double, double* %13
%53 = call double @llvm.fmuladd.f64(double %49, double %51, double %52)
store double %53, double* %13
br label %54
54: ; preds = %40
%55 = load i32, i32* %17
%56 = add nsw i32 %55, 1
store i32 %56, i32* %17
br label %36
57: ; preds = %36
%58 = load double, double* %10
%59 = call double @log(double %58)
%60 = load double, double* %13
%61 = fdiv double %60, %59
store double %61, double* %13
br label %94
62: ; preds = %6
store double 0.000000e+00, double* %13
store i32 0, i32* %19
br label %63
63: ; preds = %82, %62
%64 = load i32, i32* %19
%65 = load i32, i32* %16
%66 = icmp slt i32 %64, %65
br i1 %66, label %67, label %85
67: ; preds = %63
%68 = load i32, i32* %19
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %24, i64 %69
%71 = load i32, i32* %70
%72 = sitofp i32 %71 to double
%73 = load i32, i32* %8
%74 = sitofp i32 %73 to double
%75 = fdiv double %72, %74
store double %75, double* %20
%76 = load double, double* %20
%77 = load double, double* %11
%78 = call i64 @pow(double %76, double %77)
%79 = sitofp i64 %78 to double
%80 = load double, double* %13
%81 = fadd double %80, %79
store double %81, double* %13
br label %82
82: ; preds = %67
%83 = load i32, i32* %19
%84 = add nsw i32 %83, 1
store i32 %84, i32* %19
br label %63
85: ; preds = %63
%86 = load double, double* %13
%87 = call double @log(double %86)
%88 = load double, double* %10
%89 = call double @log(double %88)
%90 = load double, double* %11
%91 = fsub double %90, 1.000000e+00
%92 = fmul double %89, %91
%93 = fdiv double %87, %92
store double %93, double* %13
br label %94
94: ; preds = %85, %57
%95 = load i32*, i32** %12
%96 = icmp ne i32* %95, null
br i1 %96, label %97, label %100
97: ; preds = %94
%98 = load i32, i32* %16
%99 = load i32*, i32** %12
store i32 %98, i32* %99
br label %100
100: ; preds = %97, %94
%101 = load double, double* %13
%102 = load i8*, i8** %14
ret double %101
}

LLVM IR (-O2):
@FP_ZERO = global i64 0
define double @generalized_dimension(double** %0, i32 %1, i32 %2, double %3, double %4, i32* writeonly %5) {
%7 = zext i32 %1 to i64
%8 = alloca i32, i64 %7
%9 = call i32 @box_counter(double** %0, i32 %1, i32 %2, double %3, i32* %8)
%10 = fadd double %4, -1.000000e+00
%11 = call i64 @fpclassify(double %10)
%12 = load i64, i64* @FP_ZERO
%13 = icmp eq i64 %11, %12
%14 = icmp sgt i32 %9, 0
br i1 %13, label %23, label %15
15: ; preds = %6
br i1 %14, label %16, label %55
16: ; preds = %15
%17 = sitofp i32 %1 to double
%18 = zext i32 %9 to i64
%19 = and i64 %18, 1
%20 = icmp eq i32 %9, 1
br i1 %20, label %42, label %21
21: ; preds = %16
%22 = and i64 %18, 4294967294
br label %61
23: ; preds = %6
br i1 %14, label %24, label %27
24: ; preds = %23
%25 = sitofp i32 %1 to double
%26 = zext i32 %9 to i64
br label %31
27: ; preds = %31, %23
%28 = phi double [ 0.000000e+00, %23 ], [ %39, %31 ]
%29 = call double @log(double %3)
%30 = fdiv double %28, %29
br label %83
31: ; preds = %24, %31
%32 = phi i64 [ 0, %24 ], [ %40, %31 ]
%33 = phi double [ 0.000000e+00, %24 ], [ %39, %31 ]
%34 = getelementptr inbounds i32, i32* %8, i64 %32
%35 = load i32, i32* %34
%36 = sitofp i32 %35 to double
%37 = fdiv double %36, %25
%38 = call double @log(double %37)
%39 = call double @llvm.fmuladd.f64(double %37, double %38, double %33)
%40 = add nuw nsw i64 %32, 1
%41 = icmp eq i64 %40, %26
br i1 %41, label %27, label %31
42: ; preds = %61, %16
%43 = phi double [ undef, %16 ], [ %79, %61 ]
%44 = phi i64 [ 0, %16 ], [ %80, %61 ]
%45 = phi double [ 0.000000e+00, %16 ], [ %79, %61 ]
%46 = icmp eq i64 %19, 0
br i1 %46, label %55, label %47
47: ; preds = %42
%48 = getelementptr inbounds i32, i32* %8, i64 %44
%49 = load i32, i32* %48
%50 = sitofp i32 %49 to double
%51 = fdiv double %50, %17
%52 = call i64 @pow(double %51, double %4)
%53 = sitofp i64 %52 to double
%54 = fadd double %45, %53
br label %55
55: ; preds = %47, %42, %15
%56 = phi double [ 0.000000e+00, %15 ], [ %43, %42 ], [ %54, %47 ]
%57 = call double @log(double %56)
%58 = call double @log(double %3)
%59 = fmul double %10, %58
%60 = fdiv double %57, %59
br label %83
61: ; preds = %61, %21
%62 = phi i64 [ 0, %21 ], [ %80, %61 ]
%63 = phi double [ 0.000000e+00, %21 ], [ %79, %61 ]
%64 = phi i64 [ 0, %21 ], [ %81, %61 ]
%65 = getelementptr inbounds i32, i32* %8, i64 %62
%66 = load i32, i32* %65
%67 = sitofp i32 %66 to double
%68 = fdiv double %67, %17
%69 = call i64 @pow(double %68, double %4)
%70 = sitofp i64 %69 to double
%71 = fadd double %63, %70
%72 = or i64 %62, 1
%73 = getelementptr inbounds i32, i32* %8, i64 %72
%74 = load i32, i32* %73
%75 = sitofp i32 %74 to double
%76 = fdiv double %75, %17
%77 = call i64 @pow(double %76, double %4)
%78 = sitofp i64 %77 to double
%79 = fadd double %71, %78
%80 = add nuw nsw i64 %62, 2
%81 = add i64 %64, 2
%82 = icmp eq i64 %81, %22
br i1 %82, label %42, label %61
83: ; preds = %55, %27
%84 = phi double [ %30, %27 ], [ %60, %55 ]
%85 = icmp eq i32* %5, null
br i1 %85, label %87, label %86
86: ; preds = %83
store i32 %9, i32* %5
br label %87
87: ; preds = %86, %83
ret double %84
}