#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 _p3dCheckForObjectVoxel(unsigned char *, int, int, int, int, int, int, int);
int /*<<< orphan*/ free(double *);
double log(double);
scalar_t__ malloc(int);
scalar_t__ pow(double, double);
double sqrt(double);
int p3dBoxCountingFractalDimension(unsigned char *in_im, double *fd,
                                   const int dimx, const int dimy,
                                   const int dimz,
                                   int (*wr_log)(const char *, ...)) {
  int i, j, k, ct;
  int size, boxct;
  int min_dim, max_box;
  double sizes_avg, boxes_avg, sizes_sum, boxes_sum;
  double cross, r;
  double *sizes;
  double *boxes;
  min_dim = ((((((dimx) < (dimy)) ? (dimx) : (dimy))) < (dimz))
                 ? ((((dimx) < (dimy)) ? (dimx) : (dimy)))
                 : (dimz));
  max_box = (int)(log((double)min_dim) / log(2.0) + 0.5) - 1;
  if (wr_log != NULL) {
    wr_log("\t----");
    wr_log("\tMinimum box side adopted: 2");
    wr_log("\tMaximum box side adopted: %d. ",
           (int)((pow(2, (double)max_box))));
  }
  sizes = (double *)malloc(max_box * sizeof(double));
  boxes = (double *)malloc(max_box * sizeof(double));
  sizes_avg = 0;
  boxes_avg = 0;
  for (ct = 0; ct < max_box; ct++) {
    size = (int)(pow((double)2.0, (double)ct + 1));
    boxct = 0;
#pragma omp parallel for private(i, j) reduction(+ : boxct)
    for (k = 0; k < dimz; k = k + size)
      for (j = 0; j < dimy; j = j + size)
        for (i = 0; i < dimx; i = i + size) {
          if (_p3dCheckForObjectVoxel(in_im, (int)dimx, (int)dimy, (int)dimz, i,
                                      j, k, size) == 1)
            boxct++;
        }
    sizes[ct] = -log((double)size);
    boxes[ct] = log((double)boxct);
    sizes_avg += sizes[ct];
    boxes_avg += boxes[ct];
  }
  sizes_avg /= (double)(max_box);
  boxes_avg /= (double)(max_box);
  sizes_sum = 0;
  boxes_sum = 0;
  cross = 0;
  for (ct = 0; ct < max_box; ct++) {
    cross += (boxes[ct] - boxes_avg) * (sizes[ct] - sizes_avg);
    boxes_sum += (boxes[ct] - boxes_avg) * (boxes[ct] - boxes_avg);
    sizes_sum += (sizes[ct] - sizes_avg) * (sizes[ct] - sizes_avg);
  }
  r = cross / sqrt(boxes_sum * sizes_sum);
  *fd = r * sqrt(boxes_sum) / sqrt(sizes_sum);
  if (sizes != NULL)
    free(sizes);
  if (boxes != NULL)
    free(boxes);
  return 2;
}


