#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 */
double abs(int);
double exp(double);
double sqrt(double);
void ComputeMrfProbability(double *mrf_probability, double *exponent,
                           unsigned char *label, int x, int y, int z, int *dims,
                           int n_classes, double beta,
                           double *voxelsize_squared) {
  int i, j, k;
  unsigned char label1, label2;
  double distance;
  int similarity_value;
  int same = -2;
  int similar = -1;
  int different = 1;
  for (label1 = 0; label1 < n_classes; label1++)
    exponent[label1] = 0;
  for (i = -1; i < 2; i++)
    for (j = -1; j < 2; j++)
      for (k = -1; k < 2; k++)
        if (i != 0 || j != 0 || k != 0) {
          label2 =
              label[(x + i) + dims[0] * (y + j) + dims[0] * dims[1] * (z + k)];
          for (label1 = 1; label1 < n_classes + 1; label1++) {
            if (label1 == label2)
              similarity_value = same;
            else if (abs(label1 - label2) < 2)
              similarity_value = similar;
            else
              similarity_value = different;
            distance = sqrt(voxelsize_squared[0] * abs(i) +
                            voxelsize_squared[1] * abs(j) +
                            voxelsize_squared[2] * abs(k));
            exponent[label1 - 1] += (double)similarity_value / distance;
          }
        }
  for (label1 = 0; label1 < n_classes; label1++)
    mrf_probability[label1] = exp(-(beta * exponent[label1]));
}


