int floodfill(char *fill, unsigned short *pic, int w, int h, int x, int y,
              int threshold, double *cx, double *cy, double *sqx, double *sqy,
              double *xy, double *weight) {
  if (pic[x + w * y] <= threshold || fill[x + w * y])
    return 0;
  int cnt = 1;
  fill[x + w * y] = 1;
  double pw = ((double)pic[x + w * y] - threshold);
  *cx += (double)x * pw;
  *cy += (double)y * pw;
  *sqx += (double)x * (double)x * pw;
  *sqy += (double)y * (double)y * pw;
  *xy += (double)x * (double)y * pw;
  *weight += pw;
  if (x < w - 1)
    cnt += floodfill(fill, pic, w, h, x + 1, y, threshold, cx, cy, sqx, sqy, xy,
                     weight);
  if (x > 0)
    cnt += floodfill(fill, pic, w, h, x - 1, y, threshold, cx, cy, sqx, sqy, xy,
                     weight);
  if (y > 0)
    cnt += floodfill(fill, pic, w, h, x, y - 1, threshold, cx, cy, sqx, sqy, xy,
                     weight);
  if (y < h - 1)
    cnt += floodfill(fill, pic, w, h, x, y + 1, threshold, cx, cy, sqx, sqy, xy,
                     weight);
  return cnt;
}


