int edge_gray_shade_region(in_name, the_image, out_image, edge_type, min_area,
                           max_area, diff, percent, set_value, erode, rows,
                           cols, bits_per_pixel)
char in_name[];
float percent;
int edge_type;
long bits_per_pixel, cols, rows;
short diff, erode, max_area, min_area, set_value, **the_image, **out_image;
{
  int a, b, count, i, j, k, length, width;
  short cutoff;
  unsigned long histogram[255 + 1];
  if (edge_type == 1 || edge_type == 2 || edge_type == 3)
    detect_edges(the_image, out_image, edge_type, 0, 0, rows, cols,
                 bits_per_pixel);
  if (edge_type == 4) {
    quick_edge(the_image, out_image, 0, 0, rows, cols, bits_per_pixel);
  }
  if (edge_type == 5) {
    homogeneity(the_image, out_image, rows, cols, bits_per_pixel, 0, 0);
  }
  if (edge_type == 6) {
    difference_edge(the_image, out_image, rows, cols, bits_per_pixel, 0, 0);
  }
  if (edge_type == 7) {
    contrast_edge(the_image, out_image, rows, cols, bits_per_pixel, 0, 0);
  }
  if (edge_type == 8) {
    gaussian_edge(the_image, out_image, rows, cols, bits_per_pixel, 3, 0, 0);
  }
  if (edge_type == 10) {
    range(the_image, out_image, rows, cols, bits_per_pixel, 3, 0, 0);
  }
  if (edge_type == 11) {
    variance(the_image, out_image, rows, cols, bits_per_pixel, 0, 0);
  }
  for (i = 0; i < rows; i++)
    for (j = 0; j < cols; j++)
      the_image[i][j] = out_image[i][j];
  zero_histogram(histogram, 255 + 1);
  calculate_histogram(the_image, histogram, rows, cols);
  find_cutoff_point(histogram, percent, &cutoff, rows, cols);
  threshold_image_array(the_image, out_image, 255, cutoff, set_value, rows,
                        cols);
  if (erode != 0) {
    for (i = 0; i < rows; i++)
      for (j = 0; j < cols; j++)
        the_image[i][j] = out_image[i][j];
    erode_image_array(the_image, out_image, set_value, erode, rows, cols);
  }
  read_image_array(in_name, the_image);
  for (i = 0; i < rows; i++)
    for (j = 0; j < cols; j++)
      if (out_image[i][j] == set_value)
        the_image[i][j] = -50;
  pixel_grow(the_image, out_image, diff, min_area, max_area, rows, cols);
  return (1);
}


