unsigned char *make_distance_map(unsigned char *img, unsigned int width,
                                 unsigned int height) {
  short *xdist = (short *)malloc(width * height * sizeof(short));
  short *ydist = (short *)malloc(width * height * sizeof(short));
  double *gx = (double *)calloc(width * height, sizeof(double));
  double *gy = (double *)calloc(width * height, sizeof(double));
  double *data = (double *)calloc(width * height, sizeof(double));
  double *outside = (double *)calloc(width * height, sizeof(double));
  double *inside = (double *)calloc(width * height, sizeof(double));
  int i;
  double img_min = 255, img_max = -255;
  for (i = 0; i < width * height; ++i) {
    double v = img[i];
    data[i] = v;
    if (v > img_max)
      img_max = v;
    if (v < img_min)
      img_min = v;
  }
  for (i = 0; i < width * height; ++i) {
    data[i] = (img[i] - img_min) / img_max;
  }
  computegradient(data, height, width, gx, gy);
  edtaa3(data, gx, gy, height, width, xdist, ydist, outside);
  for (i = 0; i < width * height; ++i)
    if (outside[i] < 0)
      outside[i] = 0.0;
  memset(gx, 0, sizeof(double) * width * height);
  memset(gy, 0, sizeof(double) * width * height);
  for (i = 0; i < width * height; ++i)
    data[i] = 1 - data[i];
  computegradient(data, height, width, gx, gy);
  edtaa3(data, gx, gy, height, width, xdist, ydist, inside);
  for (i = 0; i < width * height; ++i)
    if (inside[i] < 0)
      inside[i] = 0.0;
  unsigned char *out =
      (unsigned char *)malloc(width * height * sizeof(unsigned char));
  for (i = 0; i < width * height; ++i) {
    outside[i] -= inside[i];
    outside[i] = 128 + outside[i] * 16;
    if (outside[i] < 0)
      outside[i] = 0;
    if (outside[i] > 255)
      outside[i] = 255;
    out[i] = 255 - (unsigned char)outside[i];
  }
  free(xdist);
  free(ydist);
  free(gx);
  free(gy);
  free(data);
  free(outside);
  free(inside);
  return out;
}


