#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 _p3dPunThresholding_entropy(double *, int);
double _p3dPunThresholding_flog(double);
double _p3dPunThresholding_maxfromt_8(double *, int);
double _p3dPunThresholding_maxtot(double *, int);
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 p3dPunThresholding_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 *Ht = NULL;
  double *Pt = NULL;
  double *F = NULL;
  double HT, x, y, z, to, from;
  int i, ct, t;
  if (wr_log != NULL) {
    p3dResetStartTime();
    wr_log("Pore3D - Thresholding image according to Pun's method...");
  }
  if (((Ht = (double *)malloc(sizeof(double) * (UCHAR_MAX + 1))) == 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 (((prob = (double *)calloc((UCHAR_MAX + 1), sizeof(double))) == 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);
  HT = Ht[0] = _p3dPunThresholding_entropy(prob, 0);
  Pt[0] = prob[0];
  for (i = 1; i <= UCHAR_MAX; i++) {
    Pt[i] = Pt[i - 1] + prob[i];
    x = _p3dPunThresholding_entropy(prob, i);
    Ht[i] = Ht[i - 1] + x;
    HT += x;
  }
  t = 0;
  for (i = 0; i <= UCHAR_MAX; i++) {
    to = (_p3dPunThresholding_maxtot(prob, i));
    from = _p3dPunThresholding_maxfromt_8(prob, i);
    if (to > 0.0 && from > 0.0) {
      x = (Ht[i] / HT) * _p3dPunThresholding_flog(Pt[i]) /
          _p3dPunThresholding_flog(to);
      y = 1.0 - (Ht[i] / HT);
      z = _p3dPunThresholding_flog(1 - Pt[i]) / _p3dPunThresholding_flog(from);
    } else
      x = y = z = 0.0;
    F[i] = x + y * z;
    if (i > 0 && 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 (wr_log != NULL) {
    wr_log("\tDetermined threshold: %d.", *thresh);
    wr_log("Pore3D - Image thresholded successfully in %dm%0.3fs.",
           p3dGetElapsedTime_min(), p3dGetElapsedTime_sec());
  }
  if (prob != NULL)
    free(prob);
  if (Ht != NULL)
    free(Ht);
  if (Pt != NULL)
    free(Pt);
  if (F != NULL)
    free(F);
  return 2;
MEM_ERROR:
  if (wr_log != NULL) {
    wr_log("Pore3D - Not enough (contiguous) memory. Program will exit.");
  }
  if (prob != NULL)
    free(prob);
  if (Ht != NULL)
    free(Ht);
  if (Pt != NULL)
    free(Pt);
  if (F != NULL)
    free(F);
  return 0;
}


x86 assembly (clang, -O0):
<p3dPunThresholding_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     1207 <p3dPunThresholding_8+0x67>
mov    $0x0,%al
call   1080 <p3dResetStartTime@plt>
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   *0x10(%rbp)
mov    0x2de2(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    1233 <p3dPunThresholding_8+0x93>
jmp    1797 <p3dPunThresholding_8+0x5f7>
mov    0x2db6(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
jne    125f <p3dPunThresholding_8+0xbf>
jmp    1797 <p3dPunThresholding_8+0x5f7>
mov    0x2d8a(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
jne    128b <p3dPunThresholding_8+0xeb>
jmp    1797 <p3dPunThresholding_8+0x5f7>
mov    0x2d5e(%rip),%rax
mov    (%rax),%edi
add    $0x1,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    12b4 <p3dPunThresholding_8+0x114>
jmp    1797 <p3dPunThresholding_8+0x5f7>
movl   $0x0,-0x88(%rbp)
mov    -0x88(%rbp),%eax
mov    -0x1c(%rbp),%ecx
imul   -0x20(%rbp),%ecx
imul   -0x24(%rbp),%ecx
cmp    %ecx,%eax
jge    1323 <p3dPunThresholding_8+0x183>
mov    -0x38(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq -0x88(%rbp),%rdx
movzbl (%rcx,%rdx,1),%ecx
movsd  0xd0e(%rip),%xmm0
addsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq -0x88(%rbp),%rdx
movzbl (%rcx,%rdx,1),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    12be <p3dPunThresholding_8+0x11e>
movl   $0x0,-0x88(%rbp)
mov    -0x88(%rbp),%eax
mov    0x2cb6(%rip),%rcx
cmp    (%rcx),%eax
jg     1389 <p3dPunThresholding_8+0x1e9>
mov    -0x38(%rbp),%rax
movslq -0x88(%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 -0x88(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    132d <p3dPunThresholding_8+0x18d>
mov    -0x38(%rbp),%rdi
xor    %esi,%esi
call   1090 <_p3dPunThresholding_entropy@plt>
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  %xmm0,-0x58(%rbp)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    0x2c28(%rip),%rcx
cmp    (%rcx),%eax
jg     1466 <p3dPunThresholding_8+0x2c6>
mov    -0x48(%rbp),%rax
mov    -0x84(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x84(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
mov    -0x48(%rbp),%rax
movslq -0x84(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%rdi
mov    -0x84(%rbp),%esi
call   1090 <_p3dPunThresholding_entropy@plt>
movsd  %xmm0,-0x60(%rbp)
mov    -0x40(%rbp),%rax
mov    -0x84(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x60(%rbp),%xmm0
mov    -0x40(%rbp),%rax
movslq -0x84(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x60(%rbp),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    13bb <p3dPunThresholding_8+0x21b>
movl   $0x0,-0x8c(%rbp)
movl   $0x0,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    0x2b69(%rip),%rcx
cmp    (%rcx),%eax
jg     1647 <p3dPunThresholding_8+0x4a7>
mov    -0x38(%rbp),%rdi
mov    -0x84(%rbp),%esi
call   10b0 <_p3dPunThresholding_maxtot@plt>
movsd  %xmm0,-0x78(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x84(%rbp),%esi
call   10c0 <_p3dPunThresholding_maxfromt_8@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  -0x78(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    15b0 <p3dPunThresholding_8+0x410>
movsd  -0x80(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    15b0 <p3dPunThresholding_8+0x410>
mov    -0x40(%rbp),%rax
movslq -0x84(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
mov    -0x48(%rbp),%rax
movslq -0x84(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <_p3dPunThresholding_flog@plt>
movaps %xmm0,%xmm1
movsd  -0xa8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x78(%rbp),%xmm0
call   1040 <_p3dPunThresholding_flog@plt>
movaps %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x40(%rbp),%rax
movslq -0x84(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
divsd  -0x58(%rbp),%xmm1
movsd  0xaa1(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x48(%rbp),%rax
movslq -0x84(%rbp),%rcx
movsd  0xa85(%rip),%xmm0
subsd  (%rax,%rcx,8),%xmm0
call   1040 <_p3dPunThresholding_flog@plt>
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
call   1040 <_p3dPunThresholding_flog@plt>
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
jmp    15c8 <p3dPunThresholding_8+0x428>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x70(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x50(%rbp),%rax
movslq -0x84(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
cmpl   $0x0,-0x84(%rbp)
jle    162e <p3dPunThresholding_8+0x48e>
mov    -0x50(%rbp),%rax
movslq -0x84(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x50(%rbp),%rax
movslq -0x8c(%rbp),%rcx
ucomisd (%rax,%rcx,8),%xmm0
jbe    162e <p3dPunThresholding_8+0x48e>
mov    -0x84(%rbp),%eax
mov    %eax,-0x8c(%rbp)
jmp    1633 <p3dPunThresholding_8+0x493>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    147a <p3dPunThresholding_8+0x2da>
mov    -0x8c(%rbp),%eax
mov    %al,%cl
mov    -0x30(%rbp),%rax
mov    %cl,(%rax)
movl   $0x0,-0x88(%rbp)
mov    -0x88(%rbp),%eax
mov    -0x1c(%rbp),%ecx
imul   -0x20(%rbp),%ecx
imul   -0x24(%rbp),%ecx
cmp    %ecx,%eax
jge    16e1 <p3dPunThresholding_8+0x541>
mov    -0x10(%rbp),%rax
movslq -0x88(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x30(%rbp),%rcx
movzbl (%rcx),%ecx
cmp    %ecx,%eax
jle    16aa <p3dPunThresholding_8+0x50a>
mov    0x2953(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xac(%rbp)
jmp    16b7 <p3dPunThresholding_8+0x517>
xor    %eax,%eax
mov    %eax,-0xac(%rbp)
jmp    16b7 <p3dPunThresholding_8+0x517>
mov    -0xac(%rbp),%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x88(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    165f <p3dPunThresholding_8+0x4bf>
cmpq   $0x0,0x10(%rbp)
je     173b <p3dPunThresholding_8+0x59b>
mov    0x10(%rbp),%rcx
mov    -0x30(%rbp),%rax
movzbl (%rax),%esi
lea    0x943(%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    0x925(%rip),%rdi
mov    $0x0,%al
call   *%rcx
cmpq   $0x0,-0x38(%rbp)
je     174f <p3dPunThresholding_8+0x5af>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x40(%rbp)
je     1763 <p3dPunThresholding_8+0x5c3>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x48(%rbp)
je     1777 <p3dPunThresholding_8+0x5d7>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x50(%rbp)
je     178b <p3dPunThresholding_8+0x5eb>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movl   $0x2,-0x4(%rbp)
jmp    1805 <p3dPunThresholding_8+0x665>
cmpq   $0x0,0x10(%rbp)
je     17ae <p3dPunThresholding_8+0x60e>
lea    0x8e9(%rip),%rdi
mov    $0x0,%al
call   *0x10(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     17c2 <p3dPunThresholding_8+0x622>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x40(%rbp)
je     17d6 <p3dPunThresholding_8+0x636>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x48(%rbp)
je     17ea <p3dPunThresholding_8+0x64a>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x50(%rbp)
je     17fe <p3dPunThresholding_8+0x65e>
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):
<p3dPunThresholding_8>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r9,0x60(%rsp)
mov    %r8d,%r13d
mov    %ecx,%r12d
mov    %edx,%r15d
mov    %rsi,0x38(%rsp)
mov    %rdi,%r14
mov    0xa0(%rsp),%rbx
test   %rbx,%rbx
je     11e3 <p3dPunThresholding_8+0x43>
xor    %eax,%eax
call   1080 <p3dResetStartTime@plt>
lea    0xe31(%rip),%rdi
xor    %eax,%eax
call   *%rbx
mov    0x2e06(%rip),%rbp
mov    0x0(%rbp),%eax
lea    0x8(,%rax,8),%edi
call   10a0 <malloc@plt>
mov    %rax,0x58(%rsp)
test   %rax,%rax
je     129b <p3dPunThresholding_8+0xfb>
mov    0x0(%rbp),%eax
lea    0x8(,%rax,8),%edi
call   10a0 <malloc@plt>
mov    %rax,0x28(%rsp)
test   %rax,%rax
je     129b <p3dPunThresholding_8+0xfb>
mov    0x0(%rbp),%eax
lea    0x8(,%rax,8),%edi
call   10a0 <malloc@plt>
mov    %rax,0x40(%rsp)
test   %rax,%rax
je     12dc <p3dPunThresholding_8+0x13c>
mov    %r12d,%ebx
mov    0x0(%rbp),%edi
add    $0x1,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
test   %rax,%rax
je     12e6 <p3dPunThresholding_8+0x146>
mov    %rax,%r12
mov    %ebx,%eax
imul   %r15d,%eax
imul   %r13d,%eax
mov    %eax,%ebx
mov    %eax,0x24(%rsp)
test   %eax,%eax
mov    0x28(%rsp),%r13
mov    0x2d76(%rip),%r15
mov    0x58(%rsp),%rbp
jle    13ad <p3dPunThresholding_8+0x20d>
lea    -0x1(%rbx),%rcx
mov    %ebx,%eax
and    $0x3,%eax
cmp    $0x3,%rcx
jae    12fa <p3dPunThresholding_8+0x15a>
xor    %ecx,%ecx
jmp    1370 <p3dPunThresholding_8+0x1d0>
xor    %ebp,%ebp
xor    %r14d,%r14d
test   %rbx,%rbx
je     12b0 <p3dPunThresholding_8+0x110>
lea    0xdee(%rip),%rdi
xor    %eax,%eax
call   *%rbx
mov    0x58(%rsp),%rdi
test   %rdi,%rdi
je     12bf <p3dPunThresholding_8+0x11f>
call   1030 <free@plt>
test   %rbp,%rbp
je     12cc <p3dPunThresholding_8+0x12c>
mov    %rbp,%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
test   %r14,%r14
jne    1993 <p3dPunThresholding_8+0x7f3>
jmp    199b <p3dPunThresholding_8+0x7fb>
xor    %r14d,%r14d
mov    0x28(%rsp),%rbp
jmp    12a0 <p3dPunThresholding_8+0x100>
mov    0xa0(%rsp),%rbx
mov    0x40(%rsp),%r14
mov    0x28(%rsp),%rbp
jmp    12a0 <p3dPunThresholding_8+0x100>
mov    %ebx,%edx
and    $0xfffffffc,%edx
xor    %ecx,%ecx
movsd  0xcf7(%rip),%xmm0
nopl   0x0(%rax)
movzbl (%r14,%rcx,1),%esi
movsd  (%r12,%rsi,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r12,%rsi,8)
movzbl 0x1(%r14,%rcx,1),%esi
movsd  (%r12,%rsi,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r12,%rsi,8)
movzbl 0x2(%r14,%rcx,1),%esi
movsd  (%r12,%rsi,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r12,%rsi,8)
movzbl 0x3(%r14,%rcx,1),%esi
movsd  (%r12,%rsi,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r12,%rsi,8)
add    $0x4,%rcx
cmp    %rcx,%rdx
jne    1310 <p3dPunThresholding_8+0x170>
test   %rax,%rax
je     13ad <p3dPunThresholding_8+0x20d>
add    %r14,%rcx
xor    %edx,%edx
movsd  0xc7e(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rcx,%rdx,1),%esi
movsd  (%r12,%rsi,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r12,%rsi,8)
add    $0x1,%rdx
cmp    %rdx,%rax
jne    1390 <p3dPunThresholding_8+0x1f0>
mov    (%r15),%ecx
test   %ecx,%ecx
js     1469 <p3dPunThresholding_8+0x2c9>
xorps  %xmm0,%xmm0
cvtsi2sdl 0x24(%rsp),%xmm0
lea    0x1(%rcx),%rax
test   %rcx,%rcx
je     1448 <p3dPunThresholding_8+0x2a8>
mov    %eax,%ecx
and    $0xfffffffe,%ecx
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x2(%rcx),%rsi
mov    %rsi,%rdx
shr    %rdx
add    $0x1,%rdx
test   %rsi,%rsi
je     18ea <p3dPunThresholding_8+0x74a>
mov    %rdx,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %esi,%esi
nopw   0x0(%rax,%rax,1)
movupd (%r12,%rsi,8),%xmm2
movupd 0x10(%r12,%rsi,8),%xmm3
divpd  %xmm1,%xmm2
movupd %xmm2,(%r12,%rsi,8)
divpd  %xmm1,%xmm3
movupd %xmm3,0x10(%r12,%rsi,8)
add    $0x4,%rsi
add    $0xfffffffffffffffe,%rdi
jne    1400 <p3dPunThresholding_8+0x260>
test   $0x1,%dl
je     1441 <p3dPunThresholding_8+0x2a1>
movupd (%r12,%rsi,8),%xmm2
divpd  %xmm1,%xmm2
movupd %xmm2,(%r12,%rsi,8)
cmp    %rax,%rcx
jne    1450 <p3dPunThresholding_8+0x2b0>
jmp    1469 <p3dPunThresholding_8+0x2c9>
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
movsd  (%r12,%rcx,8),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r12,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1450 <p3dPunThresholding_8+0x2b0>
mov    %rbx,0x30(%rsp)
mov    %r12,%rdi
xor    %esi,%esi
call   1090 <_p3dPunThresholding_entropy@plt>
movapd %xmm0,%xmm1
movsd  %xmm0,0x0(%rbp)
movsd  (%r12),%xmm0
movsd  %xmm0,0x0(%r13)
mov    (%r15),%eax
test   %eax,%eax
jle    1529 <p3dPunThresholding_8+0x389>
addsd  0x8(%r12),%xmm0
movsd  %xmm0,0x8(%r13)
mov    %r12,%rdi
mov    $0x1,%esi
movsd  %xmm1,0x18(%rsp)
call   1090 <_p3dPunThresholding_entropy@plt>
movsd  0x18(%rsp),%xmm1
addsd  %xmm0,%xmm1
addsd  0x0(%rbp),%xmm0
movsd  %xmm0,0x8(%rbp)
mov    (%r15),%eax
cmp    $0x2,%eax
jl     1529 <p3dPunThresholding_8+0x389>
mov    $0x2,%ebx
nopl   0x0(%rax)
movsd  %xmm1,0x18(%rsp)
movsd  -0x8(%r13,%rbx,8),%xmm0
addsd  (%r12,%rbx,8),%xmm0
movsd  %xmm0,0x0(%r13,%rbx,8)
mov    %r12,%rdi
mov    %ebx,%esi
call   1090 <_p3dPunThresholding_entropy@plt>
movsd  0x18(%rsp),%xmm1
addsd  %xmm0,%xmm1
addsd  -0x8(%rbp,%rbx,8),%xmm0
movsd  %xmm0,0x0(%rbp,%rbx,8)
movslq (%r15),%rax
lea    0x1(%rbx),%rcx
cmp    %rax,%rbx
mov    %rcx,%rbx
jl     14e0 <p3dPunThresholding_8+0x340>
test   %eax,%eax
js     161d <p3dPunThresholding_8+0x47d>
movsd  %xmm1,0x18(%rsp)
mov    %r12,%rdi
xor    %esi,%esi
call   10b0 <_p3dPunThresholding_maxtot@plt>
movsd  %xmm0,0x10(%rsp)
mov    %r12,%rdi
xor    %esi,%esi
call   10c0 <_p3dPunThresholding_maxfromt_8@plt>
movapd %xmm0,%xmm2
xorpd  %xmm1,%xmm1
movsd  0x10(%rsp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1624 <p3dPunThresholding_8+0x484>
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
xorpd  %xmm3,%xmm3
jbe    162c <p3dPunThresholding_8+0x48c>
movsd  0x0(%rbp),%xmm0
divsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x0(%r13),%xmm0
movsd  %xmm2,0x50(%rsp)
call   1040 <_p3dPunThresholding_flog@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <_p3dPunThresholding_flog@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x0(%rbp),%xmm1
divsd  0x18(%rsp),%xmm1
movsd  0xa25(%rip),%xmm0
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
movsd  %xmm2,0x10(%rsp)
subsd  0x0(%r13),%xmm0
call   1040 <_p3dPunThresholding_flog@plt>
movsd  %xmm0,0x48(%rsp)
movsd  0x50(%rsp),%xmm0
call   1040 <_p3dPunThresholding_flog@plt>
movsd  0x48(%rsp),%xmm3
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm3
movsd  0x10(%rsp),%xmm0
jmp    162c <p3dPunThresholding_8+0x48c>
xor    %ebx,%ebx
jmp    17b1 <p3dPunThresholding_8+0x611>
xorpd  %xmm0,%xmm0
xorpd  %xmm3,%xmm3
mulsd  %xmm3,%xmm0
addsd  %xmm1,%xmm0
mov    0x40(%rsp),%rax
movsd  %xmm0,(%rax)
xor    %ebx,%ebx
cmpl   $0x0,(%r15)
jle    17b1 <p3dPunThresholding_8+0x611>
mov    $0x1,%r13d
jmp    1675 <p3dPunThresholding_8+0x4d5>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x1(%r13),%rcx
movslq (%r15),%rdx
mov    %eax,%ebx
cmp    %rdx,%r13
mov    %rcx,%r13
jge    17aa <p3dPunThresholding_8+0x60a>
mov    %r12,%rdi
mov    %r13d,%esi
call   10b0 <_p3dPunThresholding_maxtot@plt>
movsd  %xmm0,0x10(%rsp)
mov    %r12,%rdi
mov    %r13d,%esi
call   10c0 <_p3dPunThresholding_maxfromt_8@plt>
movsd  0x10(%rsp),%xmm1
ucomisd 0x969(%rip),%xmm1
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
xorpd  %xmm2,%xmm2
xorpd  %xmm3,%xmm3
jbe    177f <p3dPunThresholding_8+0x5df>
ucomisd 0x94b(%rip),%xmm1
xorpd  %xmm0,%xmm0
xorpd  %xmm2,%xmm2
xorpd  %xmm3,%xmm3
jbe    177f <p3dPunThresholding_8+0x5df>
movsd  0x0(%rbp,%r13,8),%xmm0
divsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x28(%rsp),%r15
movsd  (%r15,%r13,8),%xmm0
movsd  %xmm1,0x50(%rsp)
call   1040 <_p3dPunThresholding_flog@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <_p3dPunThresholding_flog@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x0(%rbp,%r13,8),%xmm0
divsd  0x18(%rsp),%xmm0
movsd  0x8cc(%rip),%xmm1
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
movsd  %xmm2,0x10(%rsp)
movapd %xmm1,%xmm0
subsd  (%r15,%r13,8),%xmm0
mov    0x289d(%rip),%r15
call   1040 <_p3dPunThresholding_flog@plt>
movsd  %xmm0,0x48(%rsp)
movsd  0x50(%rsp),%xmm0
call   1040 <_p3dPunThresholding_flog@plt>
movsd  0x48(%rsp),%xmm3
movsd  0x10(%rsp),%xmm2
divsd  %xmm0,%xmm3
movsd  0x8(%rsp),%xmm0
mulsd  %xmm3,%xmm2
addsd  %xmm0,%xmm2
mov    0x40(%rsp),%rcx
movsd  %xmm2,(%rcx,%r13,8)
movslq %ebx,%rax
ucomisd (%rcx,%rax,8),%xmm2
mov    %r13d,%eax
ja     1660 <p3dPunThresholding_8+0x4c0>
mov    %ebx,%eax
jmp    1660 <p3dPunThresholding_8+0x4c0>
mov    %eax,%ebx
mov    0x28(%rsp),%r13
mov    0x60(%rsp),%r15
mov    %bl,(%r15)
cmpl   $0x0,0x24(%rsp)
mov    0x38(%rsp),%rdi
mov    0x30(%rsp),%rbp
jle    1934 <p3dPunThresholding_8+0x794>
xor    %eax,%eax
cmp    %bl,(%r14)
jbe    17de <p3dPunThresholding_8+0x63e>
mov    0x2814(%rip),%rax
mov    (%rax),%eax
mov    %al,(%rdi)
cmpl   $0x1,0x24(%rsp)
je     1934 <p3dPunThresholding_8+0x794>
lea    -0x1(%rbp),%r8
mov    $0x1,%eax
cmp    $0x8,%r8
jb     1904 <p3dPunThresholding_8+0x764>
lea    0x1(%rdi),%rsi
lea    (%rdi,%rbp,1),%rcx
lea    0x1(%r14),%rbx
cmp    %r15,%rdi
setb   %r9b
cmp    %r15,%rcx
seta   %r10b
lea    (%r14,%rbp,1),%rdx
cmp    %rdx,%rsi
setb   %dl
cmp    %rcx,%rbx
setb   %r11b
mov    0x27c0(%rip),%rdi
lea    0x4(%rdi),%rbx
cmp    %rbx,%rsi
setb   %bl
cmp    %rdi,%rcx
seta   %sil
test   %r10b,%r9b
jne    18fa <p3dPunThresholding_8+0x75a>
and    %r11b,%dl
jne    18fa <p3dPunThresholding_8+0x75a>
and    %sil,%bl
mov    0x38(%rsp),%rdi
mov    0x30(%rsp),%rbp
jne    1904 <p3dPunThresholding_8+0x764>
mov    %r8,%rdx
and    $0xfffffffffffffff8,%rdx
lea    0x1(%rdx),%rax
movzbl (%r15),%ecx
movd   %ecx,%xmm0
punpcklbw %xmm0,%xmm0
pshuflw $0x0,%xmm0,%xmm0
mov    0x2767(%rip),%rcx
movd   (%rcx),%xmm1
punpcklbw %xmm1,%xmm1
pshuflw $0x0,%xmm1,%xmm1
xor    %esi,%esi
nopl   0x0(%rax,%rax,1)
movd   0x1(%r14,%rsi,1),%xmm2
movd   0x5(%r14,%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(%rdi,%rsi,1)
movd   %xmm2,0x5(%rdi,%rsi,1)
add    $0x8,%rsi
cmp    %rsi,%rdx
jne    18a0 <p3dPunThresholding_8+0x700>
cmp    %rdx,%r8
jne    1904 <p3dPunThresholding_8+0x764>
jmp    1934 <p3dPunThresholding_8+0x794>
xor    %esi,%esi
test   $0x1,%dl
jne    1431 <p3dPunThresholding_8+0x291>
jmp    1441 <p3dPunThresholding_8+0x2a1>
mov    0x38(%rsp),%rdi
mov    0x30(%rsp),%rbp
mov    %rax,%rcx
not    %rcx
test   $0x1,%bpl
jne    192b <p3dPunThresholding_8+0x78b>
mov    (%r14,%rax,1),%bl
xor    %edx,%edx
cmp    (%r15),%bl
jbe    1924 <p3dPunThresholding_8+0x784>
mov    0x26ce(%rip),%rdx
mov    (%rdx),%edx
mov    %dl,(%rdi,%rax,1)
add    $0x1,%rax
add    %rbp,%rcx
jne    19c1 <p3dPunThresholding_8+0x821>
mov    0xa0(%rsp),%rbp
test   %rbp,%rbp
je     196f <p3dPunThresholding_8+0x7cf>
movzbl (%r15),%esi
lea    0x6fd(%rip),%rdi
xor    %eax,%eax
call   *%rbp
xor    %eax,%eax
call   1070 <p3dGetElapsedTime_min@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <p3dGetElapsedTime_sec@plt>
lea    0x6fd(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   *%rbp
mov    %r12,%rdi
call   1030 <free@plt>
mov    0x58(%rsp),%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    $0x2,%ebx
mov    0x40(%rsp),%r14
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
nopl   0x0(%rax)
mov    %cl,0x1(%rdi,%rax,1)
add    $0x2,%rax
cmp    %rax,%rbp
je     1934 <p3dPunThresholding_8+0x794>
movzbl (%r14,%rax,1),%ebx
xor    %ecx,%ecx
mov    $0x0,%edx
cmp    (%r15),%bl
jbe    19db <p3dPunThresholding_8+0x83b>
mov    0x2617(%rip),%rdx
mov    (%rdx),%edx
mov    %dl,(%rdi,%rax,1)
movzbl 0x1(%r14,%rax,1),%edx
cmp    (%r15),%dl
jbe    19b0 <p3dPunThresholding_8+0x810>
mov    0x2600(%rip),%rcx
mov    (%rcx),%ecx
jmp    19b0 <p3dPunThresholding_8+0x810>

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

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