#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 UCHAR_MAX;
double _p3dJohannsenThresholding_dlog(double);
double _p3dJohannsenThresholding_entropy(double);
scalar_t__ calloc(int, int);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ p3dGetElapsedTime_min();
int /*<<< orphan*/ p3dGetElapsedTime_sec();
int /*<<< orphan*/ p3dResetStartTime();
int p3dJohannsenThresholding_8(unsigned char *in_im, unsigned char *out_im,
                               const int dimx, const int dimy, const int dimz,
                               unsigned char *thresh,
                               int (*wr_log)(const char *, ...),
                               int (*wr_progress)(const int, ...)) {
  double *prob = NULL;
  double *Pt = NULL;
  double *F = NULL;
  double *Pq = NULL;
  int i, t, start, end;
  double Sb, Sw;
  int ct;
  if (wr_log != NULL) {
    p3dResetStartTime();
    wr_log("Pore3D - Thresholding image according to Johannsen's method...");
  }
  if (((prob = (double *)calloc((UCHAR_MAX + 1), sizeof(double))) == NULL)) {
    goto MEM_ERROR;
  };
  if (((Pt = (double *)malloc(sizeof(double) * (UCHAR_MAX + 1))) == NULL)) {
    goto MEM_ERROR;
  };
  if (((F = (double *)malloc(sizeof(double) * (UCHAR_MAX + 1))) == NULL)) {
    goto MEM_ERROR;
  };
  if (((Pq = (double *)malloc(sizeof(double) * (UCHAR_MAX + 1))) == NULL)) {
    goto MEM_ERROR;
  };
  for (ct = 0; ct < (dimx * dimy * dimz); ct++)
    prob[in_im[ct]] = prob[in_im[ct]] + 1.0;
  for (ct = 0; ct <= UCHAR_MAX; ct++)
    prob[ct] = prob[ct] / (double)(dimx * dimy * dimz);
  Pt[0] = prob[0];
  Pq[0] = 1.0 - Pt[0];
  for (i = 1; i <= UCHAR_MAX; i++) {
    Pt[i] = Pt[i - 1] + prob[i];
    Pq[i] = 1.0 - Pt[i - 1];
  }
  start = 0;
  while (prob[start++] <= 0.0)
    ;
  end = UCHAR_MAX;
  while (prob[end--] <= 0.0)
    ;
  t = -1;
  for (i = start; i <= end; i++) {
    if (prob[i] <= 0.0)
      continue;
    Sb = _p3dJohannsenThresholding_dlog(Pt[i]) +
         (1.0 / Pt[i]) * (_p3dJohannsenThresholding_entropy(prob[i]) +
                          _p3dJohannsenThresholding_entropy(Pt[i - 1]));
    Sw = _p3dJohannsenThresholding_dlog(Pq[i]) +
         (1.0 / Pq[i]) * (_p3dJohannsenThresholding_entropy(prob[i]) +
                          _p3dJohannsenThresholding_entropy(Pq[i + 1]));
    F[i] = Sb + Sw;
    if (t < 0)
      t = i;
    else if (F[i] < F[t])
      t = i;
  }
  *thresh = (unsigned char)t;
#pragma omp parallel for
  for (ct = 0; ct < (dimx * dimy * dimz); ct++)
    out_im[ct] = (in_im[ct] > (*thresh)) ? UCHAR_MAX : 0;
  if (prob != NULL)
    free(prob);
  if (Pt != NULL)
    free(Pt);
  if (F != NULL)
    free(F);
  if (Pq != NULL)
    free(Pq);
  if (wr_log != NULL) {
    wr_log("\tDetermined threshold: %d.", *thresh);
    wr_log("Pore3D - Image thresholded successfully in %dm%0.3fs.",
           p3dGetElapsedTime_min(), p3dGetElapsedTime_sec());
  }
  return 2;
MEM_ERROR:
  if (wr_log != NULL) {
    wr_log("Pore3D - Not enough (contiguous) memory. Program will exit.");
  }
  if (prob != NULL)
    free(prob);
  if (Pt != NULL)
    free(Pt);
  if (F != NULL)
    free(F);
  if (Pq != NULL)
    free(Pq);
  return (int)NULL;
}