x86 assembly (clang, -O0):
<p3dBoxCountingFractalDimension>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    119b <p3dBoxCountingFractalDimension+0x3b>
mov    -0x14(%rbp),%eax
mov    %eax,-0x8c(%rbp)
jmp    11a4 <p3dBoxCountingFractalDimension+0x44>
mov    -0x18(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11e7 <p3dBoxCountingFractalDimension+0x87>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11cd <p3dBoxCountingFractalDimension+0x6d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x90(%rbp)
jmp    11d6 <p3dBoxCountingFractalDimension+0x76>
mov    -0x18(%rbp),%eax
mov    %eax,-0x90(%rbp)
mov    -0x90(%rbp),%eax
mov    %eax,-0x94(%rbp)
jmp    11f0 <p3dBoxCountingFractalDimension+0x90>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x94(%rbp)
mov    -0x94(%rbp),%eax
mov    %eax,-0x44(%rbp)
cvtsi2sdl -0x44(%rbp),%xmm0
call   1060 <log@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  0xdf5(%rip),%xmm0
call   1060 <log@plt>
movaps %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
movsd  0xdd1(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
sub    $0x1,%eax
mov    %eax,-0x48(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1291 <p3dBoxCountingFractalDimension+0x131>
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   *-0x28(%rbp)
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   *-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0xa8(%rbp)
cvtsi2sdl -0x48(%rbp),%xmm1
movsd  0xd90(%rip),%xmm0
call   1070 <pow@plt>
mov    -0xa8(%rbp),%rcx
mov    %eax,%esi
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   *%rcx
movslq -0x48(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x80(%rbp)
movslq -0x48(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x88(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x48(%rbp),%eax
jge    1439 <p3dBoxCountingFractalDimension+0x2d9>
cvtsi2sdl -0x38(%rbp),%xmm1
movsd  0xd26(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xd12(%rip),%xmm0
call   1070 <pow@plt>
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    13b2 <p3dBoxCountingFractalDimension+0x252>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    139f <p3dBoxCountingFractalDimension+0x23f>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    138c <p3dBoxCountingFractalDimension+0x22c>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
mov    -0x30(%rbp),%r9d
mov    -0x34(%rbp),%r10d
mov    -0x3c(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1040 <_p3dCheckForObjectVoxel@plt>
cmp    $0x1,%eax
jne    1379 <p3dBoxCountingFractalDimension+0x219>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    137e <p3dBoxCountingFractalDimension+0x21e>
mov    -0x2c(%rbp),%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    1332 <p3dBoxCountingFractalDimension+0x1d2>
jmp    1391 <p3dBoxCountingFractalDimension+0x231>
mov    -0x30(%rbp),%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    131f <p3dBoxCountingFractalDimension+0x1bf>
jmp    13a4 <p3dBoxCountingFractalDimension+0x244>
mov    -0x34(%rbp),%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    130c <p3dBoxCountingFractalDimension+0x1ac>
cvtsi2sdl -0x3c(%rbp),%xmm0
call   1060 <log@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x80(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
cvtsi2sdl -0x40(%rbp),%xmm0
call   1060 <log@plt>
mov    -0x88(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x80(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x88(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    12d1 <p3dBoxCountingFractalDimension+0x171>
cvtsi2sdl -0x48(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
cvtsi2sdl -0x48(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x70(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x48(%rbp),%eax
jge    1543 <p3dBoxCountingFractalDimension+0x3e3>
mov    -0x88(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x58(%rbp),%xmm0
mov    -0x80(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
subsd  -0x50(%rbp),%xmm2
movsd  -0x70(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x88(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x58(%rbp),%xmm0
mov    -0x88(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
subsd  -0x58(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x80(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x50(%rbp),%xmm0
mov    -0x80(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
subsd  -0x50(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    147e <p3dBoxCountingFractalDimension+0x31e>
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x68(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
call   1080 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0xc0(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0x68(%rbp),%xmm0
call   1080 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0xb8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x60(%rbp),%xmm0
call   1080 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0xb0(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
cmpq   $0x0,-0x80(%rbp)
je     15d6 <p3dBoxCountingFractalDimension+0x476>
mov    -0x80(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x88(%rbp)
je     15f0 <p3dBoxCountingFractalDimension+0x490>
mov    -0x88(%rbp),%rdi
call   1030 <free@plt>
mov    $0x2,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<p3dBoxCountingFractalDimension>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %r9,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
cmp    %ecx,%edx
mov    %ecx,0x10(%rsp)
mov    %ecx,%eax
mov    %edx,0x30(%rsp)
cmovl  %edx,%eax
cmp    %r8d,%eax
mov    %r8d,0x40(%rsp)
cmovge %r8d,%eax
cvtsi2sd %eax,%xmm0
call   1060 <log@plt>
divsd  0xe5a(%rip),%xmm0
addsd  0xe5a(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    %rax,0x50(%rsp)
lea    -0x1(%rax),%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
test   %r15,%r15
movapd %xmm0,0x80(%rsp)
je     120b <p3dBoxCountingFractalDimension+0xab>
lea    0xe5a(%rip),%rdi
xor    %eax,%eax
call   *%r15
lea    0xe54(%rip),%rdi
xor    %eax,%eax
call   *%r15
movsd  0xe21(%rip),%xmm0
movapd 0x80(%rsp),%xmm1
call   1070 <pow@plt>
lea    0xe4f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   *%r15
lea    0x0(,%rbp,8),%r15d
mov    %r15d,%edi
call   1050 <malloc@plt>
mov    %rax,0x8(%rsp)
mov    %r15d,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
xorpd  %xmm6,%xmm6
xorpd  %xmm3,%xmm3
xorpd  %xmm5,%xmm5
cmpl   $0x2,0x50(%rsp)
jl     14b4 <p3dBoxCountingFractalDimension+0x354>
mov    %rbx,0x78(%rsp)
mov    %r14,0x60(%rsp)
mov    %rbp,0x58(%rsp)
mov    %ebp,%eax
mov    %rax,0x28(%rsp)
xorpd  %xmm4,%xmm4
xor    %eax,%eax
mov    %r15,0x68(%rsp)
jmp    12d4 <p3dBoxCountingFractalDimension+0x174>
cs nopw 0x0(%rax,%rax,1)
nop
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
call   1060 <log@plt>
xorpd  0xd9b(%rip),%xmm0
mov    0x8(%rsp),%rbx
mov    0x70(%rsp),%rbp
movlpd %xmm0,(%rbx,%rbp,8)
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
call   1060 <log@plt>
mov    %rbp,%rax
mov    0x68(%rsp),%r15
movsd  %xmm0,(%r15,%rbp,8)
movsd  (%rbx,%rbp,8),%xmm1
unpcklpd %xmm0,%xmm1
movapd 0x90(%rsp),%xmm4
addpd  %xmm1,%xmm4
add    $0x1,%rax
cmp    0x28(%rsp),%rax
je     13b2 <p3dBoxCountingFractalDimension+0x252>
movapd %xmm4,0x90(%rsp)
mov    %rax,0x70(%rsp)
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
addsd  0xd27(%rip),%xmm1
movsd  0xd17(%rip),%xmm0
call   1070 <pow@plt>
mov    %rax,%r15
mov    $0x0,%r14d
mov    0x40(%rsp),%eax
test   %eax,%eax
mov    0x10(%rsp),%edx
mov    0x30(%rsp),%esi
jle    1270 <p3dBoxCountingFractalDimension+0x110>
xor    %ebx,%ebx
xor    %r14d,%r14d
jmp    133b <p3dBoxCountingFractalDimension+0x1db>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    %r15d,%ebx
cmp    %eax,%ebx
jge    1270 <p3dBoxCountingFractalDimension+0x110>
test   %edx,%edx
jle    1330 <p3dBoxCountingFractalDimension+0x1d0>
xor    %r12d,%r12d
jmp    1358 <p3dBoxCountingFractalDimension+0x1f8>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    %r15d,%r12d
cmp    %edx,%r12d
jge    1330 <p3dBoxCountingFractalDimension+0x1d0>
test   %esi,%esi
jle    1350 <p3dBoxCountingFractalDimension+0x1f0>
xor    %r13d,%r13d
mov    0x78(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%rdi
mov    0x30(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0x40(%rsp),%ecx
mov    %r13d,%r8d
mov    %r12d,%r9d
push   %r15
push   %rbx
call   1040 <_p3dCheckForObjectVoxel@plt>
mov    0x40(%rsp),%esi
mov    0x20(%rsp),%edx
add    $0x10,%rsp
xor    %ecx,%ecx
cmp    $0x1,%eax
sete   %cl
add    %ecx,%r14d
mov    0x40(%rsp),%eax
add    %r15d,%r13d
cmp    %esi,%r13d
jl     1370 <p3dBoxCountingFractalDimension+0x210>
jmp    1350 <p3dBoxCountingFractalDimension+0x1f0>
xorpd  %xmm6,%xmm6
xorpd  %xmm5,%xmm5
cmpl   $0x2,0x50(%rsp)
mov    0x60(%rsp),%r14
xorpd  %xmm3,%xmm3
mov    0x58(%rsp),%rax
jl     14b4 <p3dBoxCountingFractalDimension+0x354>
movapd 0x80(%rsp),%xmm0
unpcklpd %xmm0,%xmm0
divpd  %xmm0,%xmm4
cmp    $0x1,%eax
jne    1403 <p3dBoxCountingFractalDimension+0x2a3>
xorpd  %xmm0,%xmm0
xorpd  %xmm5,%xmm5
xor    %eax,%eax
testb  $0x1,0x28(%rsp)
jne    1488 <p3dBoxCountingFractalDimension+0x328>
jmp    14b4 <p3dBoxCountingFractalDimension+0x354>
mov    0x28(%rsp),%rcx
and    $0xfffffffe,%ecx
xorpd  %xmm0,%xmm0
xorpd  %xmm5,%xmm5
xor    %eax,%eax
mov    0x8(%rsp),%rdx
nopw   0x0(%rax,%rax,1)
movsd  (%rdx,%rax,8),%xmm1
movsd  0x8(%rdx,%rax,8),%xmm6
movhpd (%r15,%rax,8),%xmm1
subpd  %xmm4,%xmm1
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm5,%xmm2
mulpd  %xmm1,%xmm1
addpd  %xmm0,%xmm1
movhpd 0x8(%r15,%rax,8),%xmm6
subpd  %xmm4,%xmm6
movapd %xmm6,%xmm5
unpckhpd %xmm6,%xmm5
mulsd  %xmm6,%xmm5
addsd  %xmm2,%xmm5
mulpd  %xmm6,%xmm6
movapd %xmm6,%xmm0
addpd  %xmm1,%xmm0
add    $0x2,%rax
cmp    %rax,%rcx
jne    1420 <p3dBoxCountingFractalDimension+0x2c0>
addpd  %xmm1,%xmm6
testb  $0x1,0x28(%rsp)
je     14b4 <p3dBoxCountingFractalDimension+0x354>
mov    0x8(%rsp),%rcx
movsd  (%rcx,%rax,8),%xmm6
movhpd (%r15,%rax,8),%xmm6
subpd  %xmm4,%xmm6
movapd %xmm6,%xmm1
unpckhpd %xmm6,%xmm1
mulsd  %xmm6,%xmm1
addsd  %xmm1,%xmm5
mulpd  %xmm6,%xmm6
addpd  %xmm0,%xmm6
movapd %xmm6,%xmm1
unpckhpd %xmm6,%xmm1
movapd %xmm1,%xmm0
mulsd  %xmm6,%xmm0
ucomisd %xmm3,%xmm0
movapd %xmm6,0x30(%rsp)
jb     14d6 <p3dBoxCountingFractalDimension+0x376>
sqrtsd %xmm0,%xmm0
jmp    14f3 <p3dBoxCountingFractalDimension+0x393>
movapd %xmm5,0x10(%rsp)
movapd %xmm1,0x40(%rsp)
call   1080 <sqrt@plt>
movapd 0x40(%rsp),%xmm1
movapd 0x10(%rsp),%xmm5
mov    0x8(%rsp),%rbp
divsd  %xmm0,%xmm5
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
jb     150f <p3dBoxCountingFractalDimension+0x3af>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    1528 <p3dBoxCountingFractalDimension+0x3c8>
movapd %xmm1,%xmm0
movapd %xmm5,0x10(%rsp)
call   1080 <sqrt@plt>
xorpd  %xmm2,%xmm2
movapd 0x10(%rsp),%xmm5
movapd 0x30(%rsp),%xmm1
mulsd  %xmm0,%xmm5
ucomisd %xmm2,%xmm1
jb     1541 <p3dBoxCountingFractalDimension+0x3e1>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    1556 <p3dBoxCountingFractalDimension+0x3f6>
movapd %xmm1,%xmm0
movapd %xmm5,0x10(%rsp)
call   1080 <sqrt@plt>
movapd 0x10(%rsp),%xmm5
divsd  %xmm0,%xmm5
movsd  %xmm5,(%r14)
test   %rbp,%rbp
je     156c <p3dBoxCountingFractalDimension+0x40c>
mov    %rbp,%rdi
call   1030 <free@plt>
test   %r15,%r15
je     1579 <p3dBoxCountingFractalDimension+0x419>
mov    %r15,%rdi
call   1030 <free@plt>
mov    $0x2,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"\09----\00"
@.str.1 = [29 x i8] c"\09Minimum box side adopted: 2\00"
@.str.2 = [32 x i8] c"\09Maximum box side adopted: %d. \00"
define i32 @p3dBoxCountingFractalDimension(i8* %0, double* %1, i32 %2, i32 %3, i32 %4, i32 (i8*, ...)* %5) {
%7 = alloca i8*
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32 (i8*, ...)*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double*
%28 = alloca double*
store i8* %0, i8** %7
store double* %1, double** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 (i8*, ...)* %5, i32 (i8*, ...)** %12
%29 = load i32, i32* %9
%30 = load i32, i32* %10
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %34
32: ; preds = %6
%33 = load i32, i32* %9
br label %36
34: ; preds = %6
%35 = load i32, i32* %10
br label %36
36: ; preds = %34, %32
%37 = phi i32 [ %33, %32 ], [ %35, %34 ]
%38 = load i32, i32* %11
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %50
40: ; preds = %36
%41 = load i32, i32* %9
%42 = load i32, i32* %10
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = load i32, i32* %9
br label %48
46: ; preds = %40
%47 = load i32, i32* %10
br label %48
48: ; preds = %46, %44
%49 = phi i32 [ %45, %44 ], [ %47, %46 ]
br label %52
50: ; preds = %36
%51 = load i32, i32* %11
br label %52
52: ; preds = %50, %48
%53 = phi i32 [ %49, %48 ], [ %51, %50 ]
store i32 %53, i32* %19
%54 = load i32, i32* %19
%55 = sitofp i32 %54 to double
%56 = call double @log(double %55)
%57 = call double @log(double 2.000000e+00)
%58 = fdiv double %56, %57
%59 = fadd double %58, 5.000000e-01
%60 = fptosi double %59 to i32
%61 = sub nsw i32 %60, 1
store i32 %61, i32* %20
%62 = load i32 (i8*, ...)*, i32 (i8*, ...)** %12
%63 = icmp ne i32 (i8*, ...)* %62, null
br i1 %63, label %64, label %75
64: ; preds = %52
%65 = load i32 (i8*, ...)*, i32 (i8*, ...)** %12
%66 = call i32 (i8*, ...) %65(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%67 = load i32 (i8*, ...)*, i32 (i8*, ...)** %12
%68 = call i32 (i8*, ...) %67(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%69 = load i32 (i8*, ...)*, i32 (i8*, ...)** %12
%70 = load i32, i32* %20
%71 = sitofp i32 %70 to double
%72 = call i64 @pow(double 2.000000e+00, double %71)
%73 = trunc i64 %72 to i32
%74 = call i32 (i8*, ...) %69(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %73)
br label %75
75: ; preds = %64, %52
%76 = load i32, i32* %20
%77 = sext i32 %76 to i64
%78 = mul i64 %77, 8
%79 = trunc i64 %78 to i32
%80 = call i64 @malloc(i32 %79)
%81 = inttoptr i64 %80 to double*
store double* %81, double** %27
%82 = load i32, i32* %20
%83 = sext i32 %82 to i64
%84 = mul i64 %83, 8
%85 = trunc i64 %84 to i32
%86 = call i64 @malloc(i32 %85)
%87 = inttoptr i64 %86 to double*
store double* %87, double** %28
store double 0.000000e+00, double* %21
store double 0.000000e+00, double* %22
store i32 0, i32* %16
br label %88
88: ; preds = %171, %75
%89 = load i32, i32* %16
%90 = load i32, i32* %20
%91 = icmp slt i32 %89, %90
br i1 %91, label %92, label %174
92: ; preds = %88
%93 = load i32, i32* %16
%94 = sitofp i32 %93 to double
%95 = fadd double %94, 1.000000e+00
%96 = call i64 @pow(double 2.000000e+00, double %95)
%97 = trunc i64 %96 to i32
store i32 %97, i32* %17
store i32 0, i32* %18
store i32 0, i32* %15
br label %98
98: ; preds = %137, %92
%99 = load i32, i32* %15
%100 = load i32, i32* %11
%101 = icmp slt i32 %99, %100
br i1 %101, label %102, label %141
102: ; preds = %98
store i32 0, i32* %14
br label %103
103: ; preds = %132, %102
%104 = load i32, i32* %14
%105 = load i32, i32* %10
%106 = icmp slt i32 %104, %105
br i1 %106, label %107, label %136
107: ; preds = %103
store i32 0, i32* %13
br label %108
108: ; preds = %127, %107
%109 = load i32, i32* %13
%110 = load i32, i32* %9
%111 = icmp slt i32 %109, %110
br i1 %111, label %112, label %131
112: ; preds = %108
%113 = load i8*, i8** %7
%114 = load i32, i32* %9
%115 = load i32, i32* %10
%116 = load i32, i32* %11
%117 = load i32, i32* %13
%118 = load i32, i32* %14
%119 = load i32, i32* %15
%120 = load i32, i32* %17
%121 = call i32 @_p3dCheckForObjectVoxel(i8* %113, i32 %114, i32 %115, i32 %116, i32 %117, i32 %118, i32 %119, i32 %120)
%122 = icmp eq i32 %121, 1
br i1 %122, label %123, label %126
123: ; preds = %112
%124 = load i32, i32* %18
%125 = add nsw i32 %124, 1
store i32 %125, i32* %18
br label %126
126: ; preds = %123, %112
br label %127
127: ; preds = %126
%128 = load i32, i32* %13
%129 = load i32, i32* %17
%130 = add nsw i32 %128, %129
store i32 %130, i32* %13
br label %108
131: ; preds = %108
br label %132
132: ; preds = %131
%133 = load i32, i32* %14
%134 = load i32, i32* %17
%135 = add nsw i32 %133, %134
store i32 %135, i32* %14
br label %103
136: ; preds = %103
br label %137
137: ; preds = %136
%138 = load i32, i32* %15
%139 = load i32, i32* %17
%140 = add nsw i32 %138, %139
store i32 %140, i32* %15
br label %98
141: ; preds = %98
%142 = load i32, i32* %17
%143 = sitofp i32 %142 to double
%144 = call double @log(double %143)
%145 = fneg double %144
%146 = load double*, double** %27
%147 = load i32, i32* %16
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds double, double* %146, i64 %148
store double %145, double* %149
%150 = load i32, i32* %18
%151 = sitofp i32 %150 to double
%152 = call double @log(double %151)
%153 = load double*, double** %28
%154 = load i32, i32* %16
%155 = sext i32 %154 to i64
%156 = getelementptr inbounds double, double* %153, i64 %155
store double %152, double* %156
%157 = load double*, double** %27
%158 = load i32, i32* %16
%159 = sext i32 %158 to i64
%160 = getelementptr inbounds double, double* %157, i64 %159
%161 = load double, double* %160
%162 = load double, double* %21
%163 = fadd double %162, %161
store double %163, double* %21
%164 = load double*, double** %28
%165 = load i32, i32* %16
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds double, double* %164, i64 %166
%168 = load double, double* %167
%169 = load double, double* %22
%170 = fadd double %169, %168
store double %170, double* %22
br label %171
171: ; preds = %141
%172 = load i32, i32* %16
%173 = add nsw i32 %172, 1
store i32 %173, i32* %16
br label %88
174: ; preds = %88
%175 = load i32, i32* %20
%176 = sitofp i32 %175 to double
%177 = load double, double* %21
%178 = fdiv double %177, %176
store double %178, double* %21
%179 = load i32, i32* %20
%180 = sitofp i32 %179 to double
%181 = load double, double* %22
%182 = fdiv double %181, %180
store double %182, double* %22
store double 0.000000e+00, double* %23
store double 0.000000e+00, double* %24
store double 0.000000e+00, double* %25
store i32 0, i32* %16
br label %183
183: ; preds = %236, %174
%184 = load i32, i32* %16
%185 = load i32, i32* %20
%186 = icmp slt i32 %184, %185
br i1 %186, label %187, label %239
187: ; preds = %183
%188 = load double*, double** %28
%189 = load i32, i32* %16
%190 = sext i32 %189 to i64
%191 = getelementptr inbounds double, double* %188, i64 %190
%192 = load double, double* %191
%193 = load double, double* %22
%194 = fsub double %192, %193
%195 = load double*, double** %27
%196 = load i32, i32* %16
%197 = sext i32 %196 to i64
%198 = getelementptr inbounds double, double* %195, i64 %197
%199 = load double, double* %198
%200 = load double, double* %21
%201 = fsub double %199, %200
%202 = load double, double* %25
%203 = call double @llvm.fmuladd.f64(double %194, double %201, double %202)
store double %203, double* %25
%204 = load double*, double** %28
%205 = load i32, i32* %16
%206 = sext i32 %205 to i64
%207 = getelementptr inbounds double, double* %204, i64 %206
%208 = load double, double* %207
%209 = load double, double* %22
%210 = fsub double %208, %209
%211 = load double*, double** %28
%212 = load i32, i32* %16
%213 = sext i32 %212 to i64
%214 = getelementptr inbounds double, double* %211, i64 %213
%215 = load double, double* %214
%216 = load double, double* %22
%217 = fsub double %215, %216
%218 = load double, double* %24
%219 = call double @llvm.fmuladd.f64(double %210, double %217, double %218)
store double %219, double* %24
%220 = load double*, double** %27
%221 = load i32, i32* %16
%222 = sext i32 %221 to i64
%223 = getelementptr inbounds double, double* %220, i64 %222
%224 = load double, double* %223
%225 = load double, double* %21
%226 = fsub double %224, %225
%227 = load double*, double** %27
%228 = load i32, i32* %16
%229 = sext i32 %228 to i64
%230 = getelementptr inbounds double, double* %227, i64 %229
%231 = load double, double* %230
%232 = load double, double* %21
%233 = fsub double %231, %232
%234 = load double, double* %23
%235 = call double @llvm.fmuladd.f64(double %226, double %233, double %234)
store double %235, double* %23
br label %236
236: ; preds = %187
%237 = load i32, i32* %16
%238 = add nsw i32 %237, 1
store i32 %238, i32* %16
br label %183
239: ; preds = %183
%240 = load double, double* %25
%241 = load double, double* %24
%242 = load double, double* %23
%243 = fmul double %241, %242
%244 = call double @sqrt(double %243)
%245 = fdiv double %240, %244
store double %245, double* %26
%246 = load double, double* %26
%247 = load double, double* %24
%248 = call double @sqrt(double %247)
%249 = fmul double %246, %248
%250 = load double, double* %23
%251 = call double @sqrt(double %250)
%252 = fdiv double %249, %251
%253 = load double*, double** %8
store double %252, double* %253
%254 = load double*, double** %27
%255 = icmp ne double* %254, null
br i1 %255, label %256, label %259
256: ; preds = %239
%257 = load double*, double** %27
%258 = call i32 @free(double* %257)
br label %259
259: ; preds = %256, %239
%260 = load double*, double** %28
%261 = icmp ne double* %260, null
br i1 %261, label %262, label %265
262: ; preds = %259
%263 = load double*, double** %28
%264 = call i32 @free(double* %263)
br label %265
265: ; preds = %262, %259
ret i32 2
}

LLVM IR (-O2):
@.str = [6 x i8] c"\09----\00"
@.str.1 = [29 x i8] c"\09Minimum box side adopted: 2\00"
@.str.2 = [32 x i8] c"\09Maximum box side adopted: %d. \00"
define i32 @p3dBoxCountingFractalDimension(i8* %0, double* nocapture writeonly %1, i32 %2, i32 %3, i32 %4, i32 (i8*, ...)* %5) {
%7 = icmp slt i32 %2, %3
%8 = select i1 %7, i32 %2, i32 %3
%9 = icmp slt i32 %8, %4
%10 = select i1 %9, i32 %8, i32 %4
%11 = sitofp i32 %10 to double
%12 = tail call double @log(double %11)
%13 = fdiv double %12, 0x3FE62E42FEFA39EF
%14 = fadd double %13, 5.000000e-01
%15 = fptosi double %14 to i32
%16 = add i32 %15, -1
%17 = icmp eq i32 (i8*, ...)* %5, null
br i1 %17, label %25, label %18
18: ; preds = %6
%19 = tail call i32 (i8*, ...) %5(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%20 = tail call i32 (i8*, ...) %5(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%21 = sitofp i32 %16 to double
%22 = tail call i64 @pow(double 2.000000e+00, double %21)
%23 = trunc i64 %22 to i32
%24 = tail call i32 (i8*, ...) %5(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %18, %6
%26 = shl i32 %16, 3
%27 = tail call i64 @malloc(i32 %26)
%28 = inttoptr i64 %27 to double*
%29 = tail call i64 @malloc(i32 %26)
%30 = inttoptr i64 %29 to double*
%31 = icmp sgt i32 %15, 1
br i1 %31, label %32, label %145
32: ; preds = %25
%33 = icmp sgt i32 %4, 0
%34 = icmp sgt i32 %3, 0
%35 = icmp sgt i32 %2, 0
%36 = zext i32 %16 to i64
br label %37
37: ; preds = %32, %68
%38 = phi i64 [ 0, %32 ], [ %81, %68 ]
%39 = phi <2 x double> [ zeroinitializer, %32 ], [ %80, %68 ]
%40 = trunc i64 %38 to i32
%41 = sitofp i32 %40 to double
%42 = fadd double %41, 1.000000e+00
%43 = tail call i64 @pow(double 2.000000e+00, double %42)
%44 = trunc i64 %43 to i32
br i1 %33, label %45, label %68
45: ; preds = %37, %64
%46 = phi i32 [ %66, %64 ], [ 0, %37 ]
%47 = phi i32 [ %65, %64 ], [ 0, %37 ]
br i1 %34, label %48, label %64
48: ; preds = %45, %60
%49 = phi i32 [ %62, %60 ], [ 0, %45 ]
%50 = phi i32 [ %61, %60 ], [ %47, %45 ]
br i1 %35, label %51, label %60
51: ; preds = %48, %51
%52 = phi i32 [ %58, %51 ], [ 0, %48 ]
%53 = phi i32 [ %57, %51 ], [ %50, %48 ]
%54 = tail call i32 @_p3dCheckForObjectVoxel(i8* %0, i32 %2, i32 %3, i32 %4, i32 %52, i32 %49, i32 %46, i32 %44)
%55 = icmp eq i32 %54, 1
%56 = zext i1 %55 to i32
%57 = add nsw i32 %53, %56
%58 = add nsw i32 %52, %44
%59 = icmp slt i32 %58, %2
br i1 %59, label %51, label %60
60: ; preds = %51, %48
%61 = phi i32 [ %50, %48 ], [ %57, %51 ]
%62 = add nsw i32 %49, %44
%63 = icmp slt i32 %62, %3
br i1 %63, label %48, label %64
64: ; preds = %60, %45
%65 = phi i32 [ %47, %45 ], [ %61, %60 ]
%66 = add nsw i32 %46, %44
%67 = icmp slt i32 %66, %4
br i1 %67, label %45, label %68
68: ; preds = %64, %37
%69 = phi i32 [ 0, %37 ], [ %65, %64 ]
%70 = sitofp i32 %44 to double
%71 = tail call double @log(double %70)
%72 = fneg double %71
%73 = getelementptr inbounds double, double* %28, i64 %38
store double %72, double* %73
%74 = sitofp i32 %69 to double
%75 = tail call double @log(double %74)
%76 = getelementptr inbounds double, double* %30, i64 %38
store double %75, double* %76
%77 = load double, double* %73
%78 = insertelement <2 x double> poison, double %77, i64 0
%79 = insertelement <2 x double> %78, double %75, i64 1
%80 = fadd <2 x double> %39, %79
%81 = add nuw nsw i64 %38, 1
%82 = icmp eq i64 %81, %36
br i1 %82, label %83, label %37
83: ; preds = %68
%84 = sitofp i32 %16 to double
%85 = insertelement <2 x double> poison, double %84, i64 0
%86 = shufflevector <2 x double> %85, <2 x double> poison, <2 x i32> zeroinitializer
%87 = fdiv <2 x double> %80, %86
br i1 %31, label %88, label %145
88: ; preds = %83
%89 = and i64 %36, 1
%90 = icmp eq i32 %16, 1
br i1 %90, label %126, label %91
91: ; preds = %88
%92 = and i64 %36, 4294967294
br label %93
93: ; preds = %93, %91
%94 = phi i64 [ 0, %91 ], [ %121, %93 ]
%95 = phi double [ 0.000000e+00, %91 ], [ %119, %93 ]
%96 = phi <2 x double> [ zeroinitializer, %91 ], [ %120, %93 ]
%97 = phi i64 [ 0, %91 ], [ %122, %93 ]
%98 = getelementptr inbounds double, double* %30, i64 %94
%99 = load double, double* %98
%100 = getelementptr inbounds double, double* %28, i64 %94
%101 = load double, double* %100
%102 = insertelement <2 x double> poison, double %101, i64 0
%103 = insertelement <2 x double> %102, double %99, i64 1
%104 = fsub <2 x double> %103, %87
%105 = extractelement <2 x double> %104, i64 0
%106 = extractelement <2 x double> %104, i64 1
%107 = tail call double @llvm.fmuladd.f64(double %106, double %105, double %95)
%108 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %104, <2 x double> %104, <2 x double> %96)
%109 = or i64 %94, 1
%110 = getelementptr inbounds double, double* %30, i64 %109
%111 = load double, double* %110
%112 = getelementptr inbounds double, double* %28, i64 %109
%113 = load double, double* %112
%114 = insertelement <2 x double> poison, double %113, i64 0
%115 = insertelement <2 x double> %114, double %111, i64 1
%116 = fsub <2 x double> %115, %87
%117 = extractelement <2 x double> %116, i64 0
%118 = extractelement <2 x double> %116, i64 1
%119 = tail call double @llvm.fmuladd.f64(double %118, double %117, double %107)
%120 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %116, <2 x double> %116, <2 x double> %108)
%121 = add nuw nsw i64 %94, 2
%122 = add i64 %97, 2
%123 = icmp eq i64 %122, %92
br i1 %123, label %124, label %93
124: ; preds = %93
%125 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %116, <2 x double> %116, <2 x double> %108)
br label %126
126: ; preds = %124, %88
%127 = phi double [ undef, %88 ], [ %119, %124 ]
%128 = phi <2 x double> [ undef, %88 ], [ %125, %124 ]
%129 = phi i64 [ 0, %88 ], [ %121, %124 ]
%130 = phi double [ 0.000000e+00, %88 ], [ %119, %124 ]
%131 = phi <2 x double> [ zeroinitializer, %88 ], [ %120, %124 ]
%132 = icmp eq i64 %89, 0
br i1 %132, label %145, label %133
133: ; preds = %126
%134 = getelementptr inbounds double, double* %30, i64 %129
%135 = load double, double* %134
%136 = getelementptr inbounds double, double* %28, i64 %129
%137 = load double, double* %136
%138 = insertelement <2 x double> poison, double %137, i64 0
%139 = insertelement <2 x double> %138, double %135, i64 1
%140 = fsub <2 x double> %139, %87
%141 = extractelement <2 x double> %140, i64 0
%142 = extractelement <2 x double> %140, i64 1
%143 = tail call double @llvm.fmuladd.f64(double %142, double %141, double %130)
%144 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %140, <2 x double> %140, <2 x double> %131)
br label %145
145: ; preds = %133, %126, %25, %83
%146 = phi double [ 0.000000e+00, %83 ], [ 0.000000e+00, %25 ], [ %127, %126 ], [ %143, %133 ]
%147 = phi <2 x double> [ zeroinitializer, %83 ], [ zeroinitializer, %25 ], [ %128, %126 ], [ %144, %133 ]
%148 = extractelement <2 x double> %147, i64 0
%149 = extractelement <2 x double> %147, i64 1
%150 = fmul double %148, %149
%151 = tail call double @sqrt(double %150)
%152 = fdiv double %146, %151
%153 = tail call double @sqrt(double %149)
%154 = fmul double %152, %153
%155 = tail call double @sqrt(double %148)
%156 = fdiv double %154, %155
store double %156, double* %1
%157 = icmp eq i64 %27, 0
br i1 %157, label %160, label %158
158: ; preds = %145
%159 = tail call i32 @free(double* %28)
br label %160
160: ; preds = %158, %145
%161 = icmp eq i64 %29, 0
br i1 %161, label %164, label %162
162: ; preds = %160
%163 = tail call i32 @free(double* %30)
br label %164
164: ; preds = %162, %160
ret i32 2
}