void remove_connected(float *b, int *lib, int p, int r, int c) {
  if (r < 0 || r >= 19 || c < 0 || c >= 19)
    return;
  if (b[r * 19 + c] != p)
    return;
  if (lib[r * 19 + c] != 1)
    return;
  b[r * 19 + c] = 0;
  remove_connected(b, lib, p, r + 1, c);
  remove_connected(b, lib, p, r - 1, c);
  remove_connected(b, lib, p, r, c + 1);
  remove_connected(b, lib, p, r, c - 1);
}


x86 assembly (clang, -O0):
<remove_connected>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     1152 <remove_connected+0x42>
cmpl   $0x13,-0x18(%rbp)
jge    1152 <remove_connected+0x42>
cmpl   $0x0,-0x1c(%rbp)
jl     1152 <remove_connected+0x42>
cmpl   $0x13,-0x1c(%rbp)
jl     1157 <remove_connected+0x47>
jmp    1225 <remove_connected+0x115>
mov    -0x8(%rbp),%rax
imul   $0x13,-0x18(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
cvtsi2ssl -0x14(%rbp),%xmm1
ucomiss %xmm1,%xmm0
jne    1183 <remove_connected+0x73>
jp     1183 <remove_connected+0x73>
jmp    1188 <remove_connected+0x78>
jmp    1225 <remove_connected+0x115>
mov    -0x10(%rbp),%rax
imul   $0x13,-0x18(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
cmpl   $0x1,(%rax,%rcx,4)
je     11a5 <remove_connected+0x95>
jmp    1225 <remove_connected+0x115>
mov    -0x8(%rbp),%rax
imul   $0x13,-0x18(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
mov    -0x1c(%rbp),%r8d
call   1030 <remove_connected@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x1c(%rbp),%r8d
call   1030 <remove_connected@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
add    $0x1,%r8d
call   1030 <remove_connected@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
sub    $0x1,%r8d
call   1030 <remove_connected@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_connected>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x12,%ecx
ja     11d9 <remove_connected+0xc9>
mov    %r8d,%ebx
cmp    $0x12,%r8d
ja     11d9 <remove_connected+0xc9>
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %rsi,%r12
mov    %rdi,%rbp
cvtsi2ss %edx,%xmm0
movss  %xmm0,0x14(%rsp)
lea    (%r14,%r14,8),%eax
lea    (%r14,%rax,2),%r13d
lea    0x1(%r14),%eax
mov    %eax,0x10(%rsp)
lea    -0x1(%r14),%eax
mov    %eax,0xc(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    (%rbx,%r13,1),%eax
movss  0x0(%rbp,%rax,4),%xmm0
ucomiss 0x14(%rsp),%xmm0
jne    11d9 <remove_connected+0xc9>
jp     11d9 <remove_connected+0xc9>
cmpl   $0x1,(%r12,%rax,4)
jne    11d9 <remove_connected+0xc9>
movl   $0x0,0x0(%rbp,%rax,4)
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
mov    0x10(%rsp),%ecx
mov    %ebx,%r8d
call   1030 <remove_connected@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
mov    0xc(%rsp),%ecx
mov    %ebx,%r8d
call   1030 <remove_connected@plt>
lea    0x1(%rbx),%r8d
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
mov    %r14d,%ecx
call   1030 <remove_connected@plt>
add    $0xffffffff,%ebx
cmp    $0x13,%ebx
jb     1170 <remove_connected+0x60>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @remove_connected(float* %0, i32* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca float*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store float* %0, float** %6
store i32* %1, i32** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i32, i32* %9
%12 = icmp slt i32 %11, 0
br i1 %12, label %22, label %13
13: ; preds = %5
%14 = load i32, i32* %9
%15 = icmp sge i32 %14, 19
br i1 %15, label %22, label %16
16: ; preds = %13
%17 = load i32, i32* %10
%18 = icmp slt i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load i32, i32* %10
%21 = icmp sge i32 %20, 19
br i1 %21, label %22, label %23
22: ; preds = %19, %16, %13, %5
br label %79
23: ; preds = %19
%24 = load float*, float** %6
%25 = load i32, i32* %9
%26 = mul nsw i32 %25, 19
%27 = load i32, i32* %10
%28 = add nsw i32 %26, %27
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds float, float* %24, i64 %29
%31 = load float, float* %30
%32 = load i32, i32* %8
%33 = sitofp i32 %32 to float
%34 = fcmp une float %31, %33
br i1 %34, label %35, label %36
35: ; preds = %23
br label %79
36: ; preds = %23
%37 = load i32*, i32** %7
%38 = load i32, i32* %9
%39 = mul nsw i32 %38, 19
%40 = load i32, i32* %10
%41 = add nsw i32 %39, %40
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %37, i64 %42
%44 = load i32, i32* %43
%45 = icmp ne i32 %44, 1
br i1 %45, label %46, label %47
46: ; preds = %36
br label %79
47: ; preds = %36
%48 = load float*, float** %6
%49 = load i32, i32* %9
%50 = mul nsw i32 %49, 19
%51 = load i32, i32* %10
%52 = add nsw i32 %50, %51
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds float, float* %48, i64 %53
store float 0.000000e+00, float* %54
%55 = load float*, float** %6
%56 = load i32*, i32** %7
%57 = load i32, i32* %8
%58 = load i32, i32* %9
%59 = add nsw i32 %58, 1
%60 = load i32, i32* %10
%61 = load float*, float** %6
%62 = load i32*, i32** %7
%63 = load i32, i32* %8
%64 = load i32, i32* %9
%65 = sub nsw i32 %64, 1
%66 = load i32, i32* %10
%67 = load float*, float** %6
%68 = load i32*, i32** %7
%69 = load i32, i32* %8
%70 = load i32, i32* %9
%71 = load i32, i32* %10
%72 = add nsw i32 %71, 1
%73 = load float*, float** %6
%74 = load i32*, i32** %7
%75 = load i32, i32* %8
%76 = load i32, i32* %9
%77 = load i32, i32* %10
%78 = sub nsw i32 %77, 1
br label %79
79: ; preds = %47, %46, %35, %22
ret void
}

LLVM IR (-O2):
define void @remove_connected(float* %0, i32* %1, i32 %2, i32 %3, i32 %4) {
%6 = mul nuw nsw i32 %3, 19
%7 = icmp ugt i32 %3, 18
%8 = icmp ugt i32 %4, 18
%9 = or i1 %7, %8
br i1 %9, label %29, label %10
10: ; preds = %5
%11 = sitofp i32 %2 to float
%12 = add nuw nsw i32 %3, 1
%13 = add nsw i32 %3, -1
br label %14
14: ; preds = %10, %25
%15 = phi i32 [ %4, %10 ], [ %27, %25 ]
%16 = add nuw nsw i32 %15, %6
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds float, float* %0, i64 %17
%19 = load float, float* %18
%20 = fcmp une float %19, %11
br i1 %20, label %29, label %21
21: ; preds = %14
%22 = getelementptr inbounds i32, i32* %1, i64 %17
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %29
25: ; preds = %21
store float 0.000000e+00, float* %18
tail call void @remove_connected(float* %0, i32* %1, i32 %2, i32 %12, i32 %15)
tail call void @remove_connected(float* %0, i32* %1, i32 %2, i32 %13, i32 %15)
%26 = add nuw nsw i32 %15, 1
tail call void @remove_connected(float* %0, i32* %1, i32 %2, i32 %3, i32 %26)
%27 = add nsw i32 %15, -1
%28 = icmp ugt i32 %27, 18
br i1 %28, label %29, label %14
29: ; preds = %25, %14, %21, %5
ret void
}