x86 assembly (clang, -O0):
<edge_gray_shade_region>:
push   %rbp
mov    %rsp,%rbp
sub    $0x870,%rsp
mov    %r9d,-0x858(%rbp)
mov    %r8d,-0x854(%rbp)
mov    %ecx,%r8d
mov    %rdx,%r9
mov    %rsi,%r10
mov    -0x858(%rbp),%esi
mov    %rdi,%r11
mov    -0x854(%rbp),%edi
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%ecx
mov    0x10(%rbp),%edx
cvtsd2ss %xmm0,%xmm0
mov    %r11,-0x8(%rbp)
mov    %r10,-0x10(%rbp)
mov    %r9,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %di,-0x1e(%rbp)
mov    %si,-0x20(%rbp)
mov    %dx,-0x22(%rbp)
movss  %xmm0,-0x28(%rbp)
mov    %cx,-0x2a(%rbp)
mov    %ax,-0x2c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
je     1281 <edge_gray_shade_region+0x91>
cmpl   $0x2,-0x1c(%rbp)
je     1281 <edge_gray_shade_region+0x91>
cmpl   $0x3,-0x1c(%rbp)
jne    12ae <edge_gray_shade_region+0xbe>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    0x28(%rbp),%r9
mov    0x30(%rbp),%r10
mov    0x38(%rbp),%rax
xor    %r8d,%r8d
mov    %r8d,%ecx
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   10f0 <detect_edges@plt>
cmpl   $0x4,-0x1c(%rbp)
jne    12db <edge_gray_shade_region+0xeb>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x28(%rbp),%r8
mov    0x30(%rbp),%r9
mov    0x38(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
mov    %rax,(%rsp)
mov    $0x0,%al
call   1040 <quick_edge@plt>
cmpl   $0x5,-0x1c(%rbp)
jne    130a <edge_gray_shade_region+0x11a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x28(%rbp),%rdx
mov    0x30(%rbp),%rcx
mov    0x38(%rbp),%r8
xor    %r9d,%r9d
movl   $0x0,(%rsp)
mov    $0x0,%al
call   1070 <homogeneity@plt>
cmpl   $0x6,-0x1c(%rbp)
jne    1339 <edge_gray_shade_region+0x149>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x28(%rbp),%rdx
mov    0x30(%rbp),%rcx
mov    0x38(%rbp),%r8
xor    %r9d,%r9d
movl   $0x0,(%rsp)
mov    $0x0,%al
call   10e0 <difference_edge@plt>
cmpl   $0x7,-0x1c(%rbp)
jne    1368 <edge_gray_shade_region+0x178>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x28(%rbp),%rdx
mov    0x30(%rbp),%rcx
mov    0x38(%rbp),%r8
xor    %r9d,%r9d
movl   $0x0,(%rsp)
mov    $0x0,%al
call   1060 <contrast_edge@plt>
cmpl   $0x8,-0x1c(%rbp)
jne    13a4 <edge_gray_shade_region+0x1b4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x28(%rbp),%rdx
mov    0x30(%rbp),%rcx
mov    0x38(%rbp),%r8
mov    $0x3,%r9d
xor    %eax,%eax
movl   $0x0,(%rsp)
movl   $0x0,0x8(%rsp)
mov    $0x0,%al
call   10b0 <gaussian_edge@plt>
cmpl   $0xa,-0x1c(%rbp)
jne    13e0 <edge_gray_shade_region+0x1f0>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x28(%rbp),%rdx
mov    0x30(%rbp),%rcx
mov    0x38(%rbp),%r8
mov    $0x3,%r9d
xor    %eax,%eax
movl   $0x0,(%rsp)
movl   $0x0,0x8(%rsp)
mov    $0x0,%al
call   10c0 <range@plt>
cmpl   $0xb,-0x1c(%rbp)
jne    140f <edge_gray_shade_region+0x21f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x28(%rbp),%rdx
mov    0x30(%rbp),%rcx
mov    0x38(%rbp),%r8
xor    %r9d,%r9d
movl   $0x0,(%rsp)
mov    $0x0,%al
call   1080 <variance@plt>
movl   $0x0,-0x3c(%rbp)
movslq -0x3c(%rbp),%rax
cmp    0x28(%rbp),%rax
jge    1482 <edge_gray_shade_region+0x292>
movl   $0x0,-0x40(%rbp)
movslq -0x40(%rbp),%rax
cmp    0x30(%rbp),%rax
jge    146f <edge_gray_shade_region+0x27f>
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x40(%rbp),%rcx
mov    (%rax,%rcx,2),%dx
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x40(%rbp),%rcx
mov    %dx,(%rax,%rcx,2)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    142b <edge_gray_shade_region+0x23b>
jmp    1474 <edge_gray_shade_region+0x284>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1416 <edge_gray_shade_region+0x226>
lea    -0x850(%rbp),%rdi
mov    $0x100,%esi
mov    $0x0,%al
call   1110 <zero_histogram@plt>
mov    -0x10(%rbp),%rdi
lea    -0x850(%rbp),%rsi
mov    0x28(%rbp),%rdx
mov    0x30(%rbp),%rcx
mov    $0x0,%al
call   1090 <calculate_histogram@plt>
lea    -0x850(%rbp),%rdi
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    0x28(%rbp),%rdx
mov    0x30(%rbp),%rcx
lea    -0x4e(%rbp),%rsi
mov    $0x1,%al
call   10d0 <find_cutoff_point@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movswl -0x4e(%rbp),%ecx
movswl -0x2a(%rbp),%r8d
mov    0x28(%rbp),%r9
mov    0x30(%rbp),%rax
mov    $0xff,%edx
mov    %rax,(%rsp)
mov    $0x0,%al
call   1050 <threshold_image_array@plt>
movswl -0x2c(%rbp),%eax
cmp    $0x0,%eax
je     159a <edge_gray_shade_region+0x3aa>
movl   $0x0,-0x3c(%rbp)
movslq -0x3c(%rbp),%rax
cmp    0x28(%rbp),%rax
jge    157b <edge_gray_shade_region+0x38b>
movl   $0x0,-0x40(%rbp)
movslq -0x40(%rbp),%rax
cmp    0x30(%rbp),%rax
jge    1568 <edge_gray_shade_region+0x378>
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x40(%rbp),%rcx
mov    (%rax,%rcx,2),%dx
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x40(%rbp),%rcx
mov    %dx,(%rax,%rcx,2)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1524 <edge_gray_shade_region+0x334>
jmp    156d <edge_gray_shade_region+0x37d>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    150f <edge_gray_shade_region+0x31f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movswl -0x2a(%rbp),%edx
movswl -0x2c(%rbp),%ecx
mov    0x28(%rbp),%r8
mov    0x30(%rbp),%r9
mov    $0x0,%al
call   1030 <erode_image_array@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1100 <read_image_array@plt>
movl   $0x0,-0x3c(%rbp)
movslq -0x3c(%rbp),%rax
cmp    0x28(%rbp),%rax
jge    162f <edge_gray_shade_region+0x43f>
movl   $0x0,-0x40(%rbp)
movslq -0x40(%rbp),%rax
cmp    0x30(%rbp),%rax
jge    161c <edge_gray_shade_region+0x42c>
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x40(%rbp),%rcx
movswl (%rax,%rcx,2),%eax
movswl -0x2a(%rbp),%ecx
cmp    %ecx,%eax
jne    1609 <edge_gray_shade_region+0x419>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x40(%rbp),%rcx
movw   $0xffce,(%rax,%rcx,2)
jmp    160e <edge_gray_shade_region+0x41e>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    15c5 <edge_gray_shade_region+0x3d5>
jmp    1621 <edge_gray_shade_region+0x431>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    15b0 <edge_gray_shade_region+0x3c0>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movswl -0x22(%rbp),%edx
movswl -0x1e(%rbp),%ecx
movswl -0x20(%rbp),%r8d
mov    0x28(%rbp),%r9
mov    0x30(%rbp),%rax
mov    %rax,(%rsp)
mov    $0x0,%al
call   10a0 <pixel_grow@plt>
mov    $0x1,%eax
add    $0x870,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<edge_gray_shade_region>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x848,%rsp
movsd  %xmm0,0x20(%rsp)
mov    %r9d,0x34(%rsp)
mov    %r8d,0x30(%rsp)
mov    %ecx,%ebp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,0x38(%rsp)
mov    0x8a8(%rsp),%r13
mov    0x8a0(%rsp),%r12
mov    0x898(%rsp),%r10
lea    -0x1(%rbp),%eax
cmp    $0x2,%eax
ja     1266 <edge_gray_shade_region+0x76>
mov    %r13,0x8(%rsp)
mov    %r12,(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %r10,%r9
xor    %eax,%eax
call   10f0 <detect_edges@plt>
mov    0x898(%rsp),%r10
add    $0xfffffffc,%ebp
cmp    $0x7,%ebp
ja     1390 <edge_gray_shade_region+0x1a0>
lea    0xd87(%rip),%rax
movslq (%rax,%rbp,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    %r13,(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r10,%r8
mov    %r12,%r9
xor    %eax,%eax
call   1040 <quick_edge@plt>
jmp    1388 <edge_gray_shade_region+0x198>
movl   $0x0,(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r10,%rdx
mov    %r12,%rcx
mov    %r13,%r8
xor    %r9d,%r9d
xor    %eax,%eax
call   1070 <homogeneity@plt>
jmp    1388 <edge_gray_shade_region+0x198>
movl   $0x0,(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r10,%rdx
mov    %r12,%rcx
mov    %r13,%r8
xor    %r9d,%r9d
xor    %eax,%eax
call   10e0 <difference_edge@plt>
jmp    1388 <edge_gray_shade_region+0x198>
movl   $0x0,(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r10,%rdx
mov    %r12,%rcx
mov    %r13,%r8
xor    %r9d,%r9d
xor    %eax,%eax
call   1060 <contrast_edge@plt>
jmp    1388 <edge_gray_shade_region+0x198>
movl   $0x0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r10,%rdx
mov    %r12,%rcx
mov    %r13,%r8
mov    $0x3,%r9d
xor    %eax,%eax
call   10c0 <range@plt>
jmp    1388 <edge_gray_shade_region+0x198>
movl   $0x0,(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r10,%rdx
mov    %r12,%rcx
mov    %r13,%r8
xor    %r9d,%r9d
xor    %eax,%eax
call   1080 <variance@plt>
jmp    1388 <edge_gray_shade_region+0x198>
movl   $0x0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r10,%rdx
mov    %r12,%rcx
mov    %r13,%r8
mov    $0x3,%r9d
xor    %eax,%eax
call   10b0 <gaussian_edge@plt>
mov    0x898(%rsp),%r10
movsd  0x20(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x18(%rsp)
test   %r10,%r10
jle    1565 <edge_gray_shade_region+0x375>
lea    -0x10(%r12),%r8
mov    %r8,0x20(%rsp)
shr    $0x4,%r8
add    $0x1,%r8
mov    %r12,%r11
and    $0xfffffffffffffff0,%r11
mov    %r8d,%r9d
and    $0x3,%r9d
movabs $0x1ffffffffffffffc,%rax
ff ff 1f
and    %rax,%r8
mov    %r12d,%r13d
and    $0x3,%r13d
mov    %r9,0x28(%rsp)
shl    $0x5,%r9
xor    %eax,%eax
jmp    13fd <edge_gray_shade_region+0x20d>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rax
cmp    %r10,%rax
je     1565 <edge_gray_shade_region+0x375>
test   %r12,%r12
jle    13f0 <edge_gray_shade_region+0x200>
mov    (%r15,%rax,8),%rcx
mov    (%r14,%rax,8),%rdx
cmp    $0x10,%r12
jb     1422 <edge_gray_shade_region+0x232>
lea    (%rcx,%r12,2),%rdi
cmp    %rdi,%rdx
jae    1494 <edge_gray_shade_region+0x2a4>
lea    (%rdx,%r12,2),%rdi
cmp    %rdi,%rcx
jae    1494 <edge_gray_shade_region+0x2a4>
xor    %edi,%edi
mov    %rdi,%rbp
not    %rbp
add    %r12,%rbp
test   %r13,%r13
je     1452 <edge_gray_shade_region+0x262>
mov    %r13,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
movzwl (%rcx,%rdi,2),%esi
mov    %si,(%rdx,%rdi,2)
add    $0x1,%rdi
add    $0xffffffffffffffff,%rbx
jne    1440 <edge_gray_shade_region+0x250>
cmp    $0x3,%rbp
jb     13f0 <edge_gray_shade_region+0x200>
nopl   0x0(%rax,%rax,1)
movzwl (%rcx,%rdi,2),%esi
mov    %si,(%rdx,%rdi,2)
movzwl 0x2(%rcx,%rdi,2),%esi
mov    %si,0x2(%rdx,%rdi,2)
movzwl 0x4(%rcx,%rdi,2),%esi
mov    %si,0x4(%rdx,%rdi,2)
movzwl 0x6(%rcx,%rdi,2),%esi
mov    %si,0x6(%rdx,%rdi,2)
add    $0x4,%rdi
cmp    %rdi,%r12
jne    1460 <edge_gray_shade_region+0x270>
jmp    13f0 <edge_gray_shade_region+0x200>
cmpq   $0x30,0x20(%rsp)
jae    14a0 <edge_gray_shade_region+0x2b0>
xor    %edi,%edi
jmp    1508 <edge_gray_shade_region+0x318>
mov    %r8,%r10
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
nop
movups (%rcx,%rdi,2),%xmm0
movups 0x10(%rcx,%rdi,2),%xmm1
movups %xmm0,(%rdx,%rdi,2)
movups %xmm1,0x10(%rdx,%rdi,2)
movups 0x20(%rcx,%rdi,2),%xmm0
movups 0x30(%rcx,%rdi,2),%xmm1
movups %xmm0,0x20(%rdx,%rdi,2)
movups %xmm1,0x30(%rdx,%rdi,2)
movups 0x40(%rcx,%rdi,2),%xmm0
movups 0x50(%rcx,%rdi,2),%xmm1
movups %xmm0,0x40(%rdx,%rdi,2)
movups %xmm1,0x50(%rdx,%rdi,2)
movups 0x60(%rcx,%rdi,2),%xmm0
movups 0x70(%rcx,%rdi,2),%xmm1
movups %xmm0,0x60(%rdx,%rdi,2)
movups %xmm1,0x70(%rdx,%rdi,2)
add    $0x40,%rdi
add    $0xfffffffffffffffc,%r10
jne    14b0 <edge_gray_shade_region+0x2c0>
cmpq   $0x0,0x28(%rsp)
je     154c <edge_gray_shade_region+0x35c>
lea    (%rdx,%rdi,2),%rbp
add    $0x10,%rbp
lea    (%rcx,%rdi,2),%rdi
add    $0x10,%rdi
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movups -0x10(%rdi,%rbx,1),%xmm0
movups (%rdi,%rbx,1),%xmm1
movups %xmm0,-0x10(%rbp,%rbx,1)
movups %xmm1,0x0(%rbp,%rbx,1)
add    $0x20,%rbx
cmp    %rbx,%r9
jne    1530 <edge_gray_shade_region+0x340>
mov    %r11,%rdi
cmp    %r12,%r11
mov    0x898(%rsp),%r10
je     13f0 <edge_gray_shade_region+0x200>
jmp    1424 <edge_gray_shade_region+0x234>
lea    0x40(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x100,%esi
xor    %eax,%eax
mov    %r10,%rbx
call   1110 <zero_histogram@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1090 <calculate_histogram@plt>
movss  0x18(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0x1e(%rsp),%rsi
mov    %rbp,%rdi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    $0x1,%al
call   10d0 <find_cutoff_point@plt>
movswl 0x1e(%rsp),%ecx
mov    0x888(%rsp),%eax
movswl %ax,%r13d
mov    %r12,(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0xff,%edx
mov    %r13d,%r8d
mov    %rbx,%r9
xor    %eax,%eax
call   1050 <threshold_image_array@plt>
mov    0x890(%rsp),%eax
test   $0xffff,%eax
je     17ce <edge_gray_shade_region+0x5de>
cwtl
mov    %eax,0x18(%rsp)
test   %rbx,%rbx
jle    17ac <edge_gray_shade_region+0x5bc>
lea    -0x10(%r12),%r10
mov    %r10,0x20(%rsp)
shr    $0x4,%r10
add    $0x1,%r10
mov    %r12,%r8
and    $0xfffffffffffffff0,%r8
mov    %r10d,%r9d
and    $0x3,%r9d
movabs $0x1ffffffffffffffc,%rax
ff ff 1f
and    %rax,%r10
mov    %r12d,%ebp
and    $0x3,%ebp
mov    %r9,0x28(%rsp)
shl    $0x5,%r9
xor    %edx,%edx
jmp    1652 <edge_gray_shade_region+0x462>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rdx
cmp    0x898(%rsp),%rdx
je     17ac <edge_gray_shade_region+0x5bc>
test   %r12,%r12
jle    1640 <edge_gray_shade_region+0x450>
mov    (%r15,%rdx,8),%rsi
mov    (%r14,%rdx,8),%rax
cmp    $0x10,%r12
jb     1677 <edge_gray_shade_region+0x487>
lea    (%rsi,%r12,2),%rcx
cmp    %rcx,%rax
jae    16ec <edge_gray_shade_region+0x4fc>
lea    (%rax,%r12,2),%rcx
cmp    %rcx,%rsi
jae    16ec <edge_gray_shade_region+0x4fc>
xor    %r11d,%r11d
mov    %r11,%rcx
not    %rcx
add    %r12,%rcx
test   %rbp,%rbp
je     16a4 <edge_gray_shade_region+0x4b4>
mov    %rbp,%rdi
nopl   0x0(%rax,%rax,1)
movzwl (%rsi,%r11,2),%ebx
mov    %bx,(%rax,%r11,2)
add    $0x1,%r11
add    $0xffffffffffffffff,%rdi
jne    1690 <edge_gray_shade_region+0x4a0>
cmp    $0x3,%rcx
jb     1640 <edge_gray_shade_region+0x450>
nopw   0x0(%rax,%rax,1)
movzwl (%rsi,%r11,2),%ecx
mov    %cx,(%rax,%r11,2)
movzwl 0x2(%rsi,%r11,2),%ecx
mov    %cx,0x2(%rax,%r11,2)
movzwl 0x4(%rsi,%r11,2),%ecx
mov    %cx,0x4(%rax,%r11,2)
movzwl 0x6(%rsi,%r11,2),%ecx
mov    %cx,0x6(%rax,%r11,2)
add    $0x4,%r11
cmp    %r11,%r12
jne    16b0 <edge_gray_shade_region+0x4c0>
jmp    1640 <edge_gray_shade_region+0x450>
cmpq   $0x30,0x20(%rsp)
jae    16f8 <edge_gray_shade_region+0x508>
xor    %ecx,%ecx
jmp    1758 <edge_gray_shade_region+0x568>
mov    %r10,%rdi
xor    %ecx,%ecx
nopl   (%rax)
movups (%rsi,%rcx,2),%xmm0
movups 0x10(%rsi,%rcx,2),%xmm1
movups %xmm0,(%rax,%rcx,2)
movups %xmm1,0x10(%rax,%rcx,2)
movups 0x20(%rsi,%rcx,2),%xmm0
movups 0x30(%rsi,%rcx,2),%xmm1
movups %xmm0,0x20(%rax,%rcx,2)
movups %xmm1,0x30(%rax,%rcx,2)
movups 0x40(%rsi,%rcx,2),%xmm0
movups 0x50(%rsi,%rcx,2),%xmm1
movups %xmm0,0x40(%rax,%rcx,2)
movups %xmm1,0x50(%rax,%rcx,2)
movups 0x60(%rsi,%rcx,2),%xmm0
movups 0x70(%rsi,%rcx,2),%xmm1
movups %xmm0,0x60(%rax,%rcx,2)
movups %xmm1,0x70(%rax,%rcx,2)
add    $0x40,%rcx
add    $0xfffffffffffffffc,%rdi
jne    1700 <edge_gray_shade_region+0x510>
cmpq   $0x0,0x28(%rsp)
je     179b <edge_gray_shade_region+0x5ab>
lea    (%rax,%rcx,2),%rdi
add    $0x10,%rdi
lea    (%rsi,%rcx,2),%rcx
add    $0x10,%rcx
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movups -0x10(%rcx,%rbx,1),%xmm0
movups (%rcx,%rbx,1),%xmm1
movups %xmm0,-0x10(%rdi,%rbx,1)
movups %xmm1,(%rdi,%rbx,1)
add    $0x20,%rbx
cmp    %rbx,%r9
jne    1780 <edge_gray_shade_region+0x590>
mov    %r8,%r11
cmp    %r12,%r8
je     1640 <edge_gray_shade_region+0x450>
jmp    167a <edge_gray_shade_region+0x48a>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r13d,%edx
mov    0x18(%rsp),%ecx
mov    0x898(%rsp),%rbx
mov    %rbx,%r8
mov    %r12,%r9
xor    %eax,%eax
call   1030 <erode_image_array@plt>
mov    0x880(%rsp),%ebp
mov    0x38(%rsp),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1100 <read_image_array@plt>
test   %rbx,%rbx
jle    1873 <edge_gray_shade_region+0x683>
mov    %r12,%rax
and    $0xfffffffffffffffe,%rax
xor    %ecx,%ecx
jmp    1809 <edge_gray_shade_region+0x619>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rcx
cmp    %rbx,%rcx
je     1873 <edge_gray_shade_region+0x683>
test   %r12,%r12
jle    1800 <edge_gray_shade_region+0x610>
mov    (%r15,%rcx,8),%rdx
xor    %esi,%esi
cmp    $0x1,%r12
jne    1849 <edge_gray_shade_region+0x659>
test   $0x1,%r12b
je     1800 <edge_gray_shade_region+0x610>
movswl (%rdx,%rsi,2),%edx
cmp    %edx,%r13d
jne    1800 <edge_gray_shade_region+0x610>
mov    (%r14,%rcx,8),%rdx
movw   $0xffce,(%rdx,%rsi,2)
jmp    1800 <edge_gray_shade_region+0x610>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x2,%rsi
cmp    %rsi,%rax
je     181a <edge_gray_shade_region+0x62a>
movswl (%rdx,%rsi,2),%edi
cmp    %edi,%r13d
jne    185c <edge_gray_shade_region+0x66c>
mov    (%r14,%rcx,8),%rdi
movw   $0xffce,(%rdi,%rsi,2)
movswl 0x2(%rdx,%rsi,2),%edi
cmp    %edi,%r13d
jne    1840 <edge_gray_shade_region+0x650>
mov    (%r14,%rcx,8),%rdi
movw   $0xffce,0x2(%rdi,%rsi,2)
jmp    1840 <edge_gray_shade_region+0x650>
movswl %bp,%edx
movswl 0x30(%rsp),%ecx
movswl 0x34(%rsp),%r8d
mov    %r12,(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%r9
xor    %eax,%eax
call   10a0 <pixel_grow@plt>
mov    $0x1,%eax
add    $0x848,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @edge_gray_shade_region(i8* %0, i16** %1, i16** %2, i32 %3, i32 %4, i32 %5, i32 %6, double %7, i32 %8, i32 %9, i64 %10, i64 %11, i64 %12) {
%14 = alloca i16
%15 = alloca [256 x i64]
%16 = fptrunc double %7 to float
%17 = bitcast i16* %14 to i8*
%18 = bitcast [256 x i64]* %15 to i8*
%19 = add i32 %3, -1
%20 = icmp ult i32 %19, 3
br i1 %20, label %21, label %23
21: ; preds = %13
%22 = tail call i32 (i16**, i16**, i32, i32, i32, i64, i64, i64, ...) bitcast (i32 (...)* @detect_edges to i32 (i16**, i16**, i32, i32, i32, i64, i64, i64, ...)*)(i16** %1, i16** %2, i32 %3, i32 0, i32 0, i64 %10, i64 %11, i64 %12)
br label %23
23: ; preds = %13, %21
switch i32 %3, label %38 [
i32 4, label %24
i32 5, label %26
i32 6, label %28
i32 7, label %30
i32 8, label %32
i32 10, label %34
i32 11, label %36
]
24: ; preds = %23
%25 = tail call i32 (i16**, i16**, i32, i32, i64, i64, i64, ...) bitcast (i32 (...)* @quick_edge to i32 (i16**, i16**, i32, i32, i64, i64, i64, ...)*)(i16** %1, i16** %2, i32 0, i32 0, i64 %10, i64 %11, i64 %12)
br label %38
26: ; preds = %23
%27 = tail call i32 (i16**, i16**, i64, i64, i64, i32, i32, ...) bitcast (i32 (...)* @homogeneity to i32 (i16**, i16**, i64, i64, i64, i32, i32, ...)*)(i16** %1, i16** %2, i64 %10, i64 %11, i64 %12, i32 0, i32 0)
br label %38
28: ; preds = %23
%29 = tail call i32 (i16**, i16**, i64, i64, i64, i32, i32, ...) bitcast (i32 (...)* @difference_edge to i32 (i16**, i16**, i64, i64, i64, i32, i32, ...)*)(i16** %1, i16** %2, i64 %10, i64 %11, i64 %12, i32 0, i32 0)
br label %38
30: ; preds = %23
%31 = tail call i32 (i16**, i16**, i64, i64, i64, i32, i32, ...) bitcast (i32 (...)* @contrast_edge to i32 (i16**, i16**, i64, i64, i64, i32, i32, ...)*)(i16** %1, i16** %2, i64 %10, i64 %11, i64 %12, i32 0, i32 0)
br label %38
32: ; preds = %23
%33 = tail call i32 (i16**, i16**, i64, i64, i64, i32, i32, i32, ...) bitcast (i32 (...)* @gaussian_edge to i32 (i16**, i16**, i64, i64, i64, i32, i32, i32, ...)*)(i16** %1, i16** %2, i64 %10, i64 %11, i64 %12, i32 3, i32 0, i32 0)
br label %38
34: ; preds = %23
%35 = tail call i32 (i16**, i16**, i64, i64, i64, i32, i32, i32, ...) bitcast (i32 (...)* @range to i32 (i16**, i16**, i64, i64, i64, i32, i32, i32, ...)*)(i16** %1, i16** %2, i64 %10, i64 %11, i64 %12, i32 3, i32 0, i32 0)
br label %38
36: ; preds = %23
%37 = tail call i32 (i16**, i16**, i64, i64, i64, i32, i32, ...) bitcast (i32 (...)* @variance to i32 (i16**, i16**, i64, i64, i64, i32, i32, ...)*)(i16** %1, i16** %2, i64 %10, i64 %11, i64 %12, i32 0, i32 0)
br label %38
38: ; preds = %34, %32, %30, %28, %26, %24, %23, %36
%39 = icmp sgt i64 %10, 0
br i1 %39, label %40, label %174
40: ; preds = %38
%41 = icmp sgt i64 %11, 0
%42 = add i64 %11, -16
%43 = lshr i64 %42, 4
%44 = add nuw nsw i64 %43, 1
%45 = icmp ult i64 %11, 16
%46 = and i64 %11, -16
%47 = and i64 %44, 3
%48 = icmp ult i64 %42, 48
%49 = and i64 %44, 2305843009213693948
%50 = icmp eq i64 %47, 0
%51 = icmp eq i64 %46, %11
%52 = and i64 %11, 3
%53 = icmp eq i64 %52, 0
br label %54
54: ; preds = %40, %171
%55 = phi i64 [ 0, %40 ], [ %172, %171 ]
br i1 %41, label %56, label %171
56: ; preds = %54
%57 = getelementptr inbounds i16*, i16** %2, i64 %55
%58 = load i16*, i16** %57
%59 = getelementptr inbounds i16*, i16** %1, i64 %55
%60 = load i16*, i16** %59
br i1 %45, label %136, label %61
61: ; preds = %56
%62 = getelementptr i16, i16* %60, i64 %11
%63 = getelementptr i16, i16* %58, i64 %11
%64 = icmp ult i16* %60, %63
%65 = icmp ult i16* %58, %62
%66 = and i1 %64, %65
br i1 %66, label %136, label %67
67: ; preds = %61
br i1 %48, label %117, label %68
68: ; preds = %67, %68
%69 = phi i64 [ %114, %68 ], [ 0, %67 ]
%70 = phi i64 [ %115, %68 ], [ 0, %67 ]
%71 = getelementptr inbounds i16, i16* %58, i64 %69
%72 = bitcast i16* %71 to <8 x i16>*
%73 = load <8 x i16>, <8 x i16>* %72
%74 = getelementptr inbounds i16, i16* %71, i64 8
%75 = bitcast i16* %74 to <8 x i16>*
%76 = load <8 x i16>, <8 x i16>* %75
%77 = getelementptr inbounds i16, i16* %60, i64 %69
%78 = bitcast i16* %77 to <8 x i16>*
store <8 x i16> %73, <8 x i16>* %78
%79 = getelementptr inbounds i16, i16* %77, i64 8
%80 = bitcast i16* %79 to <8 x i16>*
store <8 x i16> %76, <8 x i16>* %80
%81 = or i64 %69, 16
%82 = getelementptr inbounds i16, i16* %58, i64 %81
%83 = bitcast i16* %82 to <8 x i16>*
%84 = load <8 x i16>, <8 x i16>* %83
%85 = getelementptr inbounds i16, i16* %82, i64 8
%86 = bitcast i16* %85 to <8 x i16>*
%87 = load <8 x i16>, <8 x i16>* %86
%88 = getelementptr inbounds i16, i16* %60, i64 %81
%89 = bitcast i16* %88 to <8 x i16>*
store <8 x i16> %84, <8 x i16>* %89
%90 = getelementptr inbounds i16, i16* %88, i64 8
%91 = bitcast i16* %90 to <8 x i16>*
store <8 x i16> %87, <8 x i16>* %91
%92 = or i64 %69, 32
%93 = getelementptr inbounds i16, i16* %58, i64 %92
%94 = bitcast i16* %93 to <8 x i16>*
%95 = load <8 x i16>, <8 x i16>* %94
%96 = getelementptr inbounds i16, i16* %93, i64 8
%97 = bitcast i16* %96 to <8 x i16>*
%98 = load <8 x i16>, <8 x i16>* %97
%99 = getelementptr inbounds i16, i16* %60, i64 %92
%100 = bitcast i16* %99 to <8 x i16>*
store <8 x i16> %95, <8 x i16>* %100
%101 = getelementptr inbounds i16, i16* %99, i64 8
%102 = bitcast i16* %101 to <8 x i16>*
store <8 x i16> %98, <8 x i16>* %102
%103 = or i64 %69, 48
%104 = getelementptr inbounds i16, i16* %58, i64 %103
%105 = bitcast i16* %104 to <8 x i16>*
%106 = load <8 x i16>, <8 x i16>* %105
%107 = getelementptr inbounds i16, i16* %104, i64 8
%108 = bitcast i16* %107 to <8 x i16>*
%109 = load <8 x i16>, <8 x i16>* %108
%110 = getelementptr inbounds i16, i16* %60, i64 %103
%111 = bitcast i16* %110 to <8 x i16>*
store <8 x i16> %106, <8 x i16>* %111
%112 = getelementptr inbounds i16, i16* %110, i64 8
%113 = bitcast i16* %112 to <8 x i16>*
store <8 x i16> %109, <8 x i16>* %113
%114 = add nuw i64 %69, 64
%115 = add i64 %70, 4
%116 = icmp eq i64 %115, %49
br i1 %116, label %117, label %68
117: ; preds = %68, %67
%118 = phi i64 [ 0, %67 ], [ %114, %68 ]
br i1 %50, label %135, label %119
119: ; preds = %117, %119
%120 = phi i64 [ %132, %119 ], [ %118, %117 ]
%121 = phi i64 [ %133, %119 ], [ 0, %117 ]
%122 = getelementptr inbounds i16, i16* %58, i64 %120
%123 = bitcast i16* %122 to <8 x i16>*
%124 = load <8 x i16>, <8 x i16>* %123
%125 = getelementptr inbounds i16, i16* %122, i64 8
%126 = bitcast i16* %125 to <8 x i16>*
%127 = load <8 x i16>, <8 x i16>* %126
%128 = getelementptr inbounds i16, i16* %60, i64 %120
%129 = bitcast i16* %128 to <8 x i16>*
store <8 x i16> %124, <8 x i16>* %129
%130 = getelementptr inbounds i16, i16* %128, i64 8
%131 = bitcast i16* %130 to <8 x i16>*
store <8 x i16> %127, <8 x i16>* %131
%132 = add nuw i64 %120, 16
%133 = add i64 %121, 1
%134 = icmp eq i64 %133, %47
br i1 %134, label %135, label %119
135: ; preds = %119, %117
br i1 %51, label %171, label %136
136: ; preds = %61, %56, %135
%137 = phi i64 [ 0, %61 ], [ 0, %56 ], [ %46, %135 ]
%138 = xor i64 %137, -1
%139 = add i64 %138, %11
br i1 %53, label %149, label %140
140: ; preds = %136, %140
%141 = phi i64 [ %146, %140 ], [ %137, %136 ]
%142 = phi i64 [ %147, %140 ], [ 0, %136 ]
%143 = getelementptr inbounds i16, i16* %58, i64 %141
%144 = load i16, i16* %143
%145 = getelementptr inbounds i16, i16* %60, i64 %141
store i16 %144, i16* %145
%146 = add nuw nsw i64 %141, 1
%147 = add i64 %142, 1
%148 = icmp eq i64 %147, %52
br i1 %148, label %149, label %140
149: ; preds = %140, %136
%150 = phi i64 [ %137, %136 ], [ %146, %140 ]
%151 = icmp ult i64 %139, 3
br i1 %151, label %171, label %152
152: ; preds = %149, %152
%153 = phi i64 [ %169, %152 ], [ %150, %149 ]
%154 = getelementptr inbounds i16, i16* %58, i64 %153
%155 = load i16, i16* %154
%156 = getelementptr inbounds i16, i16* %60, i64 %153
store i16 %155, i16* %156
%157 = add nuw nsw i64 %153, 1
%158 = getelementptr inbounds i16, i16* %58, i64 %157
%159 = load i16, i16* %158
%160 = getelementptr inbounds i16, i16* %60, i64 %157
store i16 %159, i16* %160
%161 = add nuw nsw i64 %153, 2
%162 = getelementptr inbounds i16, i16* %58, i64 %161
%163 = load i16, i16* %162
%164 = getelementptr inbounds i16, i16* %60, i64 %161
store i16 %163, i16* %164
%165 = add nuw nsw i64 %153, 3
%166 = getelementptr inbounds i16, i16* %58, i64 %165
%167 = load i16, i16* %166
%168 = getelementptr inbounds i16, i16* %60, i64 %165
store i16 %167, i16* %168
%169 = add nuw nsw i64 %153, 4
%170 = icmp eq i64 %169, %11
br i1 %170, label %171, label %152
171: ; preds = %149, %152, %135, %54
%172 = add nuw nsw i64 %55, 1
%173 = icmp eq i64 %172, %10
br i1 %173, label %174, label %54
174: ; preds = %171, %38
%175 = getelementptr inbounds [256 x i64], [256 x i64]* %15, i64 0, i64 0
%176 = call i32 (i64*, i32, ...) bitcast (i32 (...)* @zero_histogram to i32 (i64*, i32, ...)*)(i64* %175, i32 256)
%177 = call i32 (i16**, i64*, i64, i64, ...) bitcast (i32 (...)* @calculate_histogram to i32 (i16**, i64*, i64, i64, ...)*)(i16** %1, i64* %175, i64 %10, i64 %11)
%178 = fpext float %16 to double
%179 = call i32 (i64*, double, i16*, i64, i64, ...) bitcast (i32 (...)* @find_cutoff_point to i32 (i64*, double, i16*, i64, i64, ...)*)(i64* %175, double %178, i16* %14, i64 %10, i64 %11)
%180 = load i16, i16* %14
%181 = sext i16 %180 to i32
%182 = shl i32 %8, 16
%183 = ashr exact i32 %182, 16
%184 = call i32 (i16**, i16**, i32, i32, i32, i64, i64, ...) bitcast (i32 (...)* @threshold_image_array to i32 (i16**, i16**, i32, i32, i32, i64, i64, ...)*)(i16** %1, i16** %2, i32 255, i32 %181, i32 %183, i64 %10, i64 %11)
%185 = shl i32 %9, 16
%186 = ashr exact i32 %185, 16
%187 = icmp eq i32 %185, 0
br i1 %187, label %325, label %188
188: ; preds = %174
br i1 %39, label %189, label %323
189: ; preds = %188
%190 = icmp sgt i64 %11, 0
%191 = add i64 %11, -16
%192 = lshr i64 %191, 4
%193 = add nuw nsw i64 %192, 1
%194 = icmp ult i64 %11, 16
%195 = and i64 %11, -16
%196 = and i64 %193, 3
%197 = icmp ult i64 %191, 48
%198 = and i64 %193, 2305843009213693948
%199 = icmp eq i64 %196, 0
%200 = icmp eq i64 %195, %11
%201 = and i64 %11, 3
%202 = icmp eq i64 %201, 0
br label %203
203: ; preds = %189, %320
%204 = phi i64 [ 0, %189 ], [ %321, %320 ]
br i1 %190, label %205, label %320
205: ; preds = %203
%206 = getelementptr inbounds i16*, i16** %2, i64 %204
%207 = load i16*, i16** %206
%208 = getelementptr inbounds i16*, i16** %1, i64 %204
%209 = load i16*, i16** %208
br i1 %194, label %285, label %210
210: ; preds = %205
%211 = getelementptr i16, i16* %209, i64 %11
%212 = getelementptr i16, i16* %207, i64 %11
%213 = icmp ult i16* %209, %212
%214 = icmp ult i16* %207, %211
%215 = and i1 %213, %214
br i1 %215, label %285, label %216
216: ; preds = %210
br i1 %197, label %266, label %217
217: ; preds = %216, %217
%218 = phi i64 [ %263, %217 ], [ 0, %216 ]
%219 = phi i64 [ %264, %217 ], [ 0, %216 ]
%220 = getelementptr inbounds i16, i16* %207, i64 %218
%221 = bitcast i16* %220 to <8 x i16>*
%222 = load <8 x i16>, <8 x i16>* %221
%223 = getelementptr inbounds i16, i16* %220, i64 8
%224 = bitcast i16* %223 to <8 x i16>*
%225 = load <8 x i16>, <8 x i16>* %224
%226 = getelementptr inbounds i16, i16* %209, i64 %218
%227 = bitcast i16* %226 to <8 x i16>*
store <8 x i16> %222, <8 x i16>* %227
%228 = getelementptr inbounds i16, i16* %226, i64 8
%229 = bitcast i16* %228 to <8 x i16>*
store <8 x i16> %225, <8 x i16>* %229
%230 = or i64 %218, 16
%231 = getelementptr inbounds i16, i16* %207, i64 %230
%232 = bitcast i16* %231 to <8 x i16>*
%233 = load <8 x i16>, <8 x i16>* %232
%234 = getelementptr inbounds i16, i16* %231, i64 8
%235 = bitcast i16* %234 to <8 x i16>*
%236 = load <8 x i16>, <8 x i16>* %235
%237 = getelementptr inbounds i16, i16* %209, i64 %230
%238 = bitcast i16* %237 to <8 x i16>*
store <8 x i16> %233, <8 x i16>* %238
%239 = getelementptr inbounds i16, i16* %237, i64 8
%240 = bitcast i16* %239 to <8 x i16>*
store <8 x i16> %236, <8 x i16>* %240
%241 = or i64 %218, 32
%242 = getelementptr inbounds i16, i16* %207, i64 %241
%243 = bitcast i16* %242 to <8 x i16>*
%244 = load <8 x i16>, <8 x i16>* %243
%245 = getelementptr inbounds i16, i16* %242, i64 8
%246 = bitcast i16* %245 to <8 x i16>*
%247 = load <8 x i16>, <8 x i16>* %246
%248 = getelementptr inbounds i16, i16* %209, i64 %241
%249 = bitcast i16* %248 to <8 x i16>*
store <8 x i16> %244, <8 x i16>* %249
%250 = getelementptr inbounds i16, i16* %248, i64 8
%251 = bitcast i16* %250 to <8 x i16>*
store <8 x i16> %247, <8 x i16>* %251
%252 = or i64 %218, 48
%253 = getelementptr inbounds i16, i16* %207, i64 %252
%254 = bitcast i16* %253 to <8 x i16>*
%255 = load <8 x i16>, <8 x i16>* %254
%256 = getelementptr inbounds i16, i16* %253, i64 8
%257 = bitcast i16* %256 to <8 x i16>*
%258 = load <8 x i16>, <8 x i16>* %257
%259 = getelementptr inbounds i16, i16* %209, i64 %252
%260 = bitcast i16* %259 to <8 x i16>*
store <8 x i16> %255, <8 x i16>* %260
%261 = getelementptr inbounds i16, i16* %259, i64 8
%262 = bitcast i16* %261 to <8 x i16>*
store <8 x i16> %258, <8 x i16>* %262
%263 = add nuw i64 %218, 64
%264 = add i64 %219, 4
%265 = icmp eq i64 %264, %198
br i1 %265, label %266, label %217
266: ; preds = %217, %216
%267 = phi i64 [ 0, %216 ], [ %263, %217 ]
br i1 %199, label %284, label %268
268: ; preds = %266, %268
%269 = phi i64 [ %281, %268 ], [ %267, %266 ]
%270 = phi i64 [ %282, %268 ], [ 0, %266 ]
%271 = getelementptr inbounds i16, i16* %207, i64 %269
%272 = bitcast i16* %271 to <8 x i16>*
%273 = load <8 x i16>, <8 x i16>* %272
%274 = getelementptr inbounds i16, i16* %271, i64 8
%275 = bitcast i16* %274 to <8 x i16>*
%276 = load <8 x i16>, <8 x i16>* %275
%277 = getelementptr inbounds i16, i16* %209, i64 %269
%278 = bitcast i16* %277 to <8 x i16>*
store <8 x i16> %273, <8 x i16>* %278
%279 = getelementptr inbounds i16, i16* %277, i64 8
%280 = bitcast i16* %279 to <8 x i16>*
store <8 x i16> %276, <8 x i16>* %280
%281 = add nuw i64 %269, 16
%282 = add i64 %270, 1
%283 = icmp eq i64 %282, %196
br i1 %283, label %284, label %268
284: ; preds = %268, %266
br i1 %200, label %320, label %285
285: ; preds = %210, %205, %284
%286 = phi i64 [ 0, %210 ], [ 0, %205 ], [ %195, %284 ]
%287 = xor i64 %286, -1
%288 = add i64 %287, %11
br i1 %202, label %298, label %289
289: ; preds = %285, %289
%290 = phi i64 [ %295, %289 ], [ %286, %285 ]
%291 = phi i64 [ %296, %289 ], [ 0, %285 ]
%292 = getelementptr inbounds i16, i16* %207, i64 %290
%293 = load i16, i16* %292
%294 = getelementptr inbounds i16, i16* %209, i64 %290
store i16 %293, i16* %294
%295 = add nuw nsw i64 %290, 1
%296 = add i64 %291, 1
%297 = icmp eq i64 %296, %201
br i1 %297, label %298, label %289
298: ; preds = %289, %285
%299 = phi i64 [ %286, %285 ], [ %295, %289 ]
%300 = icmp ult i64 %288, 3
br i1 %300, label %320, label %301
301: ; preds = %298, %301
%302 = phi i64 [ %318, %301 ], [ %299, %298 ]
%303 = getelementptr inbounds i16, i16* %207, i64 %302
%304 = load i16, i16* %303
%305 = getelementptr inbounds i16, i16* %209, i64 %302
store i16 %304, i16* %305
%306 = add nuw nsw i64 %302, 1
%307 = getelementptr inbounds i16, i16* %207, i64 %306
%308 = load i16, i16* %307
%309 = getelementptr inbounds i16, i16* %209, i64 %306
store i16 %308, i16* %309
%310 = add nuw nsw i64 %302, 2
%311 = getelementptr inbounds i16, i16* %207, i64 %310
%312 = load i16, i16* %311
%313 = getelementptr inbounds i16, i16* %209, i64 %310
store i16 %312, i16* %313
%314 = add nuw nsw i64 %302, 3
%315 = getelementptr inbounds i16, i16* %207, i64 %314
%316 = load i16, i16* %315
%317 = getelementptr inbounds i16, i16* %209, i64 %314
store i16 %316, i16* %317
%318 = add nuw nsw i64 %302, 4
%319 = icmp eq i64 %318, %11
br i1 %319, label %320, label %301
320: ; preds = %298, %301, %284, %203
%321 = add nuw nsw i64 %204, 1
%322 = icmp eq i64 %321, %10
br i1 %322, label %323, label %203
323: ; preds = %320, %188
%324 = call i32 (i16**, i16**, i32, i32, i64, i64, ...) bitcast (i32 (...)* @erode_image_array to i32 (i16**, i16**, i32, i32, i64, i64, ...)*)(i16** %1, i16** %2, i32 %183, i32 %186, i64 %10, i64 %11)
br label %325
325: ; preds = %323, %174
%326 = call i32 (i8*, i16**, ...) bitcast (i32 (...)* @read_image_array to i32 (i8*, i16**, ...)*)(i8* %0, i16** %1)
br i1 %39, label %327, label %375
327: ; preds = %325
%328 = icmp sgt i64 %11, 0
%329 = and i64 %11, 1
%330 = icmp eq i64 %11, 1
%331 = and i64 %11, -2
%332 = icmp eq i64 %329, 0
br label %333
333: ; preds = %327, %372
%334 = phi i64 [ 0, %327 ], [ %373, %372 ]
br i1 %328, label %335, label %372
335: ; preds = %333
%336 = getelementptr inbounds i16*, i16** %2, i64 %334
%337 = load i16*, i16** %336
%338 = getelementptr inbounds i16*, i16** %1, i64 %334
br i1 %330, label %362, label %339
339: ; preds = %335, %358
%340 = phi i64 [ %359, %358 ], [ 0, %335 ]
%341 = phi i64 [ %360, %358 ], [ 0, %335 ]
%342 = getelementptr inbounds i16, i16* %337, i64 %340
%343 = load i16, i16* %342
%344 = sext i16 %343 to i32
%345 = icmp eq i32 %183, %344
br i1 %345, label %346, label %349
346: ; preds = %339
%347 = load i16*, i16** %338
%348 = getelementptr inbounds i16, i16* %347, i64 %340
store i16 -50, i16* %348
br label %349
349: ; preds = %339, %346
%350 = or i64 %340, 1
%351 = getelementptr inbounds i16, i16* %337, i64 %350
%352 = load i16, i16* %351
%353 = sext i16 %352 to i32
%354 = icmp eq i32 %183, %353
br i1 %354, label %355, label %358
355: ; preds = %349
%356 = load i16*, i16** %338
%357 = getelementptr inbounds i16, i16* %356, i64 %350
store i16 -50, i16* %357
br label %358
358: ; preds = %355, %349
%359 = add nuw nsw i64 %340, 2
%360 = add i64 %341, 2
%361 = icmp eq i64 %360, %331
br i1 %361, label %362, label %339
362: ; preds = %358, %335
%363 = phi i64 [ 0, %335 ], [ %359, %358 ]
br i1 %332, label %372, label %364
364: ; preds = %362
%365 = getelementptr inbounds i16, i16* %337, i64 %363
%366 = load i16, i16* %365
%367 = sext i16 %366 to i32
%368 = icmp eq i32 %183, %367
br i1 %368, label %369, label %372
369: ; preds = %364
%370 = load i16*, i16** %338
%371 = getelementptr inbounds i16, i16* %370, i64 %363
store i16 -50, i16* %371
br label %372
372: ; preds = %362, %369, %364, %333
%373 = add nuw nsw i64 %334, 1
%374 = icmp eq i64 %373, %10
br i1 %374, label %375, label %333
375: ; preds = %372, %325
%376 = shl i32 %6, 16
%377 = ashr exact i32 %376, 16
%378 = shl i32 %4, 16
%379 = ashr exact i32 %378, 16
%380 = shl i32 %5, 16
%381 = ashr exact i32 %380, 16
%382 = call i32 (i16**, i16**, i32, i32, i32, i64, i64, ...) bitcast (i32 (...)* @pixel_grow to i32 (i16**, i16**, i32, i32, i32, i64, i64, ...)*)(i16** %1, i16** %2, i32 %377, i32 %379, i32 %381, i64 %10, i64 %11)
ret i32 1
}