x86 assembly (clang, -O0):
<make_distance_map>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,%eax
mov    %eax,%edi
shl    $0x1,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,%eax
mov    %eax,%edi
shl    $0x1,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,%eax
mov    %eax,%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,%eax
mov    %eax,%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,%eax
mov    %eax,%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,%eax
mov    %eax,%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,%eax
mov    %eax,%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,-0x48(%rbp)
movsd  0xdde(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xdc9(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0x10(%rbp),%ecx
cmp    %ecx,%eax
jae    12c7 <make_distance_map+0x167>
mov    -0x8(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x68(%rbp),%xmm0
ucomisd -0x60(%rbp),%xmm0
jbe    1296 <make_distance_map+0x136>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x68(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12b4 <make_distance_map+0x154>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    12b9 <make_distance_map+0x159>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1243 <make_distance_map+0xe3>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0x10(%rbp),%ecx
cmp    %ecx,%eax
jae    1315 <make_distance_map+0x1b5>
mov    -0x8(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cvtsi2sd %eax,%xmm0
subsd  -0x58(%rbp),%xmm0
divsd  -0x60(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    12ce <make_distance_map+0x16e>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    $0x0,%al
call   1030 <computegradient@plt>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%r8d
mov    -0x18(%rbp),%r9
mov    -0x20(%rbp),%r10
mov    -0x40(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1060 <edtaa3@plt>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0x10(%rbp),%ecx
cmp    %ecx,%eax
jae    13af <make_distance_map+0x24f>
mov    -0x40(%rbp),%rax
movslq -0x4c(%rbp),%rcx
xorps  %xmm0,%xmm0
ucomisd (%rax,%rcx,8),%xmm0
jbe    139c <make_distance_map+0x23c>
mov    -0x40(%rbp),%rax
movslq -0x4c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    13a1 <make_distance_map+0x241>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1364 <make_distance_map+0x204>
mov    -0x28(%rbp),%rdi
mov    -0xc(%rbp),%eax
mov    %eax,%edx
shl    $0x3,%rdx
mov    -0x10(%rbp),%eax
imul   %rax,%rdx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x30(%rbp),%rdi
mov    -0xc(%rbp),%eax
mov    %eax,%edx
shl    $0x3,%rdx
mov    -0x10(%rbp),%eax
imul   %rax,%rdx
xor    %esi,%esi
call   1050 <memset@plt>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0x10(%rbp),%ecx
cmp    %ecx,%eax
jae    142e <make_distance_map+0x2ce>
mov    -0x38(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  0xc12(%rip),%xmm0
subsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    13ec <make_distance_map+0x28c>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    $0x0,%al
call   1030 <computegradient@plt>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%r8d
mov    -0x18(%rbp),%r9
mov    -0x20(%rbp),%r10
mov    -0x48(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1060 <edtaa3@plt>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0x10(%rbp),%ecx
cmp    %ecx,%eax
jae    14c8 <make_distance_map+0x368>
mov    -0x48(%rbp),%rax
movslq -0x4c(%rbp),%rcx
xorps  %xmm0,%xmm0
ucomisd (%rax,%rcx,8),%xmm0
jbe    14b5 <make_distance_map+0x355>
mov    -0x48(%rbp),%rax
movslq -0x4c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    14ba <make_distance_map+0x35a>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    147d <make_distance_map+0x31d>
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,%eax
mov    %eax,%edi
shl    $0x0,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x70(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0x10(%rbp),%ecx
cmp    %ecx,%eax
jae    15da <make_distance_map+0x47a>
mov    -0x48(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x40(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xadf(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xadb(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x40(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40(%rbp),%rax
movslq -0x4c(%rbp),%rcx
xorps  %xmm0,%xmm0
ucomisd (%rax,%rcx,8),%xmm0
jbe    1574 <make_distance_map+0x414>
mov    -0x40(%rbp),%rax
movslq -0x4c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xa7f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    15a8 <make_distance_map+0x448>
mov    -0x40(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  0xa65(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40(%rbp),%rax
movslq -0x4c(%rbp),%rcx
cvttsd2si (%rax,%rcx,8),%eax
movzbl %al,%ecx
mov    $0xff,%eax
sub    %ecx,%eax
mov    %al,%dl
mov    -0x70(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    14e7 <make_distance_map+0x387>
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
mov    -0x48(%rbp),%rdi
call   1040 <free@plt>
mov    -0x70(%rbp),%rax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_distance_map>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %edx,%r13d
mov    %rdi,%r12
mov    %edx,%ebx
mov    %esi,0x14(%rsp)
imul   %esi,%ebx
lea    (%rbx,%rbx,1),%rbp
mov    %rbp,%rdi
call   1080 <malloc@plt>
mov    %rax,0x38(%rsp)
mov    %rbp,%rdi
call   1080 <malloc@plt>
mov    %rax,0x28(%rsp)
mov    $0x8,%esi
mov    %rbx,%rdi
call   1070 <calloc@plt>
mov    %rax,0x18(%rsp)
mov    $0x8,%esi
mov    %rbx,%rdi
call   1070 <calloc@plt>
mov    %rax,0x30(%rsp)
mov    $0x8,%esi
mov    %rbx,%rdi
call   1070 <calloc@plt>
mov    %rax,%rbp
mov    $0x8,%esi
mov    %rbx,%rdi
call   1070 <calloc@plt>
mov    %rax,%r14
mov    $0x8,%esi
mov    %rbx,%rdi
call   1070 <calloc@plt>
mov    %rax,%r15
mov    %rbx,0x8(%rsp)
test   %ebx,%ebx
mov    %r13d,0x24(%rsp)
je     12c2 <make_distance_map+0x162>
mov    0x8(%rsp),%rsi
add    $0xffffffffffffffff,%rsi
je     142d <make_distance_map+0x2cd>
mov    0x8(%rsp),%rcx
and    $0xfffffffe,%ecx
movsd  0xde0(%rip),%xmm1
movsd  0xde0(%rip),%xmm0
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
movzbl (%r12,%rax,1),%edx
xorps  %xmm2,%xmm2
cvtsi2sd %edx,%xmm2
movsd  %xmm2,0x0(%rbp,%rax,8)
movapd %xmm2,%xmm3
maxsd  %xmm1,%xmm3
minsd  %xmm0,%xmm2
movzbl 0x1(%r12,%rax,1),%edx
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
movsd  %xmm0,0x8(%rbp,%rax,8)
movapd %xmm0,%xmm1
maxsd  %xmm3,%xmm1
minsd  %xmm2,%xmm0
add    $0x2,%rax
cmp    %rax,%rcx
jne    1230 <make_distance_map+0xd0>
testb  $0x1,0x8(%rsp)
je     12a3 <make_distance_map+0x143>
movzbl (%r12,%rax,1),%ecx
xorps  %xmm2,%xmm2
cvtsi2sd %ecx,%xmm2
movsd  %xmm2,0x0(%rbp,%rax,8)
movapd %xmm2,%xmm3
maxsd  %xmm1,%xmm3
minsd  %xmm0,%xmm2
movapd %xmm3,%xmm1
movapd %xmm2,%xmm0
cmpq   $0x0,0x8(%rsp)
je     12c2 <make_distance_map+0x162>
cmpl   $0x1,0x8(%rsp)
mov    %rsi,0x40(%rsp)
jne    144f <make_distance_map+0x2ef>
xor    %eax,%eax
jmp    1520 <make_distance_map+0x3c0>
mov    %rbp,%rdi
mov    %r13d,%esi
mov    0x14(%rsp),%r13d
mov    %r13d,%edx
mov    0x18(%rsp),%r12
mov    %r12,%rcx
mov    0x30(%rsp),%rbx
mov    %rbx,%r8
xor    %eax,%eax
call   1030 <computegradient@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %rbx,%r12
mov    0x24(%rsp),%ebx
mov    %r12,%rdx
mov    %ebx,%ecx
mov    %r13d,%r8d
mov    0x38(%rsp),%r9
xor    %eax,%eax
push   %r14
push   0x30(%rsp)
call   1060 <edtaa3@plt>
add    $0x10,%rsp
mov    0x14(%rsp),%eax
mov    %ebx,%ebx
imul   %rax,%rbx
shl    $0x3,%rbx
mov    %r12,%r13
mov    0x18(%rsp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    %rbx,%rdx
call   1050 <memset@plt>
mov    %r13,%rdi
xor    %esi,%esi
mov    %rbx,%rdx
call   1050 <memset@plt>
mov    %r12,%rcx
mov    %rbp,%rdi
mov    0x24(%rsp),%ebx
mov    %ebx,%esi
mov    0x14(%rsp),%r12d
mov    %r12d,%edx
mov    0x30(%rsp),%r13
mov    %r13,%r8
xor    %eax,%eax
call   1030 <computegradient@plt>
mov    %rbp,%rdi
mov    0x18(%rsp),%rsi
mov    %r13,%rdx
mov    %ebx,%ecx
mov    %r12d,%r8d
mov    0x38(%rsp),%r12
mov    %r12,%r9
xor    %eax,%eax
push   %r15
push   0x30(%rsp)
call   1060 <edtaa3@plt>
add    $0x10,%rsp
cmpq   $0x0,0x8(%rsp)
je     179f <make_distance_map+0x63f>
cmpl   $0x1,0x8(%rsp)
jne    13e9 <make_distance_map+0x289>
xor    %eax,%eax
testb  $0x1,0x8(%rsp)
je     13be <make_distance_map+0x25e>
xorpd  %xmm0,%xmm0
ucomisd (%r15,%rax,8),%xmm0
jbe    13be <make_distance_map+0x25e>
movq   $0x0,(%r15,%rax,8)
mov    0x8(%rsp),%r13
mov    %r13,%rdi
call   1080 <malloc@plt>
mov    %rax,%rbx
test   %r13,%r13
je     17ac <make_distance_map+0x64c>
cmpl   $0x1,0x8(%rsp)
jne    1601 <make_distance_map+0x4a1>
xor    %eax,%eax
jmp    1688 <make_distance_map+0x528>
mov    0x8(%rsp),%rcx
and    $0xfffffffe,%ecx
xor    %eax,%eax
xorpd  %xmm0,%xmm0
jmp    1409 <make_distance_map+0x2a9>
nopl   0x0(%rax)
add    $0x2,%rax
cmp    %rax,%rcx
je     13a3 <make_distance_map+0x243>
ucomisd (%r15,%rax,8),%xmm0
jbe    1419 <make_distance_map+0x2b9>
movq   $0x0,(%r15,%rax,8)
ucomisd 0x8(%r15,%rax,8),%xmm0
jbe    1400 <make_distance_map+0x2a0>
movq   $0x0,0x8(%r15,%rax,8)
jmp    1400 <make_distance_map+0x2a0>
xor    %eax,%eax
movsd  0xbc9(%rip),%xmm1
movsd  0xbc9(%rip),%xmm0
testb  $0x1,0x8(%rsp)
jne    127d <make_distance_map+0x11d>
jmp    12a3 <make_distance_map+0x143>
mov    0x8(%rsp),%rax
and    $0xfffffffe,%eax
movapd %xmm0,%xmm2
unpcklpd %xmm0,%xmm2
movapd %xmm1,%xmm3
unpcklpd %xmm1,%xmm3
lea    -0x2(%rax),%rcx
mov    %rcx,%rdx
shr    %rdx
add    $0x1,%rdx
test   %rcx,%rcx
je     1900 <make_distance_map+0x7a0>
mov    %rdx,%rsi
and    $0xfffffffffffffffe,%rsi
xor    %ecx,%ecx
pxor   %xmm4,%xmm4
nopl   0x0(%rax,%rax,1)
movzwl (%r12,%rcx,1),%edi
movd   %edi,%xmm5
punpcklbw %xmm4,%xmm5
punpcklwd %xmm4,%xmm5
cvtdq2pd %xmm5,%xmm5
subpd  %xmm2,%xmm5
divpd  %xmm3,%xmm5
movupd %xmm5,0x0(%rbp,%rcx,8)
movzwl 0x2(%r12,%rcx,1),%edi
movd   %edi,%xmm5
punpcklbw %xmm4,%xmm5
punpcklwd %xmm4,%xmm5
cvtdq2pd %xmm5,%xmm5
subpd  %xmm2,%xmm5
divpd  %xmm3,%xmm5
movupd %xmm5,0x10(%rbp,%rcx,8)
add    $0x4,%rcx
add    $0xfffffffffffffffe,%rsi
jne    1490 <make_distance_map+0x330>
test   $0x1,%dl
je     150d <make_distance_map+0x3ad>
movzwl (%r12,%rcx,1),%edx
movd   %edx,%xmm4
xorpd  %xmm5,%xmm5
punpcklbw %xmm5,%xmm4
punpcklwd %xmm5,%xmm4
cvtdq2pd %xmm4,%xmm4
subpd  %xmm2,%xmm4
divpd  %xmm3,%xmm4
movupd %xmm4,0x0(%rbp,%rcx,8)
cmp    0x8(%rsp),%rax
je     1545 <make_distance_map+0x3e5>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%r12,%rax,1),%ecx
xorps  %xmm2,%xmm2
cvtsi2sd %ecx,%xmm2
subsd  %xmm0,%xmm2
divsd  %xmm1,%xmm2
movsd  %xmm2,0x0(%rbp,%rax,8)
add    $0x1,%rax
cmp    %rax,0x8(%rsp)
jne    1520 <make_distance_map+0x3c0>
mov    %rbp,%rdi
mov    %r13d,%esi
mov    %r13d,%ebx
mov    0x14(%rsp),%r13d
mov    %r13d,%edx
mov    0x18(%rsp),%rcx
mov    0x30(%rsp),%r12
mov    %r12,%r8
xor    %eax,%eax
call   1030 <computegradient@plt>
mov    %rbp,%rdi
mov    0x18(%rsp),%rsi
mov    %r12,%rdx
mov    %ebx,%ecx
mov    %r13d,%r8d
mov    0x38(%rsp),%r9
xor    %eax,%eax
push   %r14
push   0x30(%rsp)
call   1060 <edtaa3@plt>
add    $0x10,%rsp
cmpq   $0x0,0x8(%rsp)
je     1312 <make_distance_map+0x1b2>
cmpq   $0x0,0x40(%rsp)
je     16e3 <make_distance_map+0x583>
mov    0x8(%rsp),%rcx
and    $0xfffffffe,%ecx
xor    %eax,%eax
xorpd  %xmm0,%xmm0
mov    0x14(%rsp),%edx
mov    0x24(%rsp),%r13d
jmp    15dd <make_distance_map+0x47d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x2,%rax
cmp    %rax,%rcx
je     16ee <make_distance_map+0x58e>
ucomisd (%r14,%rax,8),%xmm0
jbe    15ed <make_distance_map+0x48d>
movq   $0x0,(%r14,%rax,8)
ucomisd 0x8(%r14,%rax,8),%xmm0
jbe    15d0 <make_distance_map+0x470>
movq   $0x0,0x8(%r14,%rax,8)
jmp    15d0 <make_distance_map+0x470>
mov    0x8(%rsp),%rax
and    $0xfffffffe,%eax
xor    %ecx,%ecx
movapd 0xa2d(%rip),%xmm0
movapd 0xa35(%rip),%xmm1
movapd 0xa3d(%rip),%xmm2
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movupd (%r15,%rcx,8),%xmm3
movupd (%r14,%rcx,8),%xmm4
subpd  %xmm3,%xmm4
mulpd  %xmm0,%xmm4
addpd  %xmm1,%xmm4
xorpd  %xmm3,%xmm3
maxpd  %xmm4,%xmm3
movapd %xmm2,%xmm4
minpd  %xmm3,%xmm4
cvttpd2dq %xmm4,%xmm3
movupd %xmm4,(%r14,%rcx,8)
packuswb %xmm3,%xmm3
packuswb %xmm3,%xmm3
movd   %xmm3,%edx
not    %edx
mov    %dx,(%rbx,%rcx,1)
add    $0x2,%rcx
cmp    %rcx,%rax
jne    1630 <make_distance_map+0x4d0>
cmp    0x8(%rsp),%rax
je     17ac <make_distance_map+0x64c>
movsd  0x988(%rip),%xmm0
movsd  0x988(%rip),%xmm1
movsd  0x968(%rip),%xmm2
movsd  (%r14,%rax,8),%xmm3
subsd  (%r15,%rax,8),%xmm3
mulsd  %xmm0,%xmm3
addsd  %xmm1,%xmm3
pxor   %xmm4,%xmm4
maxsd  %xmm3,%xmm4
movapd %xmm2,%xmm3
minsd  %xmm4,%xmm3
movsd  %xmm3,(%r14,%rax,8)
cvttsd2si %xmm3,%ecx
not    %cl
mov    %cl,(%rbx,%rax,1)
add    $0x1,%rax
cmp    %rax,0x8(%rsp)
jne    16a0 <make_distance_map+0x540>
jmp    17ac <make_distance_map+0x64c>
xor    %eax,%eax
mov    0x14(%rsp),%edx
mov    0x24(%rsp),%r13d
testb  $0x1,0x8(%rsp)
je     1709 <make_distance_map+0x5a9>
xorpd  %xmm0,%xmm0
ucomisd (%r14,%rax,8),%xmm0
jbe    1709 <make_distance_map+0x5a9>
movq   $0x0,(%r14,%rax,8)
mov    %edx,%eax
mov    %r13d,%ebx
imul   %rax,%rbx
shl    $0x3,%rbx
mov    0x18(%rsp),%rdi
xor    %esi,%esi
mov    %rbx,%rdx
call   1050 <memset@plt>
mov    0x30(%rsp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    %rbx,%rdx
call   1050 <memset@plt>
cmpq   $0x0,0x8(%rsp)
je     1756 <make_distance_map+0x5f6>
cmpl   $0x4,0x8(%rsp)
jae    17fc <make_distance_map+0x69c>
xor    %eax,%eax
mov    0x18(%rsp),%rcx
jmp    18d6 <make_distance_map+0x776>
mov    %rbp,%rdi
mov    %r13d,%esi
mov    0x14(%rsp),%edx
mov    0x18(%rsp),%rbx
mov    %rbx,%rcx
mov    %r12,%r8
xor    %eax,%eax
call   1030 <computegradient@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r13d,%ecx
mov    0x14(%rsp),%r8d
mov    0x38(%rsp),%rbx
mov    %rbx,%r9
xor    %eax,%eax
push   %r15
push   0x30(%rsp)
call   1060 <edtaa3@plt>
add    $0x10,%rsp
mov    %rbx,%r12
mov    0x8(%rsp),%rdi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    %r12,%rdi
call   1040 <free@plt>
mov    0x28(%rsp),%rdi
call   1040 <free@plt>
mov    0x18(%rsp),%rdi
call   1040 <free@plt>
mov    0x30(%rsp),%rdi
call   1040 <free@plt>
mov    %rbp,%rdi
call   1040 <free@plt>
mov    %r14,%rdi
call   1040 <free@plt>
mov    %r15,%rdi
call   1040 <free@plt>
mov    %rbx,%rax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsp),%rax
and    $0xfffffffc,%eax
lea    -0x4(%rax),%rcx
mov    %rcx,%rdx
shr    $0x2,%rdx
add    $0x1,%rdx
test   %rcx,%rcx
mov    0x18(%rsp),%rcx
je     1910 <make_distance_map+0x7b0>
mov    %rdx,%rsi
and    $0xfffffffffffffffe,%rsi
xor    %edi,%edi
movapd 0x7fe(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movupd 0x0(%rbp,%rdi,8),%xmm1
movupd 0x10(%rbp,%rdi,8),%xmm2
movupd 0x20(%rbp,%rdi,8),%xmm3
movupd 0x30(%rbp,%rdi,8),%xmm4
movapd %xmm0,%xmm5
subpd  %xmm1,%xmm5
movapd %xmm0,%xmm1
subpd  %xmm2,%xmm1
movupd %xmm5,0x0(%rbp,%rdi,8)
movupd %xmm1,0x10(%rbp,%rdi,8)
movapd %xmm0,%xmm1
subpd  %xmm3,%xmm1
movapd %xmm0,%xmm2
subpd  %xmm4,%xmm2
movupd %xmm1,0x20(%rbp,%rdi,8)
movupd %xmm2,0x30(%rbp,%rdi,8)
add    $0x8,%rdi
add    $0xfffffffffffffffe,%rsi
jne    1840 <make_distance_map+0x6e0>
test   $0x1,%dl
je     18cb <make_distance_map+0x76b>
movupd 0x0(%rbp,%rdi,8),%xmm0
movupd 0x10(%rbp,%rdi,8),%xmm1
movapd 0x77d(%rip),%xmm2
movapd %xmm2,%xmm3
subpd  %xmm0,%xmm3
subpd  %xmm1,%xmm2
movupd %xmm3,0x0(%rbp,%rdi,8)
movupd %xmm2,0x10(%rbp,%rdi,8)
cmp    0x8(%rsp),%rax
je     1345 <make_distance_map+0x1e5>
movsd  0x732(%rip),%xmm0
xchg   %ax,%ax
movapd %xmm0,%xmm1
subsd  0x0(%rbp,%rax,8),%xmm1
movsd  %xmm1,0x0(%rbp,%rax,8)
add    $0x1,%rax
cmp    %rax,0x8(%rsp)
jne    18e0 <make_distance_map+0x780>
jmp    1345 <make_distance_map+0x1e5>
xor    %ecx,%ecx
test   $0x1,%dl
jne    14e6 <make_distance_map+0x386>
jmp    150d <make_distance_map+0x3ad>
xor    %edi,%edi
test   $0x1,%dl
jne    189f <make_distance_map+0x73f>
jmp    18cb <make_distance_map+0x76b>

LLVM IR (-O0):
define i8* @make_distance_map(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i16*
%8 = alloca i16*
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca i32
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = mul i32 %19, %20
%22 = zext i32 %21 to i64
%23 = mul i64 %22, 2
%24 = call i8* @malloc(i64 %23)
%25 = bitcast i8* %24 to i16*
store i16* %25, i16** %7
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = mul i32 %26, %27
%29 = zext i32 %28 to i64
%30 = mul i64 %29, 2
%31 = call i8* @malloc(i64 %30)
%32 = bitcast i8* %31 to i16*
store i16* %32, i16** %8
%33 = load i32, i32* %5
%34 = load i32, i32* %6
%35 = mul i32 %33, %34
%36 = zext i32 %35 to i64
%37 = call i8* @calloc(i64 %36, i64 8)
%38 = bitcast i8* %37 to double*
store double* %38, double** %9
%39 = load i32, i32* %5
%40 = load i32, i32* %6
%41 = mul i32 %39, %40
%42 = zext i32 %41 to i64
%43 = call i8* @calloc(i64 %42, i64 8)
%44 = bitcast i8* %43 to double*
store double* %44, double** %10
%45 = load i32, i32* %5
%46 = load i32, i32* %6
%47 = mul i32 %45, %46
%48 = zext i32 %47 to i64
%49 = call i8* @calloc(i64 %48, i64 8)
%50 = bitcast i8* %49 to double*
store double* %50, double** %11
%51 = load i32, i32* %5
%52 = load i32, i32* %6
%53 = mul i32 %51, %52
%54 = zext i32 %53 to i64
%55 = call i8* @calloc(i64 %54, i64 8)
%56 = bitcast i8* %55 to double*
store double* %56, double** %12
%57 = load i32, i32* %5
%58 = load i32, i32* %6
%59 = mul i32 %57, %58
%60 = zext i32 %59 to i64
%61 = call i8* @calloc(i64 %60, i64 8)
%62 = bitcast i8* %61 to double*
store double* %62, double** %13
store double 2.550000e+02, double* %15
store double -2.550000e+02, double* %16
store i32 0, i32* %14
br label %63
63: ; preds = %93, %3
%64 = load i32, i32* %14
%65 = load i32, i32* %5
%66 = load i32, i32* %6
%67 = mul i32 %65, %66
%68 = icmp ult i32 %64, %67
br i1 %68, label %69, label %96
69: ; preds = %63
%70 = load i8*, i8** %4
%71 = load i32, i32* %14
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8, i8* %70, i64 %72
%74 = load i8, i8* %73
%75 = uitofp i8 %74 to double
store double %75, double* %17
%76 = load double, double* %17
%77 = load double*, double** %11
%78 = load i32, i32* %14
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds double, double* %77, i64 %79
store double %76, double* %80
%81 = load double, double* %17
%82 = load double, double* %16
%83 = fcmp ogt double %81, %82
br i1 %83, label %84, label %86
84: ; preds = %69
%85 = load double, double* %17
store double %85, double* %16
br label %86
86: ; preds = %84, %69
%87 = load double, double* %17
%88 = load double, double* %15
%89 = fcmp olt double %87, %88
br i1 %89, label %90, label %92
90: ; preds = %86
%91 = load double, double* %17
store double %91, double* %15
br label %92
92: ; preds = %90, %86
br label %93
93: ; preds = %92
%94 = load i32, i32* %14
%95 = add nsw i32 %94, 1
store i32 %95, i32* %14
br label %63
96: ; preds = %63
store i32 0, i32* %14
br label %97
97: ; preds = %119, %96
%98 = load i32, i32* %14
%99 = load i32, i32* %5
%100 = load i32, i32* %6
%101 = mul i32 %99, %100
%102 = icmp ult i32 %98, %101
br i1 %102, label %103, label %122
103: ; preds = %97
%104 = load i8*, i8** %4
%105 = load i32, i32* %14
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds i8, i8* %104, i64 %106
%108 = load i8, i8* %107
%109 = zext i8 %108 to i32
%110 = sitofp i32 %109 to double
%111 = load double, double* %15
%112 = fsub double %110, %111
%113 = load double, double* %16
%114 = fdiv double %112, %113
%115 = load double*, double** %11
%116 = load i32, i32* %14
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds double, double* %115, i64 %117
store double %114, double* %118
br label %119
119: ; preds = %103
%120 = load i32, i32* %14
%121 = add nsw i32 %120, 1
store i32 %121, i32* %14
br label %97
122: ; preds = %97
%123 = load double*, double** %11
%124 = load i32, i32* %6
%125 = load i32, i32* %5
%126 = load double*, double** %9
%127 = load double*, double** %10
%128 = call i32 (double*, i32, i32, double*, double*, ...) bitcast (i32 (...)* @computegradient to i32 (double*, i32, i32, double*, double*, ...)*)(double* %123, i32 %124, i32 %125, double* %126, double* %127)
%129 = load double*, double** %11
%130 = load double*, double** %9
%131 = load double*, double** %10
%132 = load i32, i32* %6
%133 = load i32, i32* %5
%134 = load i16*, i16** %7
%135 = load i16*, i16** %8
%136 = load double*, double** %12
%137 = call i32 (double*, double*, double*, i32, i32, i16*, i16*, double*, ...) bitcast (i32 (...)* @edtaa3 to i32 (double*, double*, double*, i32, i32, i16*, i16*, double*, ...)*)(double* %129, double* %130, double* %131, i32 %132, i32 %133, i16* %134, i16* %135, double* %136)
store i32 0, i32* %14
br label %138
138: ; preds = %157, %122
%139 = load i32, i32* %14
%140 = load i32, i32* %5
%141 = load i32, i32* %6
%142 = mul i32 %140, %141
%143 = icmp ult i32 %139, %142
br i1 %143, label %144, label %160
144: ; preds = %138
%145 = load double*, double** %12
%146 = load i32, i32* %14
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds double, double* %145, i64 %147
%149 = load double, double* %148
%150 = fcmp olt double %149, 0.000000e+00
br i1 %150, label %151, label %156
151: ; preds = %144
%152 = load double*, double** %12
%153 = load i32, i32* %14
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds double, double* %152, i64 %154
store double 0.000000e+00, double* %155
br label %156
156: ; preds = %151, %144
br label %157
157: ; preds = %156
%158 = load i32, i32* %14
%159 = add nsw i32 %158, 1
store i32 %159, i32* %14
br label %138
160: ; preds = %138
%161 = load double*, double** %9
%162 = bitcast double* %161 to i8*
%163 = load i32, i32* %5
%164 = zext i32 %163 to i64
%165 = mul i64 8, %164
%166 = load i32, i32* %6
%167 = zext i32 %166 to i64
%168 = mul i64 %165, %167
%169 = load double*, double** %10
%170 = bitcast double* %169 to i8*
%171 = load i32, i32* %5
%172 = zext i32 %171 to i64
%173 = mul i64 8, %172
%174 = load i32, i32* %6
%175 = zext i32 %174 to i64
%176 = mul i64 %173, %175
store i32 0, i32* %14
br label %177
177: ; preds = %194, %160
%178 = load i32, i32* %14
%179 = load i32, i32* %5
%180 = load i32, i32* %6
%181 = mul i32 %179, %180
%182 = icmp ult i32 %178, %181
br i1 %182, label %183, label %197
183: ; preds = %177
%184 = load double*, double** %11
%185 = load i32, i32* %14
%186 = sext i32 %185 to i64
%187 = getelementptr inbounds double, double* %184, i64 %186
%188 = load double, double* %187
%189 = fsub double 1.000000e+00, %188
%190 = load double*, double** %11
%191 = load i32, i32* %14
%192 = sext i32 %191 to i64
%193 = getelementptr inbounds double, double* %190, i64 %192
store double %189, double* %193
br label %194
194: ; preds = %183
%195 = load i32, i32* %14
%196 = add nsw i32 %195, 1
store i32 %196, i32* %14
br label %177
197: ; preds = %177
%198 = load double*, double** %11
%199 = load i32, i32* %6
%200 = load i32, i32* %5
%201 = load double*, double** %9
%202 = load double*, double** %10
%203 = call i32 (double*, i32, i32, double*, double*, ...) bitcast (i32 (...)* @computegradient to i32 (double*, i32, i32, double*, double*, ...)*)(double* %198, i32 %199, i32 %200, double* %201, double* %202)
%204 = load double*, double** %11
%205 = load double*, double** %9
%206 = load double*, double** %10
%207 = load i32, i32* %6
%208 = load i32, i32* %5
%209 = load i16*, i16** %7
%210 = load i16*, i16** %8
%211 = load double*, double** %13
%212 = call i32 (double*, double*, double*, i32, i32, i16*, i16*, double*, ...) bitcast (i32 (...)* @edtaa3 to i32 (double*, double*, double*, i32, i32, i16*, i16*, double*, ...)*)(double* %204, double* %205, double* %206, i32 %207, i32 %208, i16* %209, i16* %210, double* %211)
store i32 0, i32* %14
br label %213
213: ; preds = %232, %197
%214 = load i32, i32* %14
%215 = load i32, i32* %5
%216 = load i32, i32* %6
%217 = mul i32 %215, %216
%218 = icmp ult i32 %214, %217
br i1 %218, label %219, label %235
219: ; preds = %213
%220 = load double*, double** %13
%221 = load i32, i32* %14
%222 = sext i32 %221 to i64
%223 = getelementptr inbounds double, double* %220, i64 %222
%224 = load double, double* %223
%225 = fcmp olt double %224, 0.000000e+00
br i1 %225, label %226, label %231
226: ; preds = %219
%227 = load double*, double** %13
%228 = load i32, i32* %14
%229 = sext i32 %228 to i64
%230 = getelementptr inbounds double, double* %227, i64 %229
store double 0.000000e+00, double* %230
br label %231
231: ; preds = %226, %219
br label %232
232: ; preds = %231
%233 = load i32, i32* %14
%234 = add nsw i32 %233, 1
store i32 %234, i32* %14
br label %213
235: ; preds = %213
%236 = load i32, i32* %5
%237 = load i32, i32* %6
%238 = mul i32 %236, %237
%239 = zext i32 %238 to i64
%240 = mul i64 %239, 1
%241 = call i8* @malloc(i64 %240)
store i8* %241, i8** %18
store i32 0, i32* %14
br label %242
242: ; preds = %307, %235
%243 = load i32, i32* %14
%244 = load i32, i32* %5
%245 = load i32, i32* %6
%246 = mul i32 %244, %245
%247 = icmp ult i32 %243, %246
br i1 %247, label %248, label %310
248: ; preds = %242
%249 = load double*, double** %13
%250 = load i32, i32* %14
%251 = sext i32 %250 to i64
%252 = getelementptr inbounds double, double* %249, i64 %251
%253 = load double, double* %252
%254 = load double*, double** %12
%255 = load i32, i32* %14
%256 = sext i32 %255 to i64
%257 = getelementptr inbounds double, double* %254, i64 %256
%258 = load double, double* %257
%259 = fsub double %258, %253
store double %259, double* %257
%260 = load double*, double** %12
%261 = load i32, i32* %14
%262 = sext i32 %261 to i64
%263 = getelementptr inbounds double, double* %260, i64 %262
%264 = load double, double* %263
%265 = call double @llvm.fmuladd.f64(double %264, double 1.600000e+01, double 1.280000e+02)
%266 = load double*, double** %12
%267 = load i32, i32* %14
%268 = sext i32 %267 to i64
%269 = getelementptr inbounds double, double* %266, i64 %268
store double %265, double* %269
%270 = load double*, double** %12
%271 = load i32, i32* %14
%272 = sext i32 %271 to i64
%273 = getelementptr inbounds double, double* %270, i64 %272
%274 = load double, double* %273
%275 = fcmp olt double %274, 0.000000e+00
br i1 %275, label %276, label %281
276: ; preds = %248
%277 = load double*, double** %12
%278 = load i32, i32* %14
%279 = sext i32 %278 to i64
%280 = getelementptr inbounds double, double* %277, i64 %279
store double 0.000000e+00, double* %280
br label %281
281: ; preds = %276, %248
%282 = load double*, double** %12
%283 = load i32, i32* %14
%284 = sext i32 %283 to i64
%285 = getelementptr inbounds double, double* %282, i64 %284
%286 = load double, double* %285
%287 = fcmp ogt double %286, 2.550000e+02
br i1 %287, label %288, label %293
288: ; preds = %281
%289 = load double*, double** %12
%290 = load i32, i32* %14
%291 = sext i32 %290 to i64
%292 = getelementptr inbounds double, double* %289, i64 %291
store double 2.550000e+02, double* %292
br label %293
293: ; preds = %288, %281
%294 = load double*, double** %12
%295 = load i32, i32* %14
%296 = sext i32 %295 to i64
%297 = getelementptr inbounds double, double* %294, i64 %296
%298 = load double, double* %297
%299 = fptoui double %298 to i8
%300 = zext i8 %299 to i32
%301 = sub nsw i32 255, %300
%302 = trunc i32 %301 to i8
%303 = load i8*, i8** %18
%304 = load i32, i32* %14
%305 = sext i32 %304 to i64
%306 = getelementptr inbounds i8, i8* %303, i64 %305
store i8 %302, i8* %306
br label %307
307: ; preds = %293
%308 = load i32, i32* %14
%309 = add nsw i32 %308, 1
store i32 %309, i32* %14
br label %242
310: ; preds = %242
%311 = load i16*, i16** %7
%312 = bitcast i16* %311 to i8*
%313 = load i16*, i16** %8
%314 = bitcast i16* %313 to i8*
%315 = load double*, double** %9
%316 = bitcast double* %315 to i8*
%317 = load double*, double** %10
%318 = bitcast double* %317 to i8*
%319 = load double*, double** %11
%320 = bitcast double* %319 to i8*
%321 = load double*, double** %12
%322 = bitcast double* %321 to i8*
%323 = load double*, double** %13
%324 = bitcast double* %323 to i8*
%325 = load i8*, i8** %18
ret i8* %325
}

LLVM IR (-O2):
define i8* @make_distance_map(i8* nocapture %0, i32 %1, i32 %2) {
%4 = mul i32 %2, %1
%5 = zext i32 %4 to i64
%6 = shl nuw nsw i64 %5, 1
%7 = tail call i8* @malloc(i64 %6)
%8 = bitcast i8* %7 to i16*
%9 = tail call i8* @malloc(i64 %6)
%10 = bitcast i8* %9 to i16*
%11 = tail call i8* @calloc(i64 %5, i64 8)
%12 = bitcast i8* %11 to double*
%13 = tail call i8* @calloc(i64 %5, i64 8)
%14 = bitcast i8* %13 to double*
%15 = tail call i8* @calloc(i64 %5, i64 8)
%16 = bitcast i8* %15 to double*
%17 = tail call i8* @calloc(i64 %5, i64 8)
%18 = bitcast i8* %17 to double*
%19 = tail call i8* @calloc(i64 %5, i64 8)
%20 = bitcast i8* %19 to double*
%21 = icmp eq i32 %4, 0
br i1 %21, label %144, label %22
22: ; preds = %3
%23 = add nsw i64 %5, -1
%24 = and i64 %5, 1
%25 = icmp eq i64 %23, 0
br i1 %25, label %28, label %26
26: ; preds = %22
%27 = and i64 %5, 4294967294
br label %101
28: ; preds = %101, %22
%29 = phi double [ undef, %22 ], [ %120, %101 ]
%30 = phi double [ undef, %22 ], [ %122, %101 ]
%31 = phi i64 [ 0, %22 ], [ %123, %101 ]
%32 = phi double [ 2.550000e+02, %22 ], [ %122, %101 ]
%33 = phi double [ -2.550000e+02, %22 ], [ %120, %101 ]
%34 = icmp eq i64 %24, 0
br i1 %34, label %44, label %35
35: ; preds = %28
%36 = getelementptr inbounds i8, i8* %0, i64 %31
%37 = load i8, i8* %36
%38 = uitofp i8 %37 to double
%39 = getelementptr inbounds double, double* %16, i64 %31
store double %38, double* %39
%40 = fcmp olt double %33, %38
%41 = select i1 %40, double %38, double %33
%42 = fcmp ogt double %32, %38
%43 = select i1 %42, double %38, double %32
br label %44
44: ; preds = %28, %35
%45 = phi double [ %29, %28 ], [ %41, %35 ]
%46 = phi double [ %30, %28 ], [ %43, %35 ]
br i1 %21, label %144, label %47
47: ; preds = %44
%48 = icmp eq i32 %4, 1
br i1 %48, label %99, label %49
49: ; preds = %47
%50 = and i64 %5, 4294967294
%51 = insertelement <2 x double> poison, double %46, i64 0
%52 = shufflevector <2 x double> %51, <2 x double> poison, <2 x i32> zeroinitializer
%53 = insertelement <2 x double> poison, double %45, i64 0
%54 = shufflevector <2 x double> %53, <2 x double> poison, <2 x i32> zeroinitializer
%55 = add nsw i64 %50, -2
%56 = lshr exact i64 %55, 1
%57 = add nuw i64 %56, 1
%58 = and i64 %57, 1
%59 = icmp eq i64 %55, 0
br i1 %59, label %85, label %60
60: ; preds = %49
%61 = and i64 %57, -2
br label %62
62: ; preds = %62, %60
%63 = phi i64 [ 0, %60 ], [ %82, %62 ]
%64 = phi i64 [ 0, %60 ], [ %83, %62 ]
%65 = getelementptr inbounds i8, i8* %0, i64 %63
%66 = bitcast i8* %65 to <2 x i8>*
%67 = load <2 x i8>, <2 x i8>* %66
%68 = uitofp <2 x i8> %67 to <2 x double>
%69 = fsub <2 x double> %68, %52
%70 = fdiv <2 x double> %69, %54
%71 = getelementptr inbounds double, double* %16, i64 %63
%72 = bitcast double* %71 to <2 x double>*
store <2 x double> %70, <2 x double>* %72
%73 = or i64 %63, 2
%74 = getelementptr inbounds i8, i8* %0, i64 %73
%75 = bitcast i8* %74 to <2 x i8>*
%76 = load <2 x i8>, <2 x i8>* %75
%77 = uitofp <2 x i8> %76 to <2 x double>
%78 = fsub <2 x double> %77, %52
%79 = fdiv <2 x double> %78, %54
%80 = getelementptr inbounds double, double* %16, i64 %73
%81 = bitcast double* %80 to <2 x double>*
store <2 x double> %79, <2 x double>* %81
%82 = add nuw i64 %63, 4
%83 = add nuw i64 %64, 2
%84 = icmp eq i64 %83, %61
br i1 %84, label %85, label %62
85: ; preds = %62, %49
%86 = phi i64 [ 0, %49 ], [ %82, %62 ]
%87 = icmp eq i64 %58, 0
br i1 %87, label %97, label %88
88: ; preds = %85
%89 = getelementptr inbounds i8, i8* %0, i64 %86
%90 = bitcast i8* %89 to <2 x i8>*
%91 = load <2 x i8>, <2 x i8>* %90
%92 = uitofp <2 x i8> %91 to <2 x double>
%93 = fsub <2 x double> %92, %52
%94 = fdiv <2 x double> %93, %54
%95 = getelementptr inbounds double, double* %16, i64 %86
%96 = bitcast double* %95 to <2 x double>*
store <2 x double> %94, <2 x double>* %96
br label %97
97: ; preds = %85, %88
%98 = icmp eq i64 %50, %5
br i1 %98, label %136, label %99
99: ; preds = %47, %97
%100 = phi i64 [ 0, %47 ], [ %50, %97 ]
br label %126
101: ; preds = %101, %26
%102 = phi i64 [ 0, %26 ], [ %123, %101 ]
%103 = phi double [ 2.550000e+02, %26 ], [ %122, %101 ]
%104 = phi double [ -2.550000e+02, %26 ], [ %120, %101 ]
%105 = phi i64 [ 0, %26 ], [ %124, %101 ]
%106 = getelementptr inbounds i8, i8* %0, i64 %102
%107 = load i8, i8* %106
%108 = uitofp i8 %107 to double
%109 = getelementptr inbounds double, double* %16, i64 %102
store double %108, double* %109
%110 = fcmp olt double %104, %108
%111 = select i1 %110, double %108, double %104
%112 = fcmp ogt double %103, %108
%113 = select i1 %112, double %108, double %103
%114 = or i64 %102, 1
%115 = getelementptr inbounds i8, i8* %0, i64 %114
%116 = load i8, i8* %115
%117 = uitofp i8 %116 to double
%118 = getelementptr inbounds double, double* %16, i64 %114
store double %117, double* %118
%119 = fcmp olt double %111, %117
%120 = select i1 %119, double %117, double %111
%121 = fcmp ogt double %113, %117
%122 = select i1 %121, double %117, double %113
%123 = add nuw nsw i64 %102, 2
%124 = add i64 %105, 2
%125 = icmp eq i64 %124, %27
br i1 %125, label %28, label %101
126: ; preds = %99, %126
%127 = phi i64 [ %134, %126 ], [ %100, %99 ]
%128 = getelementptr inbounds i8, i8* %0, i64 %127
%129 = load i8, i8* %128
%130 = uitofp i8 %129 to double
%131 = fsub double %130, %46
%132 = fdiv double %131, %45
%133 = getelementptr inbounds double, double* %16, i64 %127
store double %132, double* %133
%134 = add nuw nsw i64 %127, 1
%135 = icmp eq i64 %134, %5
br i1 %135, label %136, label %126
136: ; preds = %126, %97
%137 = tail call i32 (double*, i32, i32, double*, double*, ...) bitcast (i32 (...)* @computegradient to i32 (double*, i32, i32, double*, double*, ...)*)(double* %16, i32 %2, i32 %1, double* %12, double* %14)
%138 = tail call i32 (double*, double*, double*, i32, i32, i16*, i16*, double*, ...) bitcast (i32 (...)* @edtaa3 to i32 (double*, double*, double*, i32, i32, i16*, i16*, double*, ...)*)(double* %16, double* %12, double* %14, i32 %2, i32 %1, i16* %8, i16* %10, double* %18)
br i1 %21, label %147, label %139
139: ; preds = %136
%140 = and i64 %5, 1
%141 = icmp eq i64 %23, 0
br i1 %141, label %169, label %142
142: ; preds = %139
%143 = and i64 %5, 4294967294
br label %152
144: ; preds = %44, %3
%145 = tail call i32 (double*, i32, i32, double*, double*, ...) bitcast (i32 (...)* @computegradient to i32 (double*, i32, i32, double*, double*, ...)*)(double* %16, i32 %2, i32 %1, double* %12, double* %14)
%146 = tail call i32 (double*, double*, double*, i32, i32, i16*, i16*, double*, ...) bitcast (i32 (...)* @edtaa3 to i32 (double*, double*, double*, i32, i32, i16*, i16*, double*, ...)*)(double* %16, double* %12, double* %14, i32 %2, i32 %1, i16* %8, i16* %10, double* %18)
br label %147
147: ; preds = %144, %136
%148 = zext i32 %1 to i64
%149 = shl nuw nsw i64 %148, 3
%150 = zext i32 %2 to i64
%151 = mul i64 %149, %150
tail call void @llvm.memset.p0i8.i64(i8* align 8 %11, i8 0, i64 %151, i1 false)
tail call void @llvm.memset.p0i8.i64(i8* align 8 %13, i8 0, i64 %151, i1 false)
br label %245
152: ; preds = %165, %142
%153 = phi i64 [ 0, %142 ], [ %166, %165 ]
%154 = phi i64 [ 0, %142 ], [ %167, %165 ]
%155 = getelementptr inbounds double, double* %18, i64 %153
%156 = load double, double* %155
%157 = fcmp olt double %156, 0.000000e+00
br i1 %157, label %158, label %159
158: ; preds = %152
store double 0.000000e+00, double* %155
br label %159
159: ; preds = %152, %158
%160 = or i64 %153, 1
%161 = getelementptr inbounds double, double* %18, i64 %160
%162 = load double, double* %161
%163 = fcmp olt double %162, 0.000000e+00
br i1 %163, label %164, label %165
164: ; preds = %159
store double 0.000000e+00, double* %161
br label %165
165: ; preds = %164, %159
%166 = add nuw nsw i64 %153, 2
%167 = add i64 %154, 2
%168 = icmp eq i64 %167, %143
br i1 %168, label %169, label %152
169: ; preds = %165, %139
%170 = phi i64 [ 0, %139 ], [ %166, %165 ]
%171 = icmp eq i64 %140, 0
br i1 %171, label %177, label %172
172: ; preds = %169
%173 = getelementptr inbounds double, double* %18, i64 %170
%174 = load double, double* %173
%175 = fcmp olt double %174, 0.000000e+00
br i1 %175, label %176, label %177
176: ; preds = %172
store double 0.000000e+00, double* %173
br label %177
177: ; preds = %172, %176, %169
%178 = zext i32 %1 to i64
%179 = shl nuw nsw i64 %178, 3
%180 = zext i32 %2 to i64
%181 = mul i64 %179, %180
tail call void @llvm.memset.p0i8.i64(i8* align 8 %11, i8 0, i64 %181, i1 false)
tail call void @llvm.memset.p0i8.i64(i8* align 8 %13, i8 0, i64 %181, i1 false)
br i1 %21, label %253, label %182
182: ; preds = %177
%183 = icmp ult i32 %4, 4
br i1 %183, label %236, label %184
184: ; preds = %182
%185 = and i64 %5, 4294967292
%186 = add nsw i64 %185, -4
%187 = lshr exact i64 %186, 2
%188 = add nuw nsw i64 %187, 1
%189 = and i64 %188, 1
%190 = icmp eq i64 %186, 0
br i1 %190, label %220, label %191
191: ; preds = %184
%192 = and i64 %188, 9223372036854775806
br label %193
193: ; preds = %193, %191
%194 = phi i64 [ 0, %191 ], [ %217, %193 ]
%195 = phi i64 [ 0, %191 ], [ %218, %193 ]
%196 = getelementptr inbounds double, double* %16, i64 %194
%197 = bitcast double* %196 to <2 x double>*
%198 = load <2 x double>, <2 x double>* %197
%199 = getelementptr inbounds double, double* %196, i64 2
%200 = bitcast double* %199 to <2 x double>*
%201 = load <2 x double>, <2 x double>* %200
%202 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %198
%203 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %201
%204 = bitcast double* %196 to <2 x double>*
store <2 x double> %202, <2 x double>* %204
%205 = bitcast double* %199 to <2 x double>*
store <2 x double> %203, <2 x double>* %205
%206 = or i64 %194, 4
%207 = getelementptr inbounds double, double* %16, i64 %206
%208 = bitcast double* %207 to <2 x double>*
%209 = load <2 x double>, <2 x double>* %208
%210 = getelementptr inbounds double, double* %207, i64 2
%211 = bitcast double* %210 to <2 x double>*
%212 = load <2 x double>, <2 x double>* %211
%213 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %209
%214 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %212
%215 = bitcast double* %207 to <2 x double>*
store <2 x double> %213, <2 x double>* %215
%216 = bitcast double* %210 to <2 x double>*
store <2 x double> %214, <2 x double>* %216
%217 = add nuw i64 %194, 8
%218 = add i64 %195, 2
%219 = icmp eq i64 %218, %192
br i1 %219, label %220, label %193
220: ; preds = %193, %184
%221 = phi i64 [ 0, %184 ], [ %217, %193 ]
%222 = icmp eq i64 %189, 0
br i1 %222, label %234, label %223
223: ; preds = %220
%224 = getelementptr inbounds double, double* %16, i64 %221
%225 = bitcast double* %224 to <2 x double>*
%226 = load <2 x double>, <2 x double>* %225
%227 = getelementptr inbounds double, double* %224, i64 2
%228 = bitcast double* %227 to <2 x double>*
%229 = load <2 x double>, <2 x double>* %228
%230 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %226
%231 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %229
%232 = bitcast double* %224 to <2 x double>*
store <2 x double> %230, <2 x double>* %232
%233 = bitcast double* %227 to <2 x double>*
store <2 x double> %231, <2 x double>* %233
br label %234
234: ; preds = %220, %223
%235 = icmp eq i64 %185, %5
br i1 %235, label %245, label %236
236: ; preds = %182, %234
%237 = phi i64 [ 0, %182 ], [ %185, %234 ]
br label %238
238: ; preds = %236, %238
%239 = phi i64 [ %243, %238 ], [ %237, %236 ]
%240 = getelementptr inbounds double, double* %16, i64 %239
%241 = load double, double* %240
%242 = fsub double 1.000000e+00, %241
store double %242, double* %240
%243 = add nuw nsw i64 %239, 1
%244 = icmp eq i64 %243, %5
br i1 %244, label %245, label %238
245: ; preds = %238, %234, %147
%246 = tail call i32 (double*, i32, i32, double*, double*, ...) bitcast (i32 (...)* @computegradient to i32 (double*, i32, i32, double*, double*, ...)*)(double* %16, i32 %2, i32 %1, double* %12, double* %14)
%247 = tail call i32 (double*, double*, double*, i32, i32, i16*, i16*, double*, ...) bitcast (i32 (...)* @edtaa3 to i32 (double*, double*, double*, i32, i32, i16*, i16*, double*, ...)*)(double* %16, double* %12, double* %14, i32 %2, i32 %1, i16* %8, i16* %10, double* %20)
br i1 %21, label %256, label %248
248: ; preds = %245
%249 = and i64 %5, 1
%250 = icmp eq i32 %4, 1
br i1 %250, label %275, label %251
251: ; preds = %248
%252 = and i64 %5, 4294967294
br label %258
253: ; preds = %177
%254 = tail call i32 (double*, i32, i32, double*, double*, ...) bitcast (i32 (...)* @computegradient to i32 (double*, i32, i32, double*, double*, ...)*)(double* %16, i32 %2, i32 %1, double* %12, double* %14)
%255 = tail call i32 (double*, double*, double*, i32, i32, i16*, i16*, double*, ...) bitcast (i32 (...)* @edtaa3 to i32 (double*, double*, double*, i32, i32, i16*, i16*, double*, ...)*)(double* %16, double* %12, double* %14, i32 %2, i32 %1, i16* %8, i16* %10, double* %20)
br label %256
256: ; preds = %253, %245
%257 = tail call i8* @malloc(i64 %5)
br label %331
258: ; preds = %271, %251
%259 = phi i64 [ 0, %251 ], [ %272, %271 ]
%260 = phi i64 [ 0, %251 ], [ %273, %271 ]
%261 = getelementptr inbounds double, double* %20, i64 %259
%262 = load double, double* %261
%263 = fcmp olt double %262, 0.000000e+00
br i1 %263, label %264, label %265
264: ; preds = %258
store double 0.000000e+00, double* %261
br label %265
265: ; preds = %258, %264
%266 = or i64 %259, 1
%267 = getelementptr inbounds double, double* %20, i64 %266
%268 = load double, double* %267
%269 = fcmp olt double %268, 0.000000e+00
br i1 %269, label %270, label %271
270: ; preds = %265
store double 0.000000e+00, double* %267
br label %271
271: ; preds = %270, %265
%272 = add nuw nsw i64 %259, 2
%273 = add i64 %260, 2
%274 = icmp eq i64 %273, %252
br i1 %274, label %275, label %258
275: ; preds = %271, %248
%276 = phi i64 [ 0, %248 ], [ %272, %271 ]
%277 = icmp eq i64 %249, 0
br i1 %277, label %283, label %278
278: ; preds = %275
%279 = getelementptr inbounds double, double* %20, i64 %276
%280 = load double, double* %279
%281 = fcmp olt double %280, 0.000000e+00
br i1 %281, label %282, label %283
282: ; preds = %278
store double 0.000000e+00, double* %279
br label %283
283: ; preds = %278, %282, %275
%284 = tail call i8* @malloc(i64 %5)
br i1 %21, label %331, label %285
285: ; preds = %283
%286 = icmp eq i32 %4, 1
br i1 %286, label %312, label %287
287: ; preds = %285
%288 = and i64 %5, 4294967294
br label %289
289: ; preds = %289, %287
%290 = phi i64 [ 0, %287 ], [ %308, %289 ]
%291 = getelementptr inbounds double, double* %20, i64 %290
%292 = bitcast double* %291 to <2 x double>*
%293 = load <2 x double>, <2 x double>* %292
%294 = getelementptr inbounds double, double* %18, i64 %290
%295 = bitcast double* %294 to <2 x double>*
%296 = load <2 x double>, <2 x double>* %295
%297 = fsub <2 x double> %296, %293
%298 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %297, <2 x double> <double 1.600000e+01, double 1.600000e+01>, <2 x double> <double 1.280000e+02, double 1.280000e+02>)
%299 = fcmp olt <2 x double> %298, zeroinitializer
%300 = select <2 x i1> %299, <2 x double> zeroinitializer, <2 x double> %298
%301 = fcmp ogt <2 x double> %300, <double 2.550000e+02, double 2.550000e+02>
%302 = select <2 x i1> %301, <2 x double> <double 2.550000e+02, double 2.550000e+02>, <2 x double> %300
%303 = bitcast double* %294 to <2 x double>*
store <2 x double> %302, <2 x double>* %303
%304 = fptoui <2 x double> %302 to <2 x i8>
%305 = xor <2 x i8> %304, <i8 -1, i8 -1>
%306 = getelementptr inbounds i8, i8* %284, i64 %290
%307 = bitcast i8* %306 to <2 x i8>*
store <2 x i8> %305, <2 x i8>* %307
%308 = add nuw i64 %290, 2
%309 = icmp eq i64 %308, %288
br i1 %309, label %310, label %289
310: ; preds = %289
%311 = icmp eq i64 %288, %5
br i1 %311, label %331, label %312
312: ; preds = %285, %310
%313 = phi i64 [ 0, %285 ], [ %288, %310 ]
br label %314
314: ; preds = %312, %314
%315 = phi i64 [ %329, %314 ], [ %313, %312 ]
%316 = getelementptr inbounds double, double* %20, i64 %315
%317 = load double, double* %316
%318 = getelementptr inbounds double, double* %18, i64 %315
%319 = load double, double* %318
%320 = fsub double %319, %317
%321 = tail call double @llvm.fmuladd.f64(double %320, double 1.600000e+01, double 1.280000e+02)
%322 = fcmp olt double %321, 0.000000e+00
%323 = select i1 %322, double 0.000000e+00, double %321
%324 = fcmp ogt double %323, 2.550000e+02
%325 = select i1 %324, double 2.550000e+02, double %323
store double %325, double* %318
%326 = fptoui double %325 to i8
%327 = xor i8 %326, -1
%328 = getelementptr inbounds i8, i8* %284, i64 %315
store i8 %327, i8* %328
%329 = add nuw nsw i64 %315, 1
%330 = icmp eq i64 %329, %5
br i1 %330, label %331, label %314
331: ; preds = %314, %310, %256, %283
%332 = phi i8* [ %257, %256 ], [ %284, %283 ], [ %284, %310 ], [ %284, %314 ]
tail call void @free(i8* %7)
tail call void @free(i8* %9)
tail call void @free(i8* %11)
tail call void @free(i8* %13)
tail call void @free(i8* %15)
tail call void @free(i8* %17)
tail call void @free(i8* %19)
ret i8* %332
}