x86 assembly (clang, -O0):
<p3dJohannsenThresholding_8>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
cmpq   $0x0,0x10(%rbp)
je     11e7 <p3dJohannsenThresholding_8+0x67>
mov    $0x0,%al
call   1080 <p3dResetStartTime@plt>
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   *0x10(%rbp)
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
add    $0x1,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    1210 <p3dJohannsenThresholding_8+0x90>
jmp    1743 <p3dJohannsenThresholding_8+0x5c3>
mov    0x2dd9(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    123c <p3dJohannsenThresholding_8+0xbc>
jmp    1743 <p3dJohannsenThresholding_8+0x5c3>
mov    0x2dad(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
jne    1268 <p3dJohannsenThresholding_8+0xe8>
jmp    1743 <p3dJohannsenThresholding_8+0x5c3>
mov    0x2d81(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
jne    1294 <p3dJohannsenThresholding_8+0x114>
jmp    1743 <p3dJohannsenThresholding_8+0x5c3>
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    -0x1c(%rbp),%ecx
imul   -0x20(%rbp),%ecx
imul   -0x24(%rbp),%ecx
cmp    %ecx,%eax
jge    12f1 <p3dJohannsenThresholding_8+0x171>
mov    -0x38(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq -0x74(%rbp),%rdx
movzbl (%rcx,%rdx,1),%ecx
movsd  0xd37(%rip),%xmm0
addsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq -0x74(%rbp),%rdx
movzbl (%rcx,%rdx,1),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    129b <p3dJohannsenThresholding_8+0x11b>
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    0x2cee(%rip),%rcx
cmp    (%rcx),%eax
jg     1345 <p3dJohannsenThresholding_8+0x1c5>
mov    -0x38(%rbp),%rax
movslq -0x74(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
imul   -0x24(%rbp),%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movslq -0x74(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    12f8 <p3dJohannsenThresholding_8+0x178>
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x40(%rbp),%rax
movsd  0xc9f(%rip),%xmm0
subsd  (%rax),%xmm0
mov    -0x50(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    0x2c72(%rip),%rcx
cmp    (%rcx),%eax
jg     13e7 <p3dJohannsenThresholding_8+0x267>
mov    -0x40(%rbp),%rax
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x54(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
mov    -0x40(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40(%rbp),%rax
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xc39(%rip),%xmm0
subsd  (%rax,%rcx,8),%xmm0
mov    -0x50(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1374 <p3dJohannsenThresholding_8+0x1f4>
movl   $0x0,-0x5c(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x5c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x5c(%rbp)
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
ucomisd (%rax,%rcx,8),%xmm0
jb     1413 <p3dJohannsenThresholding_8+0x293>
jmp    13ee <p3dJohannsenThresholding_8+0x26e>
mov    0x2bd6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x60(%rbp),%ecx
mov    %ecx,%edx
add    $0xffffffff,%edx
mov    %edx,-0x60(%rbp)
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
ucomisd (%rax,%rcx,8),%xmm0
jb     1444 <p3dJohannsenThresholding_8+0x2c4>
jmp    141f <p3dJohannsenThresholding_8+0x29f>
movl   $0xffffffff,-0x58(%rbp)
mov    -0x5c(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x60(%rbp),%eax
jg     1608 <p3dJohannsenThresholding_8+0x488>
mov    -0x38(%rbp),%rax
movslq -0x54(%rbp),%rcx
xorps  %xmm0,%xmm0
ucomisd (%rax,%rcx,8),%xmm0
jb     1478 <p3dJohannsenThresholding_8+0x2f8>
jmp    15fa <p3dJohannsenThresholding_8+0x47a>
mov    -0x40(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   10a0 <_p3dJohannsenThresholding_dlog@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
mov    -0x40(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  0xb5e(%rip),%xmm0
divsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
mov    -0x38(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <_p3dJohannsenThresholding_entropy@plt>
movsd  %xmm0,-0xa8(%rbp)
ff
mov    -0x40(%rbp),%rax
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <_p3dJohannsenThresholding_entropy@plt>
movsd  -0xa8(%rbp),%xmm2
ff
movsd  -0xa0(%rbp),%xmm1
ff
movaps %xmm0,%xmm3
movsd  -0x98(%rbp),%xmm0
ff
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x50(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   10a0 <_p3dJohannsenThresholding_dlog@plt>
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x50(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  0xaca(%rip),%xmm0
divsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x38(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <_p3dJohannsenThresholding_entropy@plt>
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x50(%rbp),%rax
mov    -0x54(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <_p3dJohannsenThresholding_entropy@plt>
movsd  -0x90(%rbp),%xmm2
ff
movsd  -0x88(%rbp),%xmm1
ff
movaps %xmm0,%xmm3
movsd  -0x80(%rbp),%xmm0
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x68(%rbp),%xmm0
addsd  -0x70(%rbp),%xmm0
mov    -0x48(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
cmpl   $0x0,-0x58(%rbp)
jge    15c6 <p3dJohannsenThresholding_8+0x446>
mov    -0x54(%rbp),%eax
mov    %eax,-0x58(%rbp)
jmp    15f5 <p3dJohannsenThresholding_8+0x475>
mov    -0x48(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x48(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    15f0 <p3dJohannsenThresholding_8+0x470>
mov    -0x54(%rbp),%eax
mov    %eax,-0x58(%rbp)
jmp    15f5 <p3dJohannsenThresholding_8+0x475>
jmp    15fa <p3dJohannsenThresholding_8+0x47a>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1451 <p3dJohannsenThresholding_8+0x2d1>
mov    -0x58(%rbp),%eax
mov    %al,%cl
mov    -0x30(%rbp),%rax
mov    %cl,(%rax)
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    -0x1c(%rbp),%ecx
imul   -0x20(%rbp),%ecx
imul   -0x24(%rbp),%ecx
cmp    %ecx,%eax
jge    168d <p3dJohannsenThresholding_8+0x50d>
mov    -0x10(%rbp),%rax
movslq -0x74(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x30(%rbp),%rcx
movzbl (%rcx),%ecx
cmp    %ecx,%eax
jle    165f <p3dJohannsenThresholding_8+0x4df>
mov    0x299e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xac(%rbp)
jmp    166c <p3dJohannsenThresholding_8+0x4ec>
xor    %eax,%eax
mov    %eax,-0xac(%rbp)
jmp    166c <p3dJohannsenThresholding_8+0x4ec>
mov    -0xac(%rbp),%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x74(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    161a <p3dJohannsenThresholding_8+0x49a>
cmpq   $0x0,-0x38(%rbp)
je     16a1 <p3dJohannsenThresholding_8+0x521>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x40(%rbp)
je     16b5 <p3dJohannsenThresholding_8+0x535>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x48(%rbp)
je     16c9 <p3dJohannsenThresholding_8+0x549>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x50(%rbp)
je     16dd <p3dJohannsenThresholding_8+0x55d>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,0x10(%rbp)
je     1737 <p3dJohannsenThresholding_8+0x5b7>
mov    0x10(%rbp),%rcx
mov    -0x30(%rbp),%rax
movzbl (%rax),%esi
lea    0x94d(%rip),%rdi
mov    $0x0,%al
call   *%rcx
mov    0x10(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    $0x0,%al
call   1070 <p3dGetElapsedTime_min@plt>
mov    %eax,-0xbc(%rbp)
mov    $0x0,%al
call   1050 <p3dGetElapsedTime_sec@plt>
mov    -0xbc(%rbp),%esi
mov    -0xb8(%rbp),%rcx
mov    %eax,%edx
lea    0x92f(%rip),%rdi
mov    $0x0,%al
call   *%rcx
movl   $0x2,-0x4(%rbp)
jmp    17b1 <p3dJohannsenThresholding_8+0x631>
cmpq   $0x0,0x10(%rbp)
je     175a <p3dJohannsenThresholding_8+0x5da>
lea    0x943(%rip),%rdi
mov    $0x0,%al
call   *0x10(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     176e <p3dJohannsenThresholding_8+0x5ee>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x40(%rbp)
je     1782 <p3dJohannsenThresholding_8+0x602>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x48(%rbp)
je     1796 <p3dJohannsenThresholding_8+0x616>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x50(%rbp)
je     17aa <p3dJohannsenThresholding_8+0x62a>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<p3dJohannsenThresholding_8>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r9,0x8(%rsp)
mov    %r8d,%ebx
mov    %ecx,%ebp
mov    %edx,%r14d
mov    %rsi,0x20(%rsp)
mov    %rdi,0x28(%rsp)
mov    0xa0(%rsp),%r15
test   %r15,%r15
je     11c5 <p3dJohannsenThresholding_8+0x45>
xor    %eax,%eax
call   1080 <p3dResetStartTime@plt>
lea    0xe48(%rip),%rdi
xor    %eax,%eax
call   *%r15
mov    0x2e24(%rip),%r12
mov    (%r12),%edi
add    $0x1,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,%r13
test   %rax,%rax
je     1275 <p3dJohannsenThresholding_8+0xf5>
mov    (%r12),%eax
lea    0x8(,%rax,8),%edi
call   1090 <malloc@plt>
mov    %rax,0x18(%rsp)
test   %rax,%rax
je     1275 <p3dJohannsenThresholding_8+0xf5>
mov    (%r12),%eax
lea    0x8(,%rax,8),%edi
call   1090 <malloc@plt>
mov    %rax,0x38(%rsp)
test   %rax,%rax
je     12c4 <p3dJohannsenThresholding_8+0x144>
mov    (%r12),%eax
lea    0x8(,%rax,8),%edi
call   1090 <malloc@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     12cd <p3dJohannsenThresholding_8+0x14d>
imul   %r14d,%ebp
imul   %ebx,%ebp
mov    %ebp,%r9d
mov    %ebp,0x14(%rsp)
test   %ebp,%ebp
mov    0x18(%rsp),%r8
mov    0x28(%rsp),%r10
jle    138f <p3dJohannsenThresholding_8+0x20f>
lea    -0x1(%r9),%rcx
mov    %r9d,%eax
and    $0x3,%eax
cmp    $0x3,%rcx
jae    12d9 <p3dJohannsenThresholding_8+0x159>
xor    %ecx,%ecx
jmp    1358 <p3dJohannsenThresholding_8+0x1d8>
xor    %ebx,%ebx
xor    %ebp,%ebp
test   %r15,%r15
je     128a <p3dJohannsenThresholding_8+0x10a>
lea    0xe13(%rip),%rdi
xor    %eax,%eax
call   *%r15
test   %r13,%r13
je     1297 <p3dJohannsenThresholding_8+0x117>
mov    %r13,%rdi
call   1030 <free@plt>
test   %rbx,%rbx
je     12a4 <p3dJohannsenThresholding_8+0x124>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
test   %rbp,%rbp
je     12b3 <p3dJohannsenThresholding_8+0x133>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebp,%ebp
mov    0x18(%rsp),%rbx
jmp    1279 <p3dJohannsenThresholding_8+0xf9>
mov    0x18(%rsp),%rbx
mov    0x38(%rsp),%rbp
jmp    1279 <p3dJohannsenThresholding_8+0xf9>
mov    %r9d,%edx
and    $0xfffffffc,%edx
xor    %ecx,%ecx
movsd  0xd17(%rip),%xmm0
nopl   0x0(%rax)
movzbl (%r10,%rcx,1),%esi
movsd  0x0(%r13,%rsi,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x0(%r13,%rsi,8)
movzbl 0x1(%r10,%rcx,1),%esi
movsd  0x0(%r13,%rsi,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x0(%r13,%rsi,8)
movzbl 0x2(%r10,%rcx,1),%esi
movsd  0x0(%r13,%rsi,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x0(%r13,%rsi,8)
movzbl 0x3(%r10,%rcx,1),%esi
movsd  0x0(%r13,%rsi,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x0(%r13,%rsi,8)
add    $0x4,%rcx
cmp    %rcx,%rdx
jne    12f0 <p3dJohannsenThresholding_8+0x170>
test   %rax,%rax
je     138f <p3dJohannsenThresholding_8+0x20f>
add    %r10,%rcx
xor    %edx,%edx
movsd  0xc96(%rip),%xmm0
nopw   0x0(%rax,%rax,1)
movzbl (%rcx,%rdx,1),%esi
movsd  0x0(%r13,%rsi,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x0(%r13,%rsi,8)
add    $0x1,%rdx
cmp    %rdx,%rax
jne    1370 <p3dJohannsenThresholding_8+0x1f0>
movslq (%r12),%rax
mov    %eax,%r14d
test   %rax,%rax
js     143c <p3dJohannsenThresholding_8+0x2bc>
xorps  %xmm0,%xmm0
cvtsi2sdl 0x14(%rsp),%xmm0
lea    0x1(%r14),%rcx
test   %r14,%r14
je     1460 <p3dJohannsenThresholding_8+0x2e0>
mov    %ecx,%edx
and    $0xfffffffe,%edx
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x2(%rdx),%rsi
mov    %rsi,%rbx
shr    %rbx
add    $0x1,%rbx
test   %rsi,%rsi
je     18fa <p3dJohannsenThresholding_8+0x77a>
mov    %rbx,%rsi
and    $0xfffffffffffffffe,%rsi
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movupd 0x0(%r13,%rdi,8),%xmm2
movupd 0x10(%r13,%rdi,8),%xmm3
divpd  %xmm1,%xmm2
movupd %xmm2,0x0(%r13,%rdi,8)
divpd  %xmm1,%xmm3
movupd %xmm3,0x10(%r13,%rdi,8)
add    $0x4,%rdi
add    $0xfffffffffffffffe,%rsi
jne    13f0 <p3dJohannsenThresholding_8+0x270>
test   $0x1,%bl
je     1435 <p3dJohannsenThresholding_8+0x2b5>
movupd 0x0(%r13,%rdi,8),%xmm2
divpd  %xmm1,%xmm2
movupd %xmm2,0x0(%r13,%rdi,8)
cmp    %rcx,%rdx
jne    1470 <p3dJohannsenThresholding_8+0x2f0>
jmp    148b <p3dJohannsenThresholding_8+0x30b>
movsd  0x0(%r13),%xmm0
movsd  %xmm0,(%r8)
movsd  0xbb1(%rip),%xmm1
subsd  %xmm0,%xmm1
mov    (%rsp),%rcx
movsd  %xmm1,(%rcx)
jmp    1617 <p3dJohannsenThresholding_8+0x497>
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  0x0(%r13,%rdx,8),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x0(%r13,%rdx,8)
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    1470 <p3dJohannsenThresholding_8+0x2f0>
movsd  0x0(%r13),%xmm1
movsd  %xmm1,(%r8)
movsd  0xb62(%rip),%xmm0
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
mov    (%rsp),%rdx
movsd  %xmm2,(%rdx)
test   %eax,%eax
jle    1617 <p3dJohannsenThresholding_8+0x497>
mov    %ecx,%edi
mov    (%rsp),%rdx
lea    (%rdx,%r14,8),%rsi
add    $0x8,%rsi
add    $0x8,%rdx
cmp    %rsi,%r8
jae    1587 <p3dJohannsenThresholding_8+0x407>
lea    (%r8,%r14,8),%rsi
add    $0x8,%rsi
cmp    %rsi,%rdx
jae    1587 <p3dJohannsenThresholding_8+0x407>
add    $0xffffffffffffffff,%rcx
mov    $0x1,%esi
cmp    $0x2,%edi
je     155d <p3dJohannsenThresholding_8+0x3dd>
mov    %rcx,%rdi
and    $0xfffffffffffffffe,%rdi
neg    %rdi
mov    $0x1,%esi
nop
movsd  -0x8(%r8,%rsi,8),%xmm1
movsd  0x0(%r13,%rsi,8),%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,(%r8,%rsi,8)
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
movsd  %xmm2,-0x8(%rdx,%rsi,8)
movsd  (%r8,%rsi,8),%xmm1
movsd  0x8(%r13,%rsi,8),%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%r8,%rsi,8)
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
movsd  %xmm2,(%rdx,%rsi,8)
lea    (%rdi,%rsi,1),%rbx
add    $0x2,%rbx
add    $0x2,%rsi
cmp    $0x1,%rbx
jne    1500 <p3dJohannsenThresholding_8+0x380>
test   $0x1,%cl
je     1617 <p3dJohannsenThresholding_8+0x497>
movsd  -0x8(%r8,%rsi,8),%xmm1
movsd  0x0(%r13,%rsi,8),%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,(%r8,%rsi,8)
subsd  %xmm1,%xmm0
jmp    160e <p3dJohannsenThresholding_8+0x48e>
movsd  (%r8),%xmm1
add    $0xffffffffffffffff,%rcx
mov    $0x1,%esi
cmp    $0x2,%edi
je     15f8 <p3dJohannsenThresholding_8+0x478>
mov    %rcx,%rdi
and    $0xfffffffffffffffe,%rdi
neg    %rdi
mov    $0x1,%esi
nopl   0x0(%rax)
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
addsd  0x0(%r13,%rsi,8),%xmm1
movsd  %xmm1,(%r8,%rsi,8)
movsd  %xmm2,-0x8(%rdx,%rsi,8)
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
addsd  0x8(%r13,%rsi,8),%xmm1
movsd  %xmm1,0x8(%r8,%rsi,8)
movsd  %xmm2,(%rdx,%rsi,8)
lea    (%rdi,%rsi,1),%rbx
add    $0x2,%rbx
add    $0x2,%rsi
cmp    $0x1,%rbx
jne    15b0 <p3dJohannsenThresholding_8+0x430>
test   $0x1,%cl
je     1617 <p3dJohannsenThresholding_8+0x497>
subsd  %xmm1,%xmm0
addsd  0x0(%r13,%rsi,8),%xmm1
movsd  %xmm1,(%r8,%rsi,8)
mov    (%rsp),%rcx
movsd  %xmm0,(%rcx,%rsi,8)
xor    %ebx,%ebx
movabs $0x100000000,%rdx
xorpd  %xmm0,%xmm0
xor    %ecx,%ecx
nopl   0x0(%rax)
add    %rdx,%rbx
ucomisd 0x0(%r13,%rcx,8),%xmm0
lea    0x1(%rcx),%rcx
jae    1630 <p3dJohannsenThresholding_8+0x4b0>
mov    %r9,0x30(%rsp)
add    $0x1,%r14d
lea    0x0(,%rax,8),%rax
add    %r13,%rax
xorpd  %xmm0,%xmm0
nopl   0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%r14
ucomisd (%rax),%xmm0
lea    -0x8(%rax),%rax
jae    1660 <p3dJohannsenThresholding_8+0x4e0>
mov    $0xffffffff,%edx
cmp    %r14d,%ecx
jge    17ae <p3dJohannsenThresholding_8+0x62e>
sar    $0x20,%rbx
mov    $0xffffffff,%edx
xorpd  %xmm0,%xmm0
jmp    16a3 <p3dJohannsenThresholding_8+0x523>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %rbx,%r15
mov    %r15,%rbx
cmp    %r14d,%r15d
je     17ae <p3dJohannsenThresholding_8+0x62e>
mov    %ebx,%r12d
ucomisd 0x0(%r13,%r12,8),%xmm0
jae    1690 <p3dJohannsenThresholding_8+0x510>
mov    0x18(%rsp),%rbp
movsd  0x0(%rbp,%r12,8),%xmm0
mov    %edx,0x5c(%rsp)
call   10a0 <_p3dJohannsenThresholding_dlog@plt>
movsd  %xmm0,0x50(%rsp)
movsd  0x92e(%rip),%xmm0
divsd  0x0(%rbp,%r12,8),%xmm0
movsd  %xmm0,0x48(%rsp)
movsd  0x0(%r13,%r12,8),%xmm0
call   1040 <_p3dJohannsenThresholding_entropy@plt>
movsd  %xmm0,0x40(%rsp)
movsd  -0x8(%rbp,%rbx,8),%xmm0
call   1040 <_p3dJohannsenThresholding_entropy@plt>
addsd  0x40(%rsp),%xmm0
mulsd  0x48(%rsp),%xmm0
addsd  0x50(%rsp),%xmm0
movsd  %xmm0,0x50(%rsp)
mov    (%rsp),%rbp
movsd  0x0(%rbp,%r12,8),%xmm0
call   10a0 <_p3dJohannsenThresholding_dlog@plt>
movsd  %xmm0,0x48(%rsp)
movsd  0x8ce(%rip),%xmm0
divsd  0x0(%rbp,%r12,8),%xmm0
movsd  %xmm0,0x40(%rsp)
movsd  0x0(%r13,%r12,8),%xmm0
call   1040 <_p3dJohannsenThresholding_entropy@plt>
movsd  %xmm0,0x60(%rsp)
mov    %rbx,%r15
add    $0x1,%r15
mov    %r15d,%eax
movsd  0x0(%rbp,%rax,8),%xmm0
call   1040 <_p3dJohannsenThresholding_entropy@plt>
mov    0x5c(%rsp),%edx
addsd  0x60(%rsp),%xmm0
mulsd  0x40(%rsp),%xmm0
addsd  0x48(%rsp),%xmm0
addsd  0x50(%rsp),%xmm0
mov    0x38(%rsp),%rcx
movsd  %xmm0,(%rcx,%r12,8)
test   %edx,%edx
js     179e <p3dJohannsenThresholding_8+0x61e>
mov    %edx,%eax
movsd  (%rcx,%rax,8),%xmm1
ucomisd %xmm0,%xmm1
jbe    17a0 <p3dJohannsenThresholding_8+0x620>
mov    %ebx,%edx
mov    0x28(%rsp),%r10
xorpd  %xmm0,%xmm0
jmp    1697 <p3dJohannsenThresholding_8+0x517>
mov    0x8(%rsp),%rax
mov    %dl,(%rax)
cmpl   $0x0,0x14(%rsp)
mov    0xa0(%rsp),%rbp
mov    0x38(%rsp),%r14
mov    0x20(%rsp),%rbx
jle    194c <p3dJohannsenThresholding_8+0x7cc>
xor    %eax,%eax
cmp    %dl,(%r10)
jbe    17e2 <p3dJohannsenThresholding_8+0x662>
mov    0x2810(%rip),%rax
mov    (%rax),%eax
mov    %al,(%rbx)
cmpl   $0x1,0x14(%rsp)
je     194c <p3dJohannsenThresholding_8+0x7cc>
mov    0x30(%rsp),%rdi
lea    -0x1(%rdi),%r11
mov    $0x1,%eax
cmp    $0x8,%r11
jb     1912 <p3dJohannsenThresholding_8+0x792>
lea    0x1(%rbx),%rsi
lea    (%rbx,%rdi,1),%rbp
lea    0x1(%r10),%rcx
mov    0x8(%rsp),%rdx
cmp    %rdx,%rbx
setb   %r8b
cmp    %rdx,%rbp
seta   %r9b
lea    (%r10,%rdi,1),%rdx
cmp    %rdx,%rsi
setb   %dl
cmp    %rbp,%rcx
setb   %cl
mov    0x27b3(%rip),%rdi
lea    0x4(%rdi),%rbx
cmp    %rbx,%rsi
setb   %bl
cmp    %rdi,%rbp
seta   %sil
test   %r9b,%r8b
jne    190a <p3dJohannsenThresholding_8+0x78a>
and    %cl,%dl
mov    0xa0(%rsp),%rbp
jne    1912 <p3dJohannsenThresholding_8+0x792>
and    %sil,%bl
mov    0x20(%rsp),%rbx
jne    1912 <p3dJohannsenThresholding_8+0x792>
mov    %r11,%rdx
and    $0xfffffffffffffff8,%rdx
lea    0x1(%rdx),%rax
mov    0x8(%rsp),%rcx
movzbl (%rcx),%ecx
movd   %ecx,%xmm0
punpcklbw %xmm0,%xmm0
pshuflw $0x0,%xmm0,%xmm0
mov    0x2754(%rip),%rcx
movd   (%rcx),%xmm1
punpcklbw %xmm1,%xmm1
pshuflw $0x0,%xmm1,%xmm1
xor    %esi,%esi
nopl   0x0(%rax,%rax,1)
movd   0x1(%r10,%rsi,1),%xmm2
movd   0x5(%r10,%rsi,1),%xmm3
movdqa %xmm2,%xmm4
pminub %xmm0,%xmm4
pcmpeqb %xmm2,%xmm4
movdqa %xmm3,%xmm2
pminub %xmm0,%xmm2
pcmpeqb %xmm3,%xmm2
pandn  %xmm1,%xmm4
pandn  %xmm1,%xmm2
movd   %xmm4,0x1(%rbx,%rsi,1)
movd   %xmm2,0x5(%rbx,%rsi,1)
add    $0x8,%rsi
cmp    %rsi,%rdx
jne    18b0 <p3dJohannsenThresholding_8+0x730>
cmp    %rdx,%r11
jne    1912 <p3dJohannsenThresholding_8+0x792>
jmp    194c <p3dJohannsenThresholding_8+0x7cc>
xor    %edi,%edi
test   $0x1,%bl
jne    1423 <p3dJohannsenThresholding_8+0x2a3>
jmp    1435 <p3dJohannsenThresholding_8+0x2b5>
mov    0xa0(%rsp),%rbp
mov    %rax,%rcx
not    %rcx
mov    0x30(%rsp),%rdi
test   $0x1,%dil
jne    1947 <p3dJohannsenThresholding_8+0x7c7>
mov    (%r10,%rax,1),%bl
xor    %edx,%edx
mov    0x8(%rsp),%rsi
cmp    (%rsi),%bl
jbe    193b <p3dJohannsenThresholding_8+0x7bb>
mov    0x26b7(%rip),%rdx
mov    (%rdx),%edx
mov    0x20(%rsp),%rsi
mov    %dl,(%rsi,%rax,1)
add    $0x1,%rax
add    %rdi,%rcx
jne    19b8 <p3dJohannsenThresholding_8+0x838>
mov    %r13,%rdi
call   1030 <free@plt>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    $0x2,%ebx
test   %rbp,%rbp
je     12b3 <p3dJohannsenThresholding_8+0x133>
mov    0x8(%rsp),%rax
movzbl (%rax),%esi
lea    0x6bb(%rip),%rdi
xor    %eax,%eax
call   *%rbp
xor    %eax,%eax
call   1070 <p3dGetElapsedTime_min@plt>
mov    %rbp,%r14
mov    %eax,%ebp
xor    %eax,%eax
call   1050 <p3dGetElapsedTime_sec@plt>
lea    0x6b8(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   *%r14
jmp    12b3 <p3dJohannsenThresholding_8+0x133>
mov    0x20(%rsp),%rdi
jmp    19d1 <p3dJohannsenThresholding_8+0x851>
nop
mov    %cl,0x1(%rdi,%rax,1)
add    $0x2,%rax
cmp    %rax,%rdx
je     194c <p3dJohannsenThresholding_8+0x7cc>
movzbl (%r10,%rax,1),%ebx
xor    %ecx,%ecx
mov    $0x0,%edx
mov    0x8(%rsp),%rsi
cmp    (%rsi),%bl
jbe    19ef <p3dJohannsenThresholding_8+0x86f>
mov    0x2603(%rip),%rdx
mov    (%rdx),%edx
mov    %dl,(%rdi,%rax,1)
movzbl 0x1(%r10,%rax,1),%edx
mov    0x8(%rsp),%rsi
cmp    (%rsi),%dl
mov    0x30(%rsp),%rdx
jbe    19c0 <p3dJohannsenThresholding_8+0x840>
mov    0x25e3(%rip),%rcx
mov    (%rcx),%ecx
jmp    19c0 <p3dJohannsenThresholding_8+0x840>

LLVM IR (-O0):
@.str = [63 x i8] c"Pore3D - Thresholding image according to Johannsen's method...\00"
@UCHAR_MAX = global i32 0
@.str.1 = [27 x i8] c"\09Determined threshold: %d.\00"
@.str.2 = [54 x i8] c"Pore3D - Image thresholded successfully in %dm%0.3fs.\00"
@.str.3 = [60 x i8] c"Pore3D - Not enough (contiguous) memory. Program will exit.\00"
define i32 @p3dJohannsenThresholding_8(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, i8* %5, i32 (i8*, ...)* %6, i32 (i32, ...)* %7) {
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i32 (i8*, ...)*
%17 = alloca i32 (i32, ...)*
%18 = alloca double*
%19 = alloca double*
%20 = alloca double*
%21 = alloca double*
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca double
%27 = alloca double
%28 = alloca i32
store i8* %0, i8** %10
store i8* %1, i8** %11
store i32 %2, i32* %12
store i32 %3, i32* %13
store i32 %4, i32* %14
store i8* %5, i8** %15
store i32 (i8*, ...)* %6, i32 (i8*, ...)** %16
store i32 (i32, ...)* %7, i32 (i32, ...)** %17
store double* null, double** %18
store double* null, double** %19
store double* null, double** %20
store double* null, double** %21
%29 = load i32 (i8*, ...)*, i32 (i8*, ...)** %16
%30 = icmp ne i32 (i8*, ...)* %29, null
br i1 %30, label %31, label %35
31: ; preds = %8
%32 = call i32 (...) @p3dResetStartTime()
%33 = load i32 (i8*, ...)*, i32 (i8*, ...)** %16
%34 = call i32 (i8*, ...) %33(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0))
br label %35
35: ; preds = %31, %8
%36 = load i32, i32* @UCHAR_MAX
%37 = add nsw i32 %36, 1
%38 = call i64 @calloc(i32 %37, i32 8)
%39 = inttoptr i64 %38 to double*
store double* %39, double** %18
%40 = icmp eq double* %39, null
br i1 %40, label %41, label %42
41: ; preds = %35
br label %369
42: ; preds = %35
%43 = load i32, i32* @UCHAR_MAX
%44 = add nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = mul i64 8, %45
%47 = trunc i64 %46 to i32
%48 = call i64 @malloc(i32 %47)
%49 = inttoptr i64 %48 to double*
store double* %49, double** %19
%50 = icmp eq double* %49, null
br i1 %50, label %51, label %52
51: ; preds = %42
br label %369
52: ; preds = %42
%53 = load i32, i32* @UCHAR_MAX
%54 = add nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = mul i64 8, %55
%57 = trunc i64 %56 to i32
%58 = call i64 @malloc(i32 %57)
%59 = inttoptr i64 %58 to double*
store double* %59, double** %20
%60 = icmp eq double* %59, null
br i1 %60, label %61, label %62
61: ; preds = %52
br label %369
62: ; preds = %52
%63 = load i32, i32* @UCHAR_MAX
%64 = add nsw i32 %63, 1
%65 = sext i32 %64 to i64
%66 = mul i64 8, %65
%67 = trunc i64 %66 to i32
%68 = call i64 @malloc(i32 %67)
%69 = inttoptr i64 %68 to double*
store double* %69, double** %21
%70 = icmp eq double* %69, null
br i1 %70, label %71, label %72
71: ; preds = %62
br label %369
72: ; preds = %62
store i32 0, i32* %28
br label %73
73: ; preds = %100, %72
%74 = load i32, i32* %28
%75 = load i32, i32* %12
%76 = load i32, i32* %13
%77 = mul nsw i32 %75, %76
%78 = load i32, i32* %14
%79 = mul nsw i32 %77, %78
%80 = icmp slt i32 %74, %79
br i1 %80, label %81, label %103
81: ; preds = %73
%82 = load double*, double** %18
%83 = load i8*, i8** %10
%84 = load i32, i32* %28
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %83, i64 %85
%87 = load i8, i8* %86
%88 = zext i8 %87 to i64
%89 = getelementptr inbounds double, double* %82, i64 %88
%90 = load double, double* %89
%91 = fadd double %90, 1.000000e+00
%92 = load double*, double** %18
%93 = load i8*, i8** %10
%94 = load i32, i32* %28
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i8, i8* %93, i64 %95
%97 = load i8, i8* %96
%98 = zext i8 %97 to i64
%99 = getelementptr inbounds double, double* %92, i64 %98
store double %91, double* %99
br label %100
100: ; preds = %81
%101 = load i32, i32* %28
%102 = add nsw i32 %101, 1
store i32 %102, i32* %28
br label %73
103: ; preds = %73
store i32 0, i32* %28
br label %104
104: ; preds = %125, %103
%105 = load i32, i32* %28
%106 = load i32, i32* @UCHAR_MAX
%107 = icmp sle i32 %105, %106
br i1 %107, label %108, label %128
108: ; preds = %104
%109 = load double*, double** %18
%110 = load i32, i32* %28
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds double, double* %109, i64 %111
%113 = load double, double* %112
%114 = load i32, i32* %12
%115 = load i32, i32* %13
%116 = mul nsw i32 %114, %115
%117 = load i32, i32* %14
%118 = mul nsw i32 %116, %117
%119 = sitofp i32 %118 to double
%120 = fdiv double %113, %119
%121 = load double*, double** %18
%122 = load i32, i32* %28
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds double, double* %121, i64 %123
store double %120, double* %124
br label %125
125: ; preds = %108
%126 = load i32, i32* %28
%127 = add nsw i32 %126, 1
store i32 %127, i32* %28
br label %104
128: ; preds = %104
%129 = load double*, double** %18
%130 = getelementptr inbounds double, double* %129, i64 0
%131 = load double, double* %130
%132 = load double*, double** %19
%133 = getelementptr inbounds double, double* %132, i64 0
store double %131, double* %133
%134 = load double*, double** %19
%135 = getelementptr inbounds double, double* %134, i64 0
%136 = load double, double* %135
%137 = fsub double 1.000000e+00, %136
%138 = load double*, double** %21
%139 = getelementptr inbounds double, double* %138, i64 0
store double %137, double* %139
store i32 1, i32* %22
br label %140
140: ; preds = %172, %128
%141 = load i32, i32* %22
%142 = load i32, i32* @UCHAR_MAX
%143 = icmp sle i32 %141, %142
br i1 %143, label %144, label %175
144: ; preds = %140
%145 = load double*, double** %19
%146 = load i32, i32* %22
%147 = sub nsw i32 %146, 1
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds double, double* %145, i64 %148
%150 = load double, double* %149
%151 = load double*, double** %18
%152 = load i32, i32* %22
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds double, double* %151, i64 %153
%155 = load double, double* %154
%156 = fadd double %150, %155
%157 = load double*, double** %19
%158 = load i32, i32* %22
%159 = sext i32 %158 to i64
%160 = getelementptr inbounds double, double* %157, i64 %159
store double %156, double* %160
%161 = load double*, double** %19
%162 = load i32, i32* %22
%163 = sub nsw i32 %162, 1
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds double, double* %161, i64 %164
%166 = load double, double* %165
%167 = fsub double 1.000000e+00, %166
%168 = load double*, double** %21
%169 = load i32, i32* %22
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds double, double* %168, i64 %170
store double %167, double* %171
br label %172
172: ; preds = %144
%173 = load i32, i32* %22
%174 = add nsw i32 %173, 1
store i32 %174, i32* %22
br label %140
175: ; preds = %140
store i32 0, i32* %24
br label %176
176: ; preds = %184, %175
%177 = load double*, double** %18
%178 = load i32, i32* %24
%179 = add nsw i32 %178, 1
store i32 %179, i32* %24
%180 = sext i32 %178 to i64
%181 = getelementptr inbounds double, double* %177, i64 %180
%182 = load double, double* %181
%183 = fcmp ole double %182, 0.000000e+00
br i1 %183, label %184, label %185
184: ; preds = %176
br label %176
185: ; preds = %176
%186 = load i32, i32* @UCHAR_MAX
store i32 %186, i32* %25
br label %187
187: ; preds = %195, %185
%188 = load double*, double** %18
%189 = load i32, i32* %25
%190 = add nsw i32 %189, -1
store i32 %190, i32* %25
%191 = sext i32 %189 to i64
%192 = getelementptr inbounds double, double* %188, i64 %191
%193 = load double, double* %192
%194 = fcmp ole double %193, 0.000000e+00
br i1 %194, label %195, label %196
195: ; preds = %187
br label %187
196: ; preds = %187
store i32 -1, i32* %23
%197 = load i32, i32* %24
store i32 %197, i32* %22
br label %198
198: ; preds = %292, %196
%199 = load i32, i32* %22
%200 = load i32, i32* %25
%201 = icmp sle i32 %199, %200
br i1 %201, label %202, label %295
202: ; preds = %198
%203 = load double*, double** %18
%204 = load i32, i32* %22
%205 = sext i32 %204 to i64
%206 = getelementptr inbounds double, double* %203, i64 %205
%207 = load double, double* %206
%208 = fcmp ole double %207, 0.000000e+00
br i1 %208, label %209, label %210
209: ; preds = %202
br label %292
210: ; preds = %202
%211 = load double*, double** %19
%212 = load i32, i32* %22
%213 = sext i32 %212 to i64
%214 = getelementptr inbounds double, double* %211, i64 %213
%215 = load double, double* %214
%216 = call double @_p3dJohannsenThresholding_dlog(double %215)
%217 = load double*, double** %19
%218 = load i32, i32* %22
%219 = sext i32 %218 to i64
%220 = getelementptr inbounds double, double* %217, i64 %219
%221 = load double, double* %220
%222 = fdiv double 1.000000e+00, %221
%223 = load double*, double** %18
%224 = load i32, i32* %22
%225 = sext i32 %224 to i64
%226 = getelementptr inbounds double, double* %223, i64 %225
%227 = load double, double* %226
%228 = call double @_p3dJohannsenThresholding_entropy(double %227)
%229 = load double*, double** %19
%230 = load i32, i32* %22
%231 = sub nsw i32 %230, 1
%232 = sext i32 %231 to i64
%233 = getelementptr inbounds double, double* %229, i64 %232
%234 = load double, double* %233
%235 = call double @_p3dJohannsenThresholding_entropy(double %234)
%236 = fadd double %228, %235
%237 = call double @llvm.fmuladd.f64(double %222, double %236, double %216)
store double %237, double* %26
%238 = load double*, double** %21
%239 = load i32, i32* %22
%240 = sext i32 %239 to i64
%241 = getelementptr inbounds double, double* %238, i64 %240
%242 = load double, double* %241
%243 = call double @_p3dJohannsenThresholding_dlog(double %242)
%244 = load double*, double** %21
%245 = load i32, i32* %22
%246 = sext i32 %245 to i64
%247 = getelementptr inbounds double, double* %244, i64 %246
%248 = load double, double* %247
%249 = fdiv double 1.000000e+00, %248
%250 = load double*, double** %18
%251 = load i32, i32* %22
%252 = sext i32 %251 to i64
%253 = getelementptr inbounds double, double* %250, i64 %252
%254 = load double, double* %253
%255 = call double @_p3dJohannsenThresholding_entropy(double %254)
%256 = load double*, double** %21
%257 = load i32, i32* %22
%258 = add nsw i32 %257, 1
%259 = sext i32 %258 to i64
%260 = getelementptr inbounds double, double* %256, i64 %259
%261 = load double, double* %260
%262 = call double @_p3dJohannsenThresholding_entropy(double %261)
%263 = fadd double %255, %262
%264 = call double @llvm.fmuladd.f64(double %249, double %263, double %243)
store double %264, double* %27
%265 = load double, double* %26
%266 = load double, double* %27
%267 = fadd double %265, %266
%268 = load double*, double** %20
%269 = load i32, i32* %22
%270 = sext i32 %269 to i64
%271 = getelementptr inbounds double, double* %268, i64 %270
store double %267, double* %271
%272 = load i32, i32* %23
%273 = icmp slt i32 %272, 0
br i1 %273, label %274, label %276
274: ; preds = %210
%275 = load i32, i32* %22
store i32 %275, i32* %23
br label %291
276: ; preds = %210
%277 = load double*, double** %20
%278 = load i32, i32* %22
%279 = sext i32 %278 to i64
%280 = getelementptr inbounds double, double* %277, i64 %279
%281 = load double, double* %280
%282 = load double*, double** %20
%283 = load i32, i32* %23
%284 = sext i32 %283 to i64
%285 = getelementptr inbounds double, double* %282, i64 %284
%286 = load double, double* %285
%287 = fcmp olt double %281, %286
br i1 %287, label %288, label %290
288: ; preds = %276
%289 = load i32, i32* %22
store i32 %289, i32* %23
br label %290
290: ; preds = %288, %276
br label %291
291: ; preds = %290, %274
br label %292
292: ; preds = %291, %209
%293 = load i32, i32* %22
%294 = add nsw i32 %293, 1
store i32 %294, i32* %22
br label %198
295: ; preds = %198
%296 = load i32, i32* %23
%297 = trunc i32 %296 to i8
%298 = load i8*, i8** %15
store i8 %297, i8* %298
store i32 0, i32* %28
br label %299
299: ; preds = %328, %295
%300 = load i32, i32* %28
%301 = load i32, i32* %12
%302 = load i32, i32* %13
%303 = mul nsw i32 %301, %302
%304 = load i32, i32* %14
%305 = mul nsw i32 %303, %304
%306 = icmp slt i32 %300, %305
br i1 %306, label %307, label %331
307: ; preds = %299
%308 = load i8*, i8** %10
%309 = load i32, i32* %28
%310 = sext i32 %309 to i64
%311 = getelementptr inbounds i8, i8* %308, i64 %310
%312 = load i8, i8* %311
%313 = zext i8 %312 to i32
%314 = load i8*, i8** %15
%315 = load i8, i8* %314
%316 = zext i8 %315 to i32
%317 = icmp sgt i32 %313, %316
br i1 %317, label %318, label %320
318: ; preds = %307
%319 = load i32, i32* @UCHAR_MAX
br label %321
320: ; preds = %307
br label %321
321: ; preds = %320, %318
%322 = phi i32 [ %319, %318 ], [ 0, %320 ]
%323 = trunc i32 %322 to i8
%324 = load i8*, i8** %11
%325 = load i32, i32* %28
%326 = sext i32 %325 to i64
%327 = getelementptr inbounds i8, i8* %324, i64 %326
store i8 %323, i8* %327
br label %328
328: ; preds = %321
%329 = load i32, i32* %28
%330 = add nsw i32 %329, 1
store i32 %330, i32* %28
br label %299
331: ; preds = %299
%332 = load double*, double** %18
%333 = icmp ne double* %332, null
br i1 %333, label %334, label %337
334: ; preds = %331
%335 = load double*, double** %18
%336 = call i32 @free(double* %335)
br label %337
337: ; preds = %334, %331
%338 = load double*, double** %19
%339 = icmp ne double* %338, null
br i1 %339, label %340, label %343
340: ; preds = %337
%341 = load double*, double** %19
%342 = call i32 @free(double* %341)
br label %343
343: ; preds = %340, %337
%344 = load double*, double** %20
%345 = icmp ne double* %344, null
br i1 %345, label %346, label %349
346: ; preds = %343
%347 = load double*, double** %20
%348 = call i32 @free(double* %347)
br label %349
349: ; preds = %346, %343
%350 = load double*, double** %21
%351 = icmp ne double* %350, null
br i1 %351, label %352, label %355
352: ; preds = %349
%353 = load double*, double** %21
%354 = call i32 @free(double* %353)
br label %355
355: ; preds = %352, %349
%356 = load i32 (i8*, ...)*, i32 (i8*, ...)** %16
%357 = icmp ne i32 (i8*, ...)* %356, null
br i1 %357, label %358, label %368
358: ; preds = %355
%359 = load i32 (i8*, ...)*, i32 (i8*, ...)** %16
%360 = load i8*, i8** %15
%361 = load i8, i8* %360
%362 = zext i8 %361 to i32
%363 = call i32 (i8*, ...) %359(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %362)
%364 = load i32 (i8*, ...)*, i32 (i8*, ...)** %16
%365 = call i32 (...) @p3dGetElapsedTime_min()
%366 = call i32 (...) @p3dGetElapsedTime_sec()
%367 = call i32 (i8*, ...) %364(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), i32 %365, i32 %366)
br label %368
368: ; preds = %358, %355
store i32 2, i32* %9
br label %400
369: ; preds = %71, %61, %51, %41
%370 = load i32 (i8*, ...)*, i32 (i8*, ...)** %16
%371 = icmp ne i32 (i8*, ...)* %370, null
br i1 %371, label %372, label %375
372: ; preds = %369
%373 = load i32 (i8*, ...)*, i32 (i8*, ...)** %16
%374 = call i32 (i8*, ...) %373(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0))
br label %375
375: ; preds = %372, %369
%376 = load double*, double** %18
%377 = icmp ne double* %376, null
br i1 %377, label %378, label %381
378: ; preds = %375
%379 = load double*, double** %18
%380 = call i32 @free(double* %379)
br label %381
381: ; preds = %378, %375
%382 = load double*, double** %19
%383 = icmp ne double* %382, null
br i1 %383, label %384, label %387
384: ; preds = %381
%385 = load double*, double** %19
%386 = call i32 @free(double* %385)
br label %387
387: ; preds = %384, %381
%388 = load double*, double** %20
%389 = icmp ne double* %388, null
br i1 %389, label %390, label %393
390: ; preds = %387
%391 = load double*, double** %20
%392 = call i32 @free(double* %391)
br label %393
393: ; preds = %390, %387
%394 = load double*, double** %21
%395 = icmp ne double* %394, null
br i1 %395, label %396, label %399
396: ; preds = %393
%397 = load double*, double** %21
%398 = call i32 @free(double* %397)
br label %399
399: ; preds = %396, %393
store i32 0, i32* %9
br label %400
400: ; preds = %399, %368
%401 = load i32, i32* %9
ret i32 %401
}

LLVM IR (-O2):
@.str = [63 x i8] c"Pore3D - Thresholding image according to Johannsen's method...\00"
@UCHAR_MAX = global i32 0
@.str.1 = [27 x i8] c"\09Determined threshold: %d.\00"
@.str.2 = [54 x i8] c"Pore3D - Image thresholded successfully in %dm%0.3fs.\00"
@.str.3 = [60 x i8] c"Pore3D - Not enough (contiguous) memory. Program will exit.\00"
define i32 @p3dJohannsenThresholding_8(i8* nocapture %0, i8* nocapture writeonly %1, i32 %2, i32 %3, i32 %4, i8* nocapture %5, i32 (i8*, ...)* %6, i32 (i32, ...)* nocapture readnone %7) {
%9 = icmp eq i32 (i8*, ...)* %6, null
br i1 %9, label %13, label %10
10: ; preds = %8
%11 = tail call i32 (...) @p3dResetStartTime()
%12 = tail call i32 (i8*, ...) %6(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %10, %8
%14 = load i32, i32* @UCHAR_MAX
%15 = add nsw i32 %14, 1
%16 = tail call i64 @calloc(i32 %15, i32 8)
%17 = inttoptr i64 %16 to double*
%18 = icmp eq i64 %16, 0
br i1 %18, label %446, label %19
19: ; preds = %13
%20 = load i32, i32* @UCHAR_MAX
%21 = shl i32 %20, 3
%22 = add i32 %21, 8
%23 = tail call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to double*
%25 = inttoptr i64 %23 to i8*
%26 = icmp eq i64 %23, 0
br i1 %26, label %446, label %27
27: ; preds = %19
%28 = load i32, i32* @UCHAR_MAX
%29 = shl i32 %28, 3
%30 = add i32 %29, 8
%31 = tail call i64 @malloc(i32 %30)
%32 = inttoptr i64 %31 to double*
%33 = icmp eq i64 %31, 0
br i1 %33, label %446, label %34
34: ; preds = %27
%35 = load i32, i32* @UCHAR_MAX
%36 = shl i32 %35, 3
%37 = add i32 %36, 8
%38 = tail call i64 @malloc(i32 %37)
%39 = inttoptr i64 %38 to double*
%40 = icmp eq i64 %38, 0
br i1 %40, label %446, label %41
41: ; preds = %34
%42 = mul nsw i32 %3, %2
%43 = mul i32 %42, %4
%44 = icmp sgt i32 %43, 0
br i1 %44, label %45, label %67
45: ; preds = %41
%46 = zext i32 %43 to i64
%47 = add nsw i64 %46, -1
%48 = and i64 %46, 3
%49 = icmp ult i64 %47, 3
br i1 %49, label %52, label %50
50: ; preds = %45
%51 = and i64 %46, 4294967292
br label %119
52: ; preds = %119, %45
%53 = phi i64 [ 0, %45 ], [ %149, %119 ]
%54 = icmp eq i64 %48, 0
br i1 %54, label %67, label %55
55: ; preds = %52, %55
%56 = phi i64 [ %64, %55 ], [ %53, %52 ]
%57 = phi i64 [ %65, %55 ], [ 0, %52 ]
%58 = getelementptr inbounds i8, i8* %0, i64 %56
%59 = load i8, i8* %58
%60 = zext i8 %59 to i64
%61 = getelementptr inbounds double, double* %17, i64 %60
%62 = load double, double* %61
%63 = fadd double %62, 1.000000e+00
store double %63, double* %61
%64 = add nuw nsw i64 %56, 1
%65 = add i64 %57, 1
%66 = icmp eq i64 %65, %48
br i1 %66, label %67, label %55
67: ; preds = %52, %55, %41
%68 = load i32, i32* @UCHAR_MAX
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %73
70: ; preds = %67
%71 = load double, double* %17
store double %71, double* %24
%72 = fsub double 1.000000e+00, %71
store double %72, double* %39
br label %254
73: ; preds = %67
%74 = sitofp i32 %43 to double
%75 = add nuw i32 %68, 1
%76 = zext i32 %75 to i64
%77 = icmp eq i32 %68, 0
br i1 %77, label %117, label %78
78: ; preds = %73
%79 = and i64 %76, 4294967294
%80 = insertelement <2 x double> poison, double %74, i64 0
%81 = shufflevector <2 x double> %80, <2 x double> poison, <2 x i32> zeroinitializer
%82 = add nsw i64 %79, -2
%83 = lshr exact i64 %82, 1
%84 = add nuw i64 %83, 1
%85 = and i64 %84, 1
%86 = icmp eq i64 %82, 0
br i1 %86, label %106, label %87
87: ; preds = %78
%88 = and i64 %84, -2
br label %89
89: ; preds = %89, %87
%90 = phi i64 [ 0, %87 ], [ %103, %89 ]
%91 = phi i64 [ 0, %87 ], [ %104, %89 ]
%92 = getelementptr inbounds double, double* %17, i64 %90
%93 = bitcast double* %92 to <2 x double>*
%94 = load <2 x double>, <2 x double>* %93
%95 = fdiv <2 x double> %94, %81
%96 = bitcast double* %92 to <2 x double>*
store <2 x double> %95, <2 x double>* %96
%97 = or i64 %90, 2
%98 = getelementptr inbounds double, double* %17, i64 %97
%99 = bitcast double* %98 to <2 x double>*
%100 = load <2 x double>, <2 x double>* %99
%101 = fdiv <2 x double> %100, %81
%102 = bitcast double* %98 to <2 x double>*
store <2 x double> %101, <2 x double>* %102
%103 = add nuw i64 %90, 4
%104 = add nuw i64 %91, 2
%105 = icmp eq i64 %104, %88
br i1 %105, label %106, label %89
106: ; preds = %89, %78
%107 = phi i64 [ 0, %78 ], [ %103, %89 ]
%108 = icmp eq i64 %85, 0
br i1 %108, label %115, label %109
109: ; preds = %106
%110 = getelementptr inbounds double, double* %17, i64 %107
%111 = bitcast double* %110 to <2 x double>*
%112 = load <2 x double>, <2 x double>* %111
%113 = fdiv <2 x double> %112, %81
%114 = bitcast double* %110 to <2 x double>*
store <2 x double> %113, <2 x double>* %114
br label %115
115: ; preds = %106, %109
%116 = icmp eq i64 %79, %76
br i1 %116, label %159, label %117
117: ; preds = %73, %115
%118 = phi i64 [ 0, %73 ], [ %79, %115 ]
br label %152
119: ; preds = %119, %50
%120 = phi i64 [ 0, %50 ], [ %149, %119 ]
%121 = phi i64 [ 0, %50 ], [ %150, %119 ]
%122 = getelementptr inbounds i8, i8* %0, i64 %120
%123 = load i8, i8* %122
%124 = zext i8 %123 to i64
%125 = getelementptr inbounds double, double* %17, i64 %124
%126 = load double, double* %125
%127 = fadd double %126, 1.000000e+00
store double %127, double* %125
%128 = or i64 %120, 1
%129 = getelementptr inbounds i8, i8* %0, i64 %128
%130 = load i8, i8* %129
%131 = zext i8 %130 to i64
%132 = getelementptr inbounds double, double* %17, i64 %131
%133 = load double, double* %132
%134 = fadd double %133, 1.000000e+00
store double %134, double* %132
%135 = or i64 %120, 2
%136 = getelementptr inbounds i8, i8* %0, i64 %135
%137 = load i8, i8* %136
%138 = zext i8 %137 to i64
%139 = getelementptr inbounds double, double* %17, i64 %138
%140 = load double, double* %139
%141 = fadd double %140, 1.000000e+00
store double %141, double* %139
%142 = or i64 %120, 3
%143 = getelementptr inbounds i8, i8* %0, i64 %142
%144 = load i8, i8* %143
%145 = zext i8 %144 to i64
%146 = getelementptr inbounds double, double* %17, i64 %145
%147 = load double, double* %146
%148 = fadd double %147, 1.000000e+00
store double %148, double* %146
%149 = add nuw nsw i64 %120, 4
%150 = add i64 %121, 4
%151 = icmp eq i64 %150, %51
br i1 %151, label %52, label %119
152: ; preds = %117, %152
%153 = phi i64 [ %157, %152 ], [ %118, %117 ]
%154 = getelementptr inbounds double, double* %17, i64 %153
%155 = load double, double* %154
%156 = fdiv double %155, %74
store double %156, double* %154
%157 = add nuw nsw i64 %153, 1
%158 = icmp eq i64 %157, %76
br i1 %158, label %159, label %152
159: ; preds = %152, %115
%160 = load double, double* %17
store double %160, double* %24
%161 = fsub double 1.000000e+00, %160
store double %161, double* %39
%162 = icmp slt i32 %68, 1
br i1 %162, label %254, label %163
163: ; preds = %159
%164 = add nuw i32 %68, 1
%165 = zext i32 %164 to i64
%166 = getelementptr double, double* %24, i64 %165
%167 = getelementptr double, double* %39, i64 1
%168 = getelementptr double, double* %39, i64 %165
%169 = bitcast double* %168 to i8*
%170 = icmp ult i8* %25, %169
%171 = icmp ult double* %167, %166
%172 = and i1 %170, %171
br i1 %172, label %173, label %203
173: ; preds = %163
%174 = add nsw i64 %165, -1
%175 = and i64 %174, 1
%176 = icmp eq i32 %164, 2
br i1 %176, label %230, label %177
177: ; preds = %173
%178 = and i64 %174, -2
br label %179
179: ; preds = %179, %177
%180 = phi i64 [ 1, %177 ], [ %200, %179 ]
%181 = phi i64 [ 0, %177 ], [ %201, %179 ]
%182 = add nsw i64 %180, -1
%183 = getelementptr inbounds double, double* %24, i64 %182
%184 = load double, double* %183
%185 = getelementptr inbounds double, double* %17, i64 %180
%186 = load double, double* %185
%187 = fadd double %184, %186
%188 = getelementptr inbounds double, double* %24, i64 %180
store double %187, double* %188
%189 = fsub double 1.000000e+00, %184
%190 = getelementptr inbounds double, double* %39, i64 %180
store double %189, double* %190
%191 = add nuw nsw i64 %180, 1
%192 = getelementptr inbounds double, double* %24, i64 %180
%193 = load double, double* %192
%194 = getelementptr inbounds double, double* %17, i64 %191
%195 = load double, double* %194
%196 = fadd double %193, %195
%197 = getelementptr inbounds double, double* %24, i64 %191
store double %196, double* %197
%198 = fsub double 1.000000e+00, %193
%199 = getelementptr inbounds double, double* %39, i64 %191
store double %198, double* %199
%200 = add nuw nsw i64 %180, 2
%201 = add nuw i64 %181, 2
%202 = icmp eq i64 %201, %178
br i1 %202, label %230, label %179
203: ; preds = %163
%204 = load double, double* %24
%205 = add nsw i64 %165, -1
%206 = and i64 %205, 1
%207 = icmp eq i32 %164, 2
br i1 %207, label %243, label %208
208: ; preds = %203
%209 = and i64 %205, -2
br label %210
210: ; preds = %210, %208
%211 = phi double [ %204, %208 ], [ %223, %210 ]
%212 = phi i64 [ 1, %208 ], [ %227, %210 ]
%213 = phi i64 [ 0, %208 ], [ %228, %210 ]
%214 = getelementptr inbounds double, double* %17, i64 %212
%215 = load double, double* %214
%216 = fadd double %211, %215
%217 = getelementptr inbounds double, double* %24, i64 %212
store double %216, double* %217
%218 = fsub double 1.000000e+00, %211
%219 = getelementptr inbounds double, double* %39, i64 %212
store double %218, double* %219
%220 = add nuw nsw i64 %212, 1
%221 = getelementptr inbounds double, double* %17, i64 %220
%222 = load double, double* %221
%223 = fadd double %216, %222
%224 = getelementptr inbounds double, double* %24, i64 %220
store double %223, double* %224
%225 = fsub double 1.000000e+00, %216
%226 = getelementptr inbounds double, double* %39, i64 %220
store double %225, double* %226
%227 = add nuw nsw i64 %212, 2
%228 = add i64 %213, 2
%229 = icmp eq i64 %228, %209
br i1 %229, label %243, label %210
230: ; preds = %179, %173
%231 = phi i64 [ 1, %173 ], [ %200, %179 ]
%232 = icmp eq i64 %175, 0
br i1 %232, label %254, label %233
233: ; preds = %230
%234 = add nsw i64 %231, -1
%235 = getelementptr inbounds double, double* %24, i64 %234
%236 = load double, double* %235
%237 = getelementptr inbounds double, double* %17, i64 %231
%238 = load double, double* %237
%239 = fadd double %236, %238
%240 = getelementptr inbounds double, double* %24, i64 %231
store double %239, double* %240
%241 = fsub double 1.000000e+00, %236
%242 = getelementptr inbounds double, double* %39, i64 %231
store double %241, double* %242
br label %254
243: ; preds = %210, %203
%244 = phi double [ %204, %203 ], [ %223, %210 ]
%245 = phi i64 [ 1, %203 ], [ %227, %210 ]
%246 = icmp eq i64 %206, 0
br i1 %246, label %254, label %247
247: ; preds = %243
%248 = getelementptr inbounds double, double* %17, i64 %245
%249 = load double, double* %248
%250 = fadd double %244, %249
%251 = getelementptr inbounds double, double* %24, i64 %245
store double %250, double* %251
%252 = fsub double 1.000000e+00, %244
%253 = getelementptr inbounds double, double* %39, i64 %245
store double %252, double* %253
br label %254
254: ; preds = %247, %243, %233, %230, %70, %159
br label %255
255: ; preds = %254, %255
%256 = phi i64 [ %257, %255 ], [ 0, %254 ]
%257 = add nuw i64 %256, 1
%258 = getelementptr inbounds double, double* %17, i64 %256
%259 = load double, double* %258
%260 = fcmp ugt double %259, 0.000000e+00
br i1 %260, label %261, label %255
261: ; preds = %255
%262 = sext i32 %68 to i64
br label %263
263: ; preds = %261, %263
%264 = phi i64 [ %262, %261 ], [ %265, %263 ]
%265 = add i64 %264, -1
%266 = getelementptr inbounds double, double* %17, i64 %264
%267 = load double, double* %266
%268 = fcmp ugt double %267, 0.000000e+00
br i1 %268, label %269, label %263
269: ; preds = %263
%270 = trunc i64 %257 to i32
%271 = trunc i64 %264 to i32
%272 = icmp slt i32 %270, %271
br i1 %272, label %273, label %328
273: ; preds = %269
%274 = shl i64 %257, 32
%275 = ashr exact i64 %274, 32
br label %276
276: ; preds = %273, %323
%277 = phi i64 [ %275, %273 ], [ %324, %323 ]
%278 = phi i32 [ -1, %273 ], [ %325, %323 ]
%279 = trunc i64 %277 to i32
%280 = and i64 %277, 4294967295
%281 = getelementptr inbounds double, double* %17, i64 %280
%282 = load double, double* %281
%283 = fcmp ugt double %282, 0.000000e+00
br i1 %283, label %286, label %284
284: ; preds = %276
%285 = add nsw i64 %277, 1
br label %323
286: ; preds = %276
%287 = getelementptr inbounds double, double* %24, i64 %280
%288 = load double, double* %287
%289 = tail call double @_p3dJohannsenThresholding_dlog(double %288)
%290 = load double, double* %287
%291 = fdiv double 1.000000e+00, %290
%292 = load double, double* %281
%293 = tail call double @_p3dJohannsenThresholding_entropy(double %292)
%294 = add nsw i64 %277, -1
%295 = getelementptr inbounds double, double* %24, i64 %294
%296 = load double, double* %295
%297 = tail call double @_p3dJohannsenThresholding_entropy(double %296)
%298 = fadd double %293, %297
%299 = tail call double @llvm.fmuladd.f64(double %291, double %298, double %289)
%300 = getelementptr inbounds double, double* %39, i64 %280
%301 = load double, double* %300
%302 = tail call double @_p3dJohannsenThresholding_dlog(double %301)
%303 = load double, double* %300
%304 = fdiv double 1.000000e+00, %303
%305 = load double, double* %281
%306 = tail call double @_p3dJohannsenThresholding_entropy(double %305)
%307 = add nsw i64 %277, 1
%308 = and i64 %307, 4294967295
%309 = getelementptr inbounds double, double* %39, i64 %308
%310 = load double, double* %309
%311 = tail call double @_p3dJohannsenThresholding_entropy(double %310)
%312 = fadd double %306, %311
%313 = tail call double @llvm.fmuladd.f64(double %304, double %312, double %302)
%314 = fadd double %299, %313
%315 = getelementptr inbounds double, double* %32, i64 %280
store double %314, double* %315
%316 = icmp slt i32 %278, 0
br i1 %316, label %323, label %317
317: ; preds = %286
%318 = zext i32 %278 to i64
%319 = getelementptr inbounds double, double* %32, i64 %318
%320 = load double, double* %319
%321 = fcmp olt double %314, %320
br i1 %321, label %322, label %323
322: ; preds = %317
br label %323
323: ; preds = %284, %286, %322, %317
%324 = phi i64 [ %285, %284 ], [ %307, %286 ], [ %307, %322 ], [ %307, %317 ]
%325 = phi i32 [ %278, %284 ], [ %279, %286 ], [ %279, %322 ], [ %278, %317 ]
%326 = trunc i64 %324 to i32
%327 = icmp eq i32 %326, %271
br i1 %327, label %328, label %276
328: ; preds = %323, %269
%329 = phi i32 [ -1, %269 ], [ %325, %323 ]
%330 = trunc i32 %329 to i8
store i8 %330, i8* %5
br i1 %44, label %331, label %434
331: ; preds = %328
%332 = zext i32 %43 to i64
%333 = load i8, i8* %0
%334 = icmp ugt i8 %333, %330
%335 = load i32, i32* @UCHAR_MAX
%336 = trunc i32 %335 to i8
%337 = select i1 %334, i8 %336, i8 0
store i8 %337, i8* %1
%338 = icmp eq i32 %43, 1
br i1 %338, label %434, label %339
339: ; preds = %331
%340 = add nsw i64 %332, -1
%341 = icmp ult i64 %340, 8
br i1 %341, label %394, label %342
342: ; preds = %339
%343 = getelementptr i8, i8* %1, i64 1
%344 = getelementptr i8, i8* %1, i64 %332
%345 = getelementptr i8, i8* %0, i64 1
%346 = getelementptr i8, i8* %0, i64 %332
%347 = icmp ult i8* %1, %5
%348 = icmp ugt i8* %344, %5
%349 = and i1 %347, %348
%350 = icmp ult i8* %343, %346
%351 = icmp ult i8* %345, %344
%352 = and i1 %350, %351
%353 = or i1 %349, %352
%354 = icmp ult i8* %343, bitcast (i32* getelementptr inbounds (i32, i32* @UCHAR_MAX, i64 1) to i8*)
%355 = icmp ugt i8* %344, bitcast (i32* @UCHAR_MAX to i8*)
%356 = and i1 %354, %355
%357 = or i1 %353, %356
br i1 %357, label %394, label %358
358: ; preds = %342
%359 = and i64 %340, -8
%360 = or i64 %359, 1
%361 = load i8, i8* %5
%362 = insertelement <4 x i8> poison, i8 %361, i64 0
%363 = shufflevector <4 x i8> %362, <4 x i8> poison, <4 x i32> zeroinitializer
%364 = insertelement <4 x i8> poison, i8 %361, i64 0
%365 = shufflevector <4 x i8> %364, <4 x i8> poison, <4 x i32> zeroinitializer
%366 = load i32, i32* @UCHAR_MAX
%367 = trunc i32 %366 to i8
%368 = insertelement <4 x i8> undef, i8 %367, i64 0
%369 = shufflevector <4 x i8> %368, <4 x i8> poison, <4 x i32> zeroinitializer
%370 = trunc i32 %366 to i8
%371 = insertelement <4 x i8> undef, i8 %370, i64 0
%372 = shufflevector <4 x i8> %371, <4 x i8> poison, <4 x i32> zeroinitializer
br label %373
373: ; preds = %373, %358
%374 = phi i64 [ 0, %358 ], [ %390, %373 ]
%375 = or i64 %374, 1
%376 = getelementptr inbounds i8, i8* %0, i64 %375
%377 = bitcast i8* %376 to <4 x i8>*
%378 = load <4 x i8>, <4 x i8>* %377
%379 = getelementptr inbounds i8, i8* %376, i64 4
%380 = bitcast i8* %379 to <4 x i8>*
%381 = load <4 x i8>, <4 x i8>* %380
%382 = icmp ugt <4 x i8> %378, %363
%383 = icmp ugt <4 x i8> %381, %365
%384 = select <4 x i1> %382, <4 x i8> %369, <4 x i8> zeroinitializer
%385 = select <4 x i1> %383, <4 x i8> %372, <4 x i8> zeroinitializer
%386 = getelementptr inbounds i8, i8* %1, i64 %375
%387 = bitcast i8* %386 to <4 x i8>*
store <4 x i8> %384, <4 x i8>* %387
%388 = getelementptr inbounds i8, i8* %386, i64 4
%389 = bitcast i8* %388 to <4 x i8>*
store <4 x i8> %385, <4 x i8>* %389
%390 = add nuw i64 %374, 8
%391 = icmp eq i64 %390, %359
br i1 %391, label %392, label %373
392: ; preds = %373
%393 = icmp eq i64 %340, %359
br i1 %393, label %434, label %394
394: ; preds = %342, %339, %392
%395 = phi i64 [ 1, %342 ], [ 1, %339 ], [ %360, %392 ]
%396 = xor i64 %395, -1
%397 = and i64 %332, 1
%398 = icmp eq i64 %397, 0
br i1 %398, label %399, label %409
399: ; preds = %394
%400 = load i8, i8* %5
%401 = getelementptr inbounds i8, i8* %0, i64 %395
%402 = load i8, i8* %401
%403 = icmp ugt i8 %402, %400
%404 = load i32, i32* @UCHAR_MAX
%405 = trunc i32 %404 to i8
%406 = select i1 %403, i8 %405, i8 0
%407 = getelementptr inbounds i8, i8* %1, i64 %395
store i8 %406, i8* %407
%408 = add nuw nsw i64 %395, 1
br label %409
409: ; preds = %399, %394
%410 = phi i64 [ %395, %394 ], [ %408, %399 ]
%411 = sub nsw i64 0, %332
%412 = icmp eq i64 %396, %411
br i1 %412, label %434, label %413
413: ; preds = %409, %413
%414 = phi i64 [ %432, %413 ], [ %410, %409 ]
%415 = load i8, i8* %5
%416 = getelementptr inbounds i8, i8* %0, i64 %414
%417 = load i8, i8* %416
%418 = icmp ugt i8 %417, %415
%419 = load i32, i32* @UCHAR_MAX
%420 = trunc i32 %419 to i8
%421 = select i1 %418, i8 %420, i8 0
%422 = getelementptr inbounds i8, i8* %1, i64 %414
store i8 %421, i8* %422
%423 = add nuw nsw i64 %414, 1
%424 = load i8, i8* %5
%425 = getelementptr inbounds i8, i8* %0, i64 %423
%426 = load i8, i8* %425
%427 = icmp ugt i8 %426, %424
%428 = load i32, i32* @UCHAR_MAX
%429 = trunc i32 %428 to i8
%430 = select i1 %427, i8 %429, i8 0
%431 = getelementptr inbounds i8, i8* %1, i64 %423
store i8 %430, i8* %431
%432 = add nuw nsw i64 %414, 2
%433 = icmp eq i64 %432, %332
br i1 %433, label %434, label %413
434: ; preds = %409, %413, %331, %392, %328
%435 = tail call i32 @free(double* %17)
%436 = tail call i32 @free(double* %24)
%437 = tail call i32 @free(double* %32)
%438 = tail call i32 @free(double* %39)
br i1 %9, label %462, label %439
439: ; preds = %434
%440 = load i8, i8* %5
%441 = zext i8 %440 to i32
%442 = tail call i32 (i8*, ...) %6(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %441)
%443 = tail call i32 (...) @p3dGetElapsedTime_min()
%444 = tail call i32 (...) @p3dGetElapsedTime_sec()
%445 = tail call i32 (i8*, ...) %6(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), i32 %443, i32 %444)
br label %462
446: ; preds = %34, %27, %19, %13
%447 = phi double* [ null, %13 ], [ null, %19 ], [ %24, %27 ], [ %24, %34 ]
%448 = phi double* [ null, %13 ], [ null, %19 ], [ null, %27 ], [ %32, %34 ]
br i1 %9, label %451, label %449
449: ; preds = %446
%450 = tail call i32 (i8*, ...) %6(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0))
br label %451
451: ; preds = %449, %446
br i1 %18, label %454, label %452
452: ; preds = %451
%453 = tail call i32 @free(double* %17)
br label %454
454: ; preds = %452, %451
%455 = icmp eq double* %447, null
br i1 %455, label %458, label %456
456: ; preds = %454
%457 = tail call i32 @free(double* %447)
br label %458
458: ; preds = %456, %454
%459 = icmp eq double* %448, null
br i1 %459, label %462, label %460
460: ; preds = %458
%461 = tail call i32 @free(double* %448)
br label %462
462: ; preds = %460, %458, %434, %439
%463 = phi i32 [ 2, %439 ], [ 2, %434 ], [ 0, %458 ], [ 0, %460 ]
ret i32 %463
}