#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ ccdfs(int *, int, float *, float *, float *, int);
int find_connected_components(int a[], float rs[], float cs[], float ss[],
                              int n) {
  int i, ncc, cc;
  if (!n)
    return 0;
  for (i = 0; i < n; ++i)
    a[i] = 0;
  ncc = 0;
  cc = 1;
  for (i = 0; i < n; ++i)
    if (a[i] == 0) {
      a[i] = cc;
      ccdfs(a, i, rs, cs, ss, n);
      ++ncc;
      ++cc;
    }
  return ncc;
}


x86 assembly (clang, -O0):
<find_connected_components>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    1142 <find_connected_components+0x32>
movl   $0x0,-0x4(%rbp)
jmp    11fa <find_connected_components+0xea>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1172 <find_connected_components+0x62>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1149 <find_connected_components+0x39>
movl   $0x0,-0x34(%rbp)
movl   $0x1,-0x38(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11f4 <find_connected_components+0xe4>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    11e1 <find_connected_components+0xd1>
mov    -0x38(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x2c(%rbp),%r9d
call   1030 <ccdfs@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11e6 <find_connected_components+0xd6>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1187 <find_connected_components+0x77>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_connected_components>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,0x10(%rsp)
mov    %rdx,0x8(%rsp)
test   %r8d,%r8d
jle    11a7 <find_connected_components+0x87>
mov    %rsi,%r12
mov    %rdi,%rbx
mov    %r8d,%r13d
lea    0x0(,%r13,4),%rdx
xor    %ebp,%ebp
xor    %esi,%esi
call   1040 <memset@plt>
mov    $0x1,%r15d
xor    %r14d,%r14d
jmp    1179 <find_connected_components+0x59>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbp
cmp    %rbp,%r13
je     11aa <find_connected_components+0x8a>
cmpl   $0x0,(%rbx,%rbp,4)
jne    1170 <find_connected_components+0x50>
mov    %r15d,(%rbx,%rbp,4)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r12,%rdx
mov    0x8(%rsp),%rcx
mov    0x10(%rsp),%r8
mov    %r13d,%r9d
call   1030 <ccdfs@plt>
add    $0x1,%r14d
add    $0x1,%r15d
jmp    1170 <find_connected_components+0x50>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @find_connected_components(i32* %0, float* %1, float* %2, float* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca float*
%9 = alloca float*
%10 = alloca float*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32* %0, i32** %7
store float* %1, float** %8
store float* %2, float** %9
store float* %3, float** %10
store i32 %4, i32* %11
%15 = load i32, i32* %11
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %5
store i32 0, i32* %6
br label %66
18: ; preds = %5
store i32 0, i32* %12
br label %19
19: ; preds = %28, %18
%20 = load i32, i32* %12
%21 = load i32, i32* %11
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %31
23: ; preds = %19
%24 = load i32*, i32** %7
%25 = load i32, i32* %12
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
store i32 0, i32* %27
br label %28
28: ; preds = %23
%29 = load i32, i32* %12
%30 = add nsw i32 %29, 1
store i32 %30, i32* %12
br label %19
31: ; preds = %19
store i32 0, i32* %13
store i32 1, i32* %14
store i32 0, i32* %12
br label %32
32: ; preds = %61, %31
%33 = load i32, i32* %12
%34 = load i32, i32* %11
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %64
36: ; preds = %32
%37 = load i32*, i32** %7
%38 = load i32, i32* %12
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %37, i64 %39
%41 = load i32, i32* %40
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %60
43: ; preds = %36
%44 = load i32, i32* %14
%45 = load i32*, i32** %7
%46 = load i32, i32* %12
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %45, i64 %47
store i32 %44, i32* %48
%49 = load i32*, i32** %7
%50 = load i32, i32* %12
%51 = load float*, float** %8
%52 = load float*, float** %9
%53 = load float*, float** %10
%54 = load i32, i32* %11
%55 = call i32 @ccdfs(i32* %49, i32 %50, float* %51, float* %52, float* %53, i32 %54)
%56 = load i32, i32* %13
%57 = add nsw i32 %56, 1
store i32 %57, i32* %13
%58 = load i32, i32* %14
%59 = add nsw i32 %58, 1
store i32 %59, i32* %14
br label %60
60: ; preds = %43, %36
br label %61
61: ; preds = %60
%62 = load i32, i32* %12
%63 = add nsw i32 %62, 1
store i32 %63, i32* %12
br label %32
64: ; preds = %32
%65 = load i32, i32* %13
store i32 %65, i32* %6
br label %66
66: ; preds = %64, %17
%67 = load i32, i32* %6
ret i32 %67
}

LLVM IR (-O2):
define i32 @find_connected_components(i32* %0, float* %1, float* %2, float* %3, i32 %4) {
%6 = icmp sgt i32 %4, 0
br i1 %6, label %7, label %29
7: ; preds = %5
%8 = bitcast i32* %0 to i8*
%9 = zext i32 %4 to i64
%10 = shl nuw nsw i64 %9, 2
%11 = zext i32 %4 to i64
br label %12
12: ; preds = %7, %24
%13 = phi i64 [ 0, %7 ], [ %27, %24 ]
%14 = phi i32 [ 1, %7 ], [ %26, %24 ]
%15 = phi i32 [ 0, %7 ], [ %25, %24 ]
%16 = getelementptr inbounds i32, i32* %0, i64 %13
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %12
store i32 %14, i32* %16
%20 = trunc i64 %13 to i32
%21 = tail call i32 @ccdfs(i32* %0, i32 %20, float* %1, float* %2, float* %3, i32 %4)
%22 = add nsw i32 %15, 1
%23 = add nsw i32 %14, 1
br label %24
24: ; preds = %12, %19
%25 = phi i32 [ %22, %19 ], [ %15, %12 ]
%26 = phi i32 [ %23, %19 ], [ %14, %12 ]
%27 = add nuw nsw i64 %13, 1
%28 = icmp eq i64 %27, %11
br i1 %28, label %29, label %12
29: ; preds = %24, %5
%30 = phi i32 [ 0, %5 ], [ %25, %24 ]
ret i32 %30
}