x86 assembly (clang, -O0):
<ComputeMrfProbability>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
movsd  %xmm0,-0x30(%rbp)
movl   $0xfffffffe,-0x50(%rbp)
movl   $0xffffffff,-0x54(%rbp)
movl   $0x1,-0x58(%rbp)
movb   $0x0,-0x3d(%rbp)
movzbl -0x3d(%rbp),%eax
cmp    0x18(%rbp),%eax
jge    11a5 <ComputeMrfProbability+0x75>
mov    -0x10(%rbp),%rax
movzbl -0x3d(%rbp),%ecx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3d(%rbp),%al
add    $0x1,%al
mov    %al,-0x3d(%rbp)
jmp    117b <ComputeMrfProbability+0x4b>
movl   $0xffffffff,-0x34(%rbp)
cmpl   $0x2,-0x34(%rbp)
jge    1393 <ComputeMrfProbability+0x263>
movl   $0xffffffff,-0x38(%rbp)
cmpl   $0x2,-0x38(%rbp)
jge    1380 <ComputeMrfProbability+0x250>
movl   $0xffffffff,-0x3c(%rbp)
cmpl   $0x2,-0x3c(%rbp)
jge    136d <ComputeMrfProbability+0x23d>
cmpl   $0x0,-0x34(%rbp)
jne    11f6 <ComputeMrfProbability+0xc6>
cmpl   $0x0,-0x38(%rbp)
jne    11f6 <ComputeMrfProbability+0xc6>
cmpl   $0x0,-0x3c(%rbp)
je     135a <ComputeMrfProbability+0x22a>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    -0x34(%rbp),%ecx
mov    0x10(%rbp),%rdx
mov    (%rdx),%edx
mov    -0x20(%rbp),%esi
add    -0x38(%rbp),%esi
imul   %esi,%edx
add    %edx,%ecx
mov    0x10(%rbp),%rdx
mov    (%rdx),%edx
mov    0x10(%rbp),%rsi
imul   0x4(%rsi),%edx
mov    -0x24(%rbp),%esi
add    -0x3c(%rbp),%esi
imul   %esi,%edx
add    %edx,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x3e(%rbp)
movb   $0x1,-0x3d(%rbp)
movzbl -0x3d(%rbp),%eax
mov    0x18(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1355 <ComputeMrfProbability+0x225>
movzbl -0x3d(%rbp),%eax
movzbl -0x3e(%rbp),%ecx
cmp    %ecx,%eax
jne    1264 <ComputeMrfProbability+0x134>
mov    -0x50(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    129e <ComputeMrfProbability+0x16e>
movzbl -0x3d(%rbp),%edi
movzbl -0x3e(%rbp),%eax
sub    %eax,%edi
call   1030 <abs@plt>
movaps %xmm0,%xmm1
movsd  0xd82(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1293 <ComputeMrfProbability+0x163>
mov    -0x54(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    1299 <ComputeMrfProbability+0x169>
mov    -0x58(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    129e <ComputeMrfProbability+0x16e>
mov    0x20(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x34(%rbp),%edi
call   1030 <abs@plt>
movsd  %xmm0,-0x78(%rbp)
mov    0x20(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x38(%rbp),%edi
call   1030 <abs@plt>
movsd  -0x80(%rbp),%xmm1
movsd  -0x78(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    0x20(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x3c(%rbp),%edi
call   1030 <abs@plt>
movsd  -0x68(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x48(%rbp)
cvtsi2sdl -0x4c(%rbp),%xmm0
divsd  -0x48(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movzbl -0x3d(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3d(%rbp),%al
add    $0x1,%al
mov    %al,-0x3d(%rbp)
jmp    1237 <ComputeMrfProbability+0x107>
jmp    135a <ComputeMrfProbability+0x22a>
jmp    135f <ComputeMrfProbability+0x22f>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11ce <ComputeMrfProbability+0x9e>
jmp    1372 <ComputeMrfProbability+0x242>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11bd <ComputeMrfProbability+0x8d>
jmp    1385 <ComputeMrfProbability+0x255>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11ac <ComputeMrfProbability+0x7c>
movb   $0x0,-0x3d(%rbp)
movzbl -0x3d(%rbp),%eax
cmp    0x18(%rbp),%eax
jge    13ec <ComputeMrfProbability+0x2bc>
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movzbl -0x3d(%rbp),%ecx
mulsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1040 <exp@plt>
mov    -0x8(%rbp),%rax
movzbl -0x3d(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3d(%rbp),%al
add    $0x1,%al
mov    %al,-0x3d(%rbp)
jmp    1397 <ComputeMrfProbability+0x267>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ComputeMrfProbability>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
movsd  %xmm0,0x50(%rsp)
mov    %r9,0x58(%rsp)
mov    %r8,0x70(%rsp)
mov    %rcx,0x68(%rsp)
mov    %rdx,0x38(%rsp)
mov    %rsi,%r14
mov    0xb8(%rsp),%edx
test   %edx,%edx
jle    1264 <ComputeMrfProbability+0x134>
cmp    $0x4,%edx
jae    1176 <ComputeMrfProbability+0x46>
xor    %eax,%eax
jmp    1250 <ComputeMrfProbability+0x120>
lea    -0x1(%rdx),%ecx
xor    %eax,%eax
cmp    $0xff,%cl
je     1250 <ComputeMrfProbability+0x120>
cmp    $0xff,%ecx
ja     1250 <ComputeMrfProbability+0x120>
mov    %edx,%eax
and    $0xfffffffc,%eax
lea    -0x4(%rax),%ebp
mov    %ebp,%esi
shr    $0x2,%esi
add    $0x1,%esi
mov    %esi,%ecx
and    $0x3,%ecx
xor    %edx,%edx
cmp    $0xc,%ebp
jb     120d <ComputeMrfProbability+0xdd>
and    $0xfffffffc,%esi
xor    %edx,%edx
xorpd  %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
nop
mov    %edx,%ebx
and    $0xf0,%ebx
movupd %xmm0,(%r14,%rbx,8)
movupd %xmm0,0x10(%r14,%rbx,8)
lea    0x4(%rbx),%ebp
movupd %xmm0,(%r14,%rbp,8)
movupd %xmm0,0x10(%r14,%rbp,8)
lea    0x8(%rbx),%ebp
movupd %xmm0,(%r14,%rbp,8)
movupd %xmm0,0x10(%r14,%rbp,8)
or     $0xc,%ebx
movupd %xmm0,(%r14,%rbx,8)
movupd %xmm0,0x10(%r14,%rbx,8)
add    $0x10,%edx
add    $0xfffffffc,%esi
jne    11c0 <ComputeMrfProbability+0x90>
test   %ecx,%ecx
je     123d <ComputeMrfProbability+0x10d>
xorpd  %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
nop
mov    %edx,%esi
and    $0xfc,%esi
movupd %xmm0,(%r14,%rsi,8)
movupd %xmm0,0x10(%r14,%rsi,8)
add    $0x4,%edx
add    $0xffffffff,%ecx
jne    1220 <ComputeMrfProbability+0xf0>
mov    0xb8(%rsp),%ebx
mov    %rbx,%rdx
cmp    %edx,%eax
je     1264 <ComputeMrfProbability+0x134>
nopl   0x0(%rax,%rax,1)
movzbl %al,%eax
movq   $0x0,(%r14,%rax,8)
add    $0x1,%al
movzbl %al,%ecx
cmp    %edx,%ecx
jl     1250 <ComputeMrfProbability+0x120>
mov    %rdi,0x60(%rsp)
mov    0xc0(%rsp),%r12
mov    0x58(%rsp),%rax
lea    -0x1(%rax),%ecx
mov    %ecx,0x4c(%rsp)
add    $0x1,%eax
mov    %eax,0x48(%rsp)
mov    $0xffffffff,%r15d
jmp    129e <ComputeMrfProbability+0x16e>
nopl   0x0(%rax)
add    $0x1,%r15d
cmp    $0x2,%r15d
je     16a3 <ComputeMrfProbability+0x573>
mov    0x68(%rsp),%rax
add    %r15d,%eax
mov    %eax,0x20(%rsp)
mov    $0xffffffff,%r13d
mov    %r15,0x40(%rsp)
jmp    12d4 <ComputeMrfProbability+0x1a4>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r13d
cmp    $0x2,%r13d
mov    0xb8(%rsp),%ebx
mov    %rbx,%rdx
je     1290 <ComputeMrfProbability+0x160>
mov    %r15d,%eax
or     %r13d,%eax
setne  0xf(%rsp)
mov    0x70(%rsp),%rax
add    %r13d,%eax
mov    %eax,0x24(%rsp)
test   %edx,%edx
mov    %rdx,%rbx
jle    1430 <ComputeMrfProbability+0x300>
mov    0xb0(%rsp),%rcx
mov    0x4(%rcx),%eax
imul   0x4c(%rsp),%eax
add    0x24(%rsp),%eax
imul   (%rcx),%eax
add    0x20(%rsp),%eax
cltq
mov    0x38(%rsp),%rcx
movzbl (%rcx,%rax,1),%ebp
mov    $0x1,%r15d
jmp    1364 <ComputeMrfProbability+0x234>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
call   1050 <sqrt@plt>
mov    %rbx,%rdx
movsd  0x30(%rsp),%xmm1
divsd  %xmm0,%xmm1
movslq %r15d,%rax
addsd  -0x8(%r14,%rax,8),%xmm1
movsd  %xmm1,-0x8(%r14,%rax,8)
add    $0x1,%r15d
movzbl %r15b,%r15d
cmp    %edx,%r15d
jg     1430 <ComputeMrfProbability+0x300>
movsd  0xc94(%rip),%xmm0
cmp    %r15b,%bpl
je     1398 <ComputeMrfProbability+0x268>
mov    %r15d,%edi
sub    %ebp,%edi
call   1030 <abs@plt>
xor    %eax,%eax
movsd  0xc83(%rip),%xmm1
ucomisd %xmm0,%xmm1
seta   %al
lea    0xc8d(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm0
movsd  %xmm0,0x30(%rsp)
movsd  (%r12),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    0x40(%rsp),%rdi
call   1030 <abs@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%r12),%xmm0
movsd  %xmm0,0x28(%rsp)
mov    %r13d,%edi
call   1030 <abs@plt>
mulsd  0x28(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0x10(%r12),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    $0xffffffff,%edi
call   1030 <abs@plt>
mulsd  0x10(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
ucomisd 0xbfa(%rip),%xmm0
jb     1330 <ComputeMrfProbability+0x200>
sqrtsd %xmm0,%xmm0
jmp    1335 <ComputeMrfProbability+0x205>
cs nopw 0x0(%rax,%rax,1)
nop
cmpb   $0x0,0xf(%rsp)
je     1570 <ComputeMrfProbability+0x440>
test   %edx,%edx
jle    1570 <ComputeMrfProbability+0x440>
mov    0xb0(%rsp),%rcx
mov    0x4(%rcx),%eax
imul   0x58(%rsp),%eax
add    0x24(%rsp),%eax
imul   (%rcx),%eax
add    0x20(%rsp),%eax
cltq
mov    0x38(%rsp),%rcx
movzbl (%rcx,%rax,1),%r15d
mov    $0x1,%ebp
jmp    14b2 <ComputeMrfProbability+0x382>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
call   1050 <sqrt@plt>
mov    %rbx,%rdx
movsd  0x30(%rsp),%xmm1
divsd  %xmm0,%xmm1
movslq %ebp,%rax
addsd  -0x8(%r14,%rax,8),%xmm1
movsd  %xmm1,-0x8(%r14,%rax,8)
add    $0x1,%ebp
movzbl %bpl,%ebp
cmp    %edx,%ebp
jg     1570 <ComputeMrfProbability+0x440>
movsd  0xb46(%rip),%xmm0
cmp    %bpl,%r15b
je     14e6 <ComputeMrfProbability+0x3b6>
mov    %ebp,%edi
sub    %r15d,%edi
call   1030 <abs@plt>
xor    %eax,%eax
movsd  0xb35(%rip),%xmm1
ucomisd %xmm0,%xmm1
seta   %al
lea    0xb3f(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm0
movsd  %xmm0,0x30(%rsp)
movsd  (%r12),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    0x40(%rsp),%rdi
call   1030 <abs@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%r12),%xmm0
movsd  %xmm0,0x28(%rsp)
mov    %r13d,%edi
call   1030 <abs@plt>
mulsd  0x28(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0x10(%r12),%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %edi,%edi
call   1030 <abs@plt>
mulsd  0x10(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
ucomisd 0xaaf(%rip),%xmm0
jb     1480 <ComputeMrfProbability+0x350>
sqrtsd %xmm0,%xmm0
jmp    1485 <ComputeMrfProbability+0x355>
test   %edx,%edx
mov    0x40(%rsp),%r15
jle    12c0 <ComputeMrfProbability+0x190>
mov    0xb0(%rsp),%rcx
mov    0x4(%rcx),%eax
imul   0x48(%rsp),%eax
mov    0x24(%rsp),%edx
add    %eax,%edx
imul   (%rcx),%edx
add    0x20(%rsp),%edx
movslq %edx,%rax
mov    0x38(%rsp),%rcx
movzbl (%rcx,%rax,1),%ebp
mov    $0x1,%ebx
jmp    15e5 <ComputeMrfProbability+0x4b5>
nopl   (%rax)
call   1050 <sqrt@plt>
movsd  0x30(%rsp),%xmm1
divsd  %xmm0,%xmm1
movslq %ebx,%rax
addsd  -0x8(%r14,%rax,8),%xmm1
movsd  %xmm1,-0x8(%r14,%rax,8)
add    $0x1,%ebx
movzbl %bl,%ebx
mov    0xb8(%rsp),%eax
cmp    %eax,%ebx
jg     12c0 <ComputeMrfProbability+0x190>
movsd  0xa13(%rip),%xmm0
cmp    %bl,%bpl
je     1618 <ComputeMrfProbability+0x4e8>
mov    %ebx,%edi
sub    %ebp,%edi
call   1030 <abs@plt>
xor    %eax,%eax
movsd  0xa03(%rip),%xmm1
ucomisd %xmm0,%xmm1
seta   %al
lea    0xa0d(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm0
movsd  %xmm0,0x30(%rsp)
movsd  (%r12),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %r15d,%edi
call   1030 <abs@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%r12),%xmm0
movsd  %xmm0,0x28(%rsp)
mov    %r13d,%edi
call   1030 <abs@plt>
mulsd  0x28(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0x10(%r12),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    $0x1,%edi
call   1030 <abs@plt>
mulsd  0x10(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
ucomisd 0x97c(%rip),%xmm0
jb     15b0 <ComputeMrfProbability+0x480>
sqrtsd %xmm0,%xmm0
jmp    15b5 <ComputeMrfProbability+0x485>
test   %edx,%edx
movsd  0x50(%rsp),%xmm1
mov    0x60(%rsp),%rbp
jle    16f1 <ComputeMrfProbability+0x5c1>
mov    %rdx,%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movzbl %bl,%ebx
movsd  (%r14,%rbx,8),%xmm0
xorpd  0x95f(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <exp@plt>
movsd  0x50(%rsp),%xmm1
movsd  %xmm0,0x0(%rbp,%rbx,8)
add    $0x1,%bl
movzbl %bl,%eax
cmp    %r15d,%eax
jl     16c0 <ComputeMrfProbability+0x590>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ComputeMrfProbability(double* %0, double* %1, i8* %2, i32 %3, i32 %4, i32 %5, i32* %6, i32 %7, double %8, double* %9) {
%11 = alloca double*
%12 = alloca double*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32*
%18 = alloca i32
%19 = alloca double
%20 = alloca double*
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i8
%25 = alloca i8
%26 = alloca double
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca i32
store double* %0, double** %11
store double* %1, double** %12
store i8* %2, i8** %13
store i32 %3, i32* %14
store i32 %4, i32* %15
store i32 %5, i32* %16
store i32* %6, i32** %17
store i32 %7, i32* %18
store double %8, double* %19
store double* %9, double** %20
store i32 -2, i32* %28
store i32 -1, i32* %29
store i32 1, i32* %30
store i8 0, i8* %24
br label %31
31: ; preds = %41, %10
%32 = load i8, i8* %24
%33 = zext i8 %32 to i32
%34 = load i32, i32* %18
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %44
36: ; preds = %31
%37 = load double*, double** %12
%38 = load i8, i8* %24
%39 = zext i8 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
store double 0.000000e+00, double* %40
br label %41
41: ; preds = %36
%42 = load i8, i8* %24
%43 = add i8 %42, 1
store i8 %43, i8* %24
br label %31
44: ; preds = %31
store i32 -1, i32* %21
br label %45
45: ; preds = %165, %44
%46 = load i32, i32* %21
%47 = icmp slt i32 %46, 2
br i1 %47, label %48, label %168
48: ; preds = %45
store i32 -1, i32* %22
br label %49
49: ; preds = %161, %48
%50 = load i32, i32* %22
%51 = icmp slt i32 %50, 2
br i1 %51, label %52, label %164
52: ; preds = %49
store i32 -1, i32* %23
br label %53
53: ; preds = %157, %52
%54 = load i32, i32* %23
%55 = icmp slt i32 %54, 2
br i1 %55, label %56, label %160
56: ; preds = %53
%57 = load i32, i32* %21
%58 = icmp ne i32 %57, 0
br i1 %58, label %65, label %59
59: ; preds = %56
%60 = load i32, i32* %22
%61 = icmp ne i32 %60, 0
br i1 %61, label %65, label %62
62: ; preds = %59
%63 = load i32, i32* %23
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %156
65: ; preds = %62, %59, %56
%66 = load i8*, i8** %13
%67 = load i32, i32* %14
%68 = load i32, i32* %21
%69 = add nsw i32 %67, %68
%70 = load i32*, i32** %17
%71 = getelementptr inbounds i32, i32* %70, i64 0
%72 = load i32, i32* %71
%73 = load i32, i32* %15
%74 = load i32, i32* %22
%75 = add nsw i32 %73, %74
%76 = mul nsw i32 %72, %75
%77 = add nsw i32 %69, %76
%78 = load i32*, i32** %17
%79 = getelementptr inbounds i32, i32* %78, i64 0
%80 = load i32, i32* %79
%81 = load i32*, i32** %17
%82 = getelementptr inbounds i32, i32* %81, i64 1
%83 = load i32, i32* %82
%84 = mul nsw i32 %80, %83
%85 = load i32, i32* %16
%86 = load i32, i32* %23
%87 = add nsw i32 %85, %86
%88 = mul nsw i32 %84, %87
%89 = add nsw i32 %77, %88
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8, i8* %66, i64 %90
%92 = load i8, i8* %91
store i8 %92, i8* %25
store i8 1, i8* %24
br label %93
93: ; preds = %152, %65
%94 = load i8, i8* %24
%95 = zext i8 %94 to i32
%96 = load i32, i32* %18
%97 = add nsw i32 %96, 1
%98 = icmp slt i32 %95, %97
br i1 %98, label %99, label %155
99: ; preds = %93
%100 = load i8, i8* %24
%101 = zext i8 %100 to i32
%102 = load i8, i8* %25
%103 = zext i8 %102 to i32
%104 = icmp eq i32 %101, %103
br i1 %104, label %105, label %107
105: ; preds = %99
%106 = load i32, i32* %28
store i32 %106, i32* %27
br label %120
107: ; preds = %99
%108 = load i8, i8* %24
%109 = zext i8 %108 to i32
%110 = load i8, i8* %25
%111 = zext i8 %110 to i32
%112 = sub nsw i32 %109, %111
%113 = call double @abs(i32 %112)
%114 = fcmp olt double %113, 2.000000e+00
br i1 %114, label %115, label %117
115: ; preds = %107
%116 = load i32, i32* %29
store i32 %116, i32* %27
br label %119
117: ; preds = %107
%118 = load i32, i32* %30
store i32 %118, i32* %27
br label %119
119: ; preds = %117, %115
br label %120
120: ; preds = %119, %105
%121 = load double*, double** %20
%122 = getelementptr inbounds double, double* %121, i64 0
%123 = load double, double* %122
%124 = load i32, i32* %21
%125 = call double @abs(i32 %124)
%126 = load double*, double** %20
%127 = getelementptr inbounds double, double* %126, i64 1
%128 = load double, double* %127
%129 = load i32, i32* %22
%130 = call double @abs(i32 %129)
%131 = fmul double %128, %130
%132 = call double @llvm.fmuladd.f64(double %123, double %125, double %131)
%133 = load double*, double** %20
%134 = getelementptr inbounds double, double* %133, i64 2
%135 = load double, double* %134
%136 = load i32, i32* %23
%137 = call double @abs(i32 %136)
%138 = call double @llvm.fmuladd.f64(double %135, double %137, double %132)
%139 = call double @sqrt(double %138)
store double %139, double* %26
%140 = load i32, i32* %27
%141 = sitofp i32 %140 to double
%142 = load double, double* %26
%143 = fdiv double %141, %142
%144 = load double*, double** %12
%145 = load i8, i8* %24
%146 = zext i8 %145 to i32
%147 = sub nsw i32 %146, 1
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds double, double* %144, i64 %148
%150 = load double, double* %149
%151 = fadd double %150, %143
store double %151, double* %149
br label %152
152: ; preds = %120
%153 = load i8, i8* %24
%154 = add i8 %153, 1
store i8 %154, i8* %24
br label %93
155: ; preds = %93
br label %156
156: ; preds = %155, %62
br label %157
157: ; preds = %156
%158 = load i32, i32* %23
%159 = add nsw i32 %158, 1
store i32 %159, i32* %23
br label %53
160: ; preds = %53
br label %161
161: ; preds = %160
%162 = load i32, i32* %22
%163 = add nsw i32 %162, 1
store i32 %163, i32* %22
br label %49
164: ; preds = %49
br label %165
165: ; preds = %164
%166 = load i32, i32* %21
%167 = add nsw i32 %166, 1
store i32 %167, i32* %21
br label %45
168: ; preds = %45
store i8 0, i8* %24
br label %169
169: ; preds = %188, %168
%170 = load i8, i8* %24
%171 = zext i8 %170 to i32
%172 = load i32, i32* %18
%173 = icmp slt i32 %171, %172
br i1 %173, label %174, label %191
174: ; preds = %169
%175 = load double, double* %19
%176 = load double*, double** %12
%177 = load i8, i8* %24
%178 = zext i8 %177 to i64
%179 = getelementptr inbounds double, double* %176, i64 %178
%180 = load double, double* %179
%181 = fmul double %175, %180
%182 = fneg double %181
%183 = call double @exp(double %182)
%184 = load double*, double** %11
%185 = load i8, i8* %24
%186 = zext i8 %185 to i64
%187 = getelementptr inbounds double, double* %184, i64 %186
store double %183, double* %187
br label %188
188: ; preds = %174
%189 = load i8, i8* %24
%190 = add i8 %189, 1
store i8 %190, i8* %24
br label %169
191: ; preds = %169
ret void
}

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