x86 assembly (clang, -O0):
<floodfill>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x70,%rsp
mov    0x40(%rbp),%rax
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %rdi,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
mov    %edx,-0x3c(%rbp)
mov    %ecx,-0x40(%rbp)
mov    %r8d,-0x44(%rbp)
mov    %r9d,-0x48(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x44(%rbp),%ecx
mov    -0x3c(%rbp),%edx
imul   -0x48(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movzwl (%rax,%rcx,2),%eax
cmp    0x10(%rbp),%eax
jle    1190 <floodfill+0x80>
mov    -0x30(%rbp),%rax
mov    -0x44(%rbp),%ecx
mov    -0x3c(%rbp),%edx
imul   -0x48(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     119c <floodfill+0x8c>
movl   $0x0,-0x24(%rbp)
jmp    1471 <floodfill+0x361>
movl   $0x1,-0x4c(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x44(%rbp),%ecx
mov    -0x3c(%rbp),%edx
mov    -0x48(%rbp),%esi
imul   %esi,%edx
add    %edx,%ecx
movslq %ecx,%rcx
movb   $0x1,(%rax,%rcx,1)
mov    -0x38(%rbp),%rax
mov    -0x44(%rbp),%ecx
mov    -0x3c(%rbp),%edx
mov    -0x48(%rbp),%esi
imul   %esi,%edx
add    %edx,%ecx
movslq %ecx,%rcx
movzwl (%rax,%rcx,2),%eax
cvtsi2sd %eax,%xmm0
cvtsi2sdl 0x10(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
cvtsi2sdl -0x44(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
mov    0x18(%rbp),%rax
movsd  (%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
cvtsi2sdl -0x48(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
mov    0x20(%rbp),%rax
movsd  (%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
cvtsi2sdl -0x44(%rbp),%xmm0
cvtsi2sdl -0x44(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x58(%rbp),%xmm2
mov    0x28(%rbp),%rax
movsd  (%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
cvtsi2sdl -0x48(%rbp),%xmm0
cvtsi2sdl -0x48(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x58(%rbp),%xmm2
mov    0x30(%rbp),%rax
movsd  (%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
cvtsi2sdl -0x44(%rbp),%xmm0
cvtsi2sdl -0x48(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x58(%rbp),%xmm2
mov    0x38(%rbp),%rax
movsd  (%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
movsd  -0x58(%rbp),%xmm0
mov    0x40(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x44(%rbp),%eax
mov    -0x3c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    131d <floodfill+0x20d>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x3c(%rbp),%edx
mov    -0x40(%rbp),%ecx
mov    -0x44(%rbp),%r8d
add    $0x1,%r8d
mov    -0x48(%rbp),%r9d
mov    0x10(%rbp),%r12d
mov    0x18(%rbp),%r15
mov    0x20(%rbp),%r14
mov    0x28(%rbp),%rbx
mov    0x30(%rbp),%r11
mov    0x38(%rbp),%r10
mov    0x40(%rbp),%rax
mov    %r12d,(%rsp)
mov    %r15,0x8(%rsp)
mov    %r14,0x10(%rsp)
mov    %rbx,0x18(%rsp)
mov    %r11,0x20(%rsp)
mov    %r10,0x28(%rsp)
mov    %rax,0x30(%rsp)
call   1030 <floodfill@plt>
add    -0x4c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x44(%rbp)
jle    138a <floodfill+0x27a>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x3c(%rbp),%edx
mov    -0x40(%rbp),%ecx
mov    -0x44(%rbp),%r8d
sub    $0x1,%r8d
mov    -0x48(%rbp),%r9d
mov    0x10(%rbp),%r12d
mov    0x18(%rbp),%r15
mov    0x20(%rbp),%r14
mov    0x28(%rbp),%rbx
mov    0x30(%rbp),%r11
mov    0x38(%rbp),%r10
mov    0x40(%rbp),%rax
mov    %r12d,(%rsp)
mov    %r15,0x8(%rsp)
mov    %r14,0x10(%rsp)
mov    %rbx,0x18(%rsp)
mov    %r11,0x20(%rsp)
mov    %r10,0x28(%rsp)
mov    %rax,0x30(%rsp)
call   1030 <floodfill@plt>
add    -0x4c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x48(%rbp)
jle    13f7 <floodfill+0x2e7>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x3c(%rbp),%edx
mov    -0x40(%rbp),%ecx
mov    -0x44(%rbp),%r8d
mov    -0x48(%rbp),%r9d
sub    $0x1,%r9d
mov    0x10(%rbp),%r12d
mov    0x18(%rbp),%r15
mov    0x20(%rbp),%r14
mov    0x28(%rbp),%rbx
mov    0x30(%rbp),%r11
mov    0x38(%rbp),%r10
mov    0x40(%rbp),%rax
mov    %r12d,(%rsp)
mov    %r15,0x8(%rsp)
mov    %r14,0x10(%rsp)
mov    %rbx,0x18(%rsp)
mov    %r11,0x20(%rsp)
mov    %r10,0x28(%rsp)
mov    %rax,0x30(%rsp)
call   1030 <floodfill@plt>
add    -0x4c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%eax
mov    -0x40(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    146b <floodfill+0x35b>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x3c(%rbp),%edx
mov    -0x40(%rbp),%ecx
mov    -0x44(%rbp),%r8d
mov    -0x48(%rbp),%r9d
add    $0x1,%r9d
mov    0x10(%rbp),%r12d
mov    0x18(%rbp),%r15
mov    0x20(%rbp),%r14
mov    0x28(%rbp),%rbx
mov    0x30(%rbp),%r11
mov    0x38(%rbp),%r10
mov    0x40(%rbp),%rax
mov    %r12d,(%rsp)
mov    %r15,0x8(%rsp)
mov    %r14,0x10(%rsp)
mov    %rbx,0x18(%rsp)
mov    %r11,0x20(%rsp)
mov    %r10,0x28(%rsp)
mov    %rax,0x30(%rsp)
call   1030 <floodfill@plt>
add    -0x4c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<floodfill>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %r8d,%r13d
mov    0xd0(%rsp),%ebp
mov    %r9d,%eax
imul   %edx,%eax
add    %r8d,%eax
cltq
movzwl (%rsi,%rax,2),%r8d
xor    %ebx,%ebx
cmp    %ebp,%r8d
jle    1481 <floodfill+0x371>
cvtsi2sd %ebp,%xmm0
movsd  %xmm0,0x80(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r13d,%xmm0
mov    %rdx,%rbp
lea    (%rsi,%rax,2),%r10
movsd  %xmm0,0x78(%rsp)
mulsd  %xmm0,%xmm0
movsd  %xmm0,0x70(%rsp)
add    $0xffffffff,%edx
mov    %edx,0x3c(%rsp)
lea    0x1(%r13),%edx
mov    %edx,0x34(%rsp)
lea    -0x1(%r13),%edx
mov    %edx,0x38(%rsp)
mov    %rcx,0x18(%rsp)
lea    -0x1(%rcx),%edx
movslq %r9d,%rcx
mov    %rbp,0x88(%rsp)
movslq %ebp,%r11
movslq %r13d,%r8
cmp    %edx,%ecx
cmovg  %r9d,%edx
movslq %edx,%rbx
lea    0x1(%rcx),%rdx
imul   %r11,%rdx
add    %r8,%rdx
lea    -0x1(%rcx),%ebp
mov    %rbp,0x40(%rsp)
sub    %rcx,%rbx
mov    %rbx,0x60(%rsp)
mov    %rcx,0x68(%rsp)
mov    %ecx,%ecx
mov    %rcx,0x58(%rsp)
mov    %rsi,0x10(%rsp)
lea    (%rsi,%rdx,2),%rsi
mov    %r11,0x50(%rsp)
lea    (%r11,%r11,1),%rcx
mov    %rcx,0x48(%rsp)
xor    %r12d,%r12d
xor    %ebx,%ebx
mov    %rdi,0x28(%rsp)
mov    %r13,0x20(%rsp)
nopl   0x0(%rax,%rax,1)
cmpb   $0x0,(%rdi,%rax,1)
jne    1474 <floodfill+0x364>
mov    %rsi,%r15
mov    %rdx,0x90(%rsp)
mov    %ebx,0xc(%rsp)
mov    0x58(%rsp),%rcx
lea    (%rcx,%r12,1),%rbp
movb   $0x1,(%rdi,%rax,1)
movzwl (%r10),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
subsd  0x80(%rsp),%xmm0
movsd  0x78(%rsp),%xmm3
movapd %xmm3,%xmm1
mulsd  %xmm0,%xmm1
mov    0xd8(%rsp),%rax
addsd  (%rax),%xmm1
movsd  %xmm1,(%rax)
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
movapd %xmm1,%xmm2
mulsd  %xmm0,%xmm2
mov    0xe0(%rsp),%rax
addsd  (%rax),%xmm2
movsd  %xmm2,(%rax)
movsd  0x70(%rsp),%xmm2
mulsd  %xmm0,%xmm2
mov    0xe8(%rsp),%rax
addsd  (%rax),%xmm2
movsd  %xmm2,(%rax)
movapd %xmm3,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm1
mov    0xf0(%rsp),%rax
addsd  (%rax),%xmm1
movsd  %xmm1,(%rax)
mulsd  %xmm0,%xmm2
mov    0xf8(%rsp),%rax
addsd  (%rax),%xmm2
movsd  %xmm2,(%rax)
mov    0x100(%rsp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    $0x1,%r14d
cmp    %r13d,0x3c(%rsp)
mov    0x88(%rsp),%rbx
jle    1349 <floodfill+0x239>
sub    $0x8,%rsp
mov    0x18(%rsp),%rsi
mov    %ebx,%edx
mov    0x20(%rsp),%rcx
mov    0x3c(%rsp),%r8d
mov    %ebp,%r9d
push   0x108(%rsp)
push   0x108(%rsp)
push   0x108(%rsp)
push   0x108(%rsp)
push   0x108(%rsp)
push   0x108(%rsp)
mov    0x108(%rsp),%eax
push   %rax
call   1030 <floodfill@plt>
mov    0x68(%rsp),%rdi
add    $0x40,%rsp
mov    %eax,%r14d
add    $0x1,%r14d
mov    0x68(%rsp),%rax
lea    (%rax,%r12,1),%r13
cmpl   $0x0,0x20(%rsp)
jle    1420 <floodfill+0x310>
sub    $0x8,%rsp
mov    0x18(%rsp),%rsi
mov    %ebx,%edx
mov    0x20(%rsp),%rcx
mov    0x40(%rsp),%r8d
mov    %ebp,%r9d
push   0x108(%rsp)
push   0x108(%rsp)
push   0x108(%rsp)
push   0x108(%rsp)
push   0x108(%rsp)
push   0x108(%rsp)
mov    0x108(%rsp),%ebp
push   %rbp
call   1030 <floodfill@plt>
add    $0x40,%rsp
add    %eax,%r14d
test   %r13,%r13
jle    142c <floodfill+0x31c>
mov    0x40(%rsp),%rax
lea    (%rax,%r12,1),%r9d
sub    $0x8,%rsp
mov    0x30(%rsp),%rdi
mov    0x18(%rsp),%rsi
mov    %ebx,%edx
mov    0x20(%rsp),%rcx
mov    0x28(%rsp),%r13
mov    %r13d,%r8d
push   0x108(%rsp)
push   0x108(%rsp)
push   0x108(%rsp)
push   0x108(%rsp)
push   0x108(%rsp)
push   0x108(%rsp)
push   %rbp
call   1030 <floodfill@plt>
add    $0x40,%rsp
add    %eax,%r14d
cmp    %r12,0x60(%rsp)
jne    1438 <floodfill+0x328>
jmp    1478 <floodfill+0x368>
xchg   %ax,%ax
mov    0xd0(%rsp),%ebp
test   %r13,%r13
jg     13b8 <floodfill+0x2a8>
mov    0x20(%rsp),%r13
cmp    %r12,0x60(%rsp)
je     1478 <floodfill+0x368>
mov    0xc(%rsp),%ebx
add    %r14d,%ebx
movzwl (%r15),%edi
add    $0x1,%r12
mov    0x48(%rsp),%rax
lea    (%r15,%rax,1),%rsi
mov    0x50(%rsp),%rax
mov    0x90(%rsp),%rcx
lea    (%rcx,%rax,1),%rdx
mov    %r15,%r10
mov    %rcx,%rax
cmp    %ebp,%edi
mov    0x28(%rsp),%rdi
jg     1200 <floodfill+0xf0>
xor    %eax,%eax
jmp    147f <floodfill+0x36f>
mov    %r14d,%eax
mov    0xc(%rsp),%ebx
add    %eax,%ebx
mov    %ebx,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @floodfill(i8* %0, i16* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, double* %7, double* %8, double* %9, double* %10, double* %11, double* %12) {
%14 = mul nsw i32 %5, %2
%15 = add nsw i32 %14, %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i16, i16* %1, i64 %16
%18 = load i16, i16* %17
%19 = zext i16 %18 to i32
%20 = icmp sgt i32 %19, %6
br i1 %20, label %21, label %96
21: ; preds = %13
%22 = sitofp i32 %6 to double
%23 = sitofp i32 %4 to double
%24 = fmul double %23, %23
%25 = add nsw i32 %2, -1
%26 = icmp sgt i32 %25, %4
%27 = add nsw i32 %4, 1
%28 = icmp sgt i32 %4, 0
%29 = add nsw i32 %4, -1
%30 = add i32 %3, -1
%31 = sext i32 %5 to i64
%32 = sext i32 %2 to i64
%33 = sext i32 %4 to i64
%34 = call i32 @llvm.smax.i32(i32 %5, i32 %30)
%35 = sext i32 %34 to i64
br label %36
36: ; preds = %21, %83
%37 = phi i64 [ %31, %21 ], [ %84, %83 ]
%38 = phi i16* [ %17, %21 ], [ %88, %83 ]
%39 = phi i64 [ %16, %21 ], [ %87, %83 ]
%40 = phi i32 [ 0, %21 ], [ %85, %83 ]
%41 = getelementptr inbounds i8, i8* %0, i64 %39
%42 = load i8, i8* %41
%43 = icmp eq i8 %42, 0
br i1 %43, label %44, label %92
44: ; preds = %36
store i8 1, i8* %41
%45 = load i16, i16* %38
%46 = uitofp i16 %45 to double
%47 = fsub double %46, %22
%48 = load double, double* %7
%49 = tail call double @llvm.fmuladd.f64(double %23, double %47, double %48)
store double %49, double* %7
%50 = trunc i64 %37 to i32
%51 = sitofp i32 %50 to double
%52 = load double, double* %8
%53 = tail call double @llvm.fmuladd.f64(double %51, double %47, double %52)
store double %53, double* %8
%54 = load double, double* %9
%55 = tail call double @llvm.fmuladd.f64(double %24, double %47, double %54)
store double %55, double* %9
%56 = fmul double %51, %51
%57 = load double, double* %10
%58 = tail call double @llvm.fmuladd.f64(double %56, double %47, double %57)
store double %58, double* %10
%59 = fmul double %23, %51
%60 = load double, double* %11
%61 = tail call double @llvm.fmuladd.f64(double %59, double %47, double %60)
store double %61, double* %11
%62 = load double, double* %12
%63 = fadd double %47, %62
store double %63, double* %12
br i1 %26, label %64, label %67
64: ; preds = %44
%65 = tail call i32 @floodfill(i8* %0, i16* %1, i32 %2, i32 %3, i32 %27, i32 %50, i32 %6, double* %7, double* %8, double* %9, double* %10, double* %11, double* %12)
%66 = add nsw i32 %65, 1
br label %67
67: ; preds = %64, %44
%68 = phi i32 [ %66, %64 ], [ 1, %44 ]
br i1 %28, label %69, label %72
69: ; preds = %67
%70 = tail call i32 @floodfill(i8* %0, i16* %1, i32 %2, i32 %3, i32 %29, i32 %50, i32 %6, double* %7, double* %8, double* %9, double* %10, double* %11, double* %12)
%71 = add nsw i32 %70, %68
br label %72
72: ; preds = %69, %67
%73 = phi i32 [ %71, %69 ], [ %68, %67 ]
%74 = icmp sgt i64 %37, 0
br i1 %74, label %75, label %80
75: ; preds = %72
%76 = trunc i64 %37 to i32
%77 = add i32 %76, -1
%78 = tail call i32 @floodfill(i8* %0, i16* %1, i32 %2, i32 %3, i32 %4, i32 %77, i32 %6, double* %7, double* %8, double* %9, double* %10, double* %11, double* %12)
%79 = add nsw i32 %78, %73
br label %80
80: ; preds = %75, %72
%81 = phi i32 [ %79, %75 ], [ %73, %72 ]
%82 = icmp eq i64 %37, %35
br i1 %82, label %92, label %83
83: ; preds = %80
%84 = add nsw i64 %37, 1
%85 = add nsw i32 %81, %40
%86 = mul nsw i64 %84, %32
%87 = add nsw i64 %86, %33
%88 = getelementptr inbounds i16, i16* %1, i64 %87
%89 = load i16, i16* %88
%90 = zext i16 %89 to i32
%91 = icmp sgt i32 %90, %6
br i1 %91, label %36, label %92
92: ; preds = %80, %83, %36
%93 = phi i32 [ %40, %36 ], [ %85, %83 ], [ %40, %80 ]
%94 = phi i32 [ 0, %36 ], [ 0, %83 ], [ %81, %80 ]
%95 = add nsw i32 %94, %93
br label %96
96: ; preds = %92, %13
%97 = phi i32 [ %95, %92 ], [ 0, %13 ]
ret i32 %97
}