#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 */
struct vtx_data {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ bfsearch(struct vtx_data **, int, int *, int *, int *, int);
int find_comps(struct vtx_data **graph, int nvtxs, int *mark, int *vtxlist) {
  int root;
  int count;
  int ncomps;
  int i;
  double drandom();
  for (i = 1; i <= nvtxs; i++) {
    mark[i] = -1;
  }
  count = 0;
  ncomps = 0;
  root = nvtxs * drandom() + 1;
  bfsearch(graph, root, &count, mark, vtxlist, ncomps);
  while (count != nvtxs) {
    root = nvtxs * drandom() + 1;
    while (mark[root] >= 0) {
      root++;
      if (root > nvtxs) {
        root = 1;
      }
    }
    ncomps++;
    bfsearch(graph, root, &count, mark, vtxlist, ncomps);
  }
  return (ncomps + 1);
}


x86 assembly (clang, -O0):
<find_comps>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1167 <find_comps+0x47>
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    113e <find_comps+0x1e>
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    $0x0,%al
call   1040 <drandom@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe66(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x2c(%rbp),%r9d
lea    -0x28(%rbp),%rdx
call   1030 <bfsearch@plt>
mov    -0x28(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     125a <find_comps+0x13a>
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    $0x0,%al
call   1040 <drandom@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe0e(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jl     1230 <find_comps+0x110>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    122b <find_comps+0x10b>
movl   $0x1,-0x24(%rbp)
jmp    11fd <find_comps+0xdd>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x2c(%rbp),%r9d
lea    -0x28(%rbp),%rdx
call   1030 <bfsearch@plt>
jmp    11c1 <find_comps+0xa1>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_comps>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,%r15
test   %esi,%esi
jle    1161 <find_comps+0x31>
lea    0x4(%rbx),%rdi
mov    %ebp,%edx
shl    $0x2,%rdx
mov    $0xff,%esi
call   1030 <memset@plt>
movl   $0x0,0xc(%rsp)
cvtsi2sd %ebp,%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1050 <drandom@plt>
mulsd  0x10(%rsp),%xmm0
addsd  0xe78(%rip),%xmm0
cvttsd2si %xmm0,%esi
lea    0xc(%rsp),%rdx
mov    %r15,%rdi
mov    %rbx,%rcx
mov    %r14,%r8
xor    %r9d,%r9d
call   1040 <bfsearch@plt>
mov    $0x1,%r12d
cmp    %ebp,0xc(%rsp)
jne    11c0 <find_comps+0x90>
mov    %r12d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%r13d
mov    $0x1,%r12d
jmp    11f2 <find_comps+0xc2>
xchg   %ax,%ax
mov    %eax,%esi
mov    %r15,%rdi
lea    0xc(%rsp),%rdx
mov    %rbx,%rcx
mov    %r14,%r8
mov    %r12d,%r9d
call   1040 <bfsearch@plt>
add    $0x1,%r12d
cmp    %ebp,0xc(%rsp)
je     11ae <find_comps+0x7e>
xor    %eax,%eax
call   1050 <drandom@plt>
mulsd  0x10(%rsp),%xmm0
addsd  0xdf9(%rip),%xmm0
cvttsd2si %xmm0,%eax
movslq %eax,%rcx
cmpl   $0x0,(%rbx,%rcx,4)
js     11d0 <find_comps+0xa0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x1(%rax),%esi
cmp    %ebp,%eax
cmovge %r13d,%esi
movslq %esi,%rax
cmpl   $0x0,(%rbx,%rax,4)
mov    %esi,%eax
jns    1220 <find_comps+0xf0>
jmp    11d2 <find_comps+0xa2>

LLVM IR (-O0):
%struct.vtx_data = type { i32 }
define i32 @find_comps(%struct.vtx_data** %0, i32 %1, i32* %2, i32* %3) {
%5 = alloca %struct.vtx_data**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store %struct.vtx_data** %0, %struct.vtx_data*** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32* %3, i32** %8
store i32 1, i32* %12
br label %13
13: ; preds = %22, %4
%14 = load i32, i32* %12
%15 = load i32, i32* %6
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = load i32*, i32** %7
%19 = load i32, i32* %12
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
store i32 -1, i32* %21
br label %22
22: ; preds = %17
%23 = load i32, i32* %12
%24 = add nsw i32 %23, 1
store i32 %24, i32* %12
br label %13
25: ; preds = %13
store i32 0, i32* %10
store i32 0, i32* %11
%26 = load i32, i32* %6
%27 = sitofp i32 %26 to double
%28 = call double (...) @drandom()
%29 = call double @llvm.fmuladd.f64(double %27, double %28, double 1.000000e+00)
%30 = fptosi double %29 to i32
store i32 %30, i32* %9
%31 = load %struct.vtx_data**, %struct.vtx_data*** %5
%32 = load i32, i32* %9
%33 = load i32*, i32** %7
%34 = load i32*, i32** %8
%35 = load i32, i32* %11
%36 = call i32 @bfsearch(%struct.vtx_data** %31, i32 %32, i32* %10, i32* %33, i32* %34, i32 %35)
br label %37
37: ; preds = %62, %25
%38 = load i32, i32* %10
%39 = load i32, i32* %6
%40 = icmp ne i32 %38, %39
br i1 %40, label %41, label %71
41: ; preds = %37
%42 = load i32, i32* %6
%43 = sitofp i32 %42 to double
%44 = call double (...) @drandom()
%45 = call double @llvm.fmuladd.f64(double %43, double %44, double 1.000000e+00)
%46 = fptosi double %45 to i32
store i32 %46, i32* %9
br label %47
47: ; preds = %61, %41
%48 = load i32*, i32** %7
%49 = load i32, i32* %9
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %48, i64 %50
%52 = load i32, i32* %51
%53 = icmp sge i32 %52, 0
br i1 %53, label %54, label %62
54: ; preds = %47
%55 = load i32, i32* %9
%56 = add nsw i32 %55, 1
store i32 %56, i32* %9
%57 = load i32, i32* %9
%58 = load i32, i32* %6
%59 = icmp sgt i32 %57, %58
br i1 %59, label %60, label %61
60: ; preds = %54
store i32 1, i32* %9
br label %61
61: ; preds = %60, %54
br label %47
62: ; preds = %47
%63 = load i32, i32* %11
%64 = add nsw i32 %63, 1
store i32 %64, i32* %11
%65 = load %struct.vtx_data**, %struct.vtx_data*** %5
%66 = load i32, i32* %9
%67 = load i32*, i32** %7
%68 = load i32*, i32** %8
%69 = load i32, i32* %11
%70 = call i32 @bfsearch(%struct.vtx_data** %65, i32 %66, i32* %10, i32* %67, i32* %68, i32 %69)
br label %37
71: ; preds = %37
%72 = load i32, i32* %11
%73 = add nsw i32 %72, 1
ret i32 %73
}

LLVM IR (-O2):
%struct.vtx_data = type { i32 }
define i32 @find_comps(%struct.vtx_data** %0, i32 %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = icmp slt i32 %1, 1
br i1 %7, label %13, label %8
8: ; preds = %4
%9 = getelementptr i32, i32* %2, i64 1
%10 = bitcast i32* %9 to i8*
%11 = zext i32 %1 to i64
%12 = shl nuw nsw i64 %11, 2
br label %13
13: ; preds = %8, %4
store i32 0, i32* %5
%14 = sitofp i32 %1 to double
%15 = tail call double (...) @drandom()
%16 = tail call double @llvm.fmuladd.f64(double %14, double %15, double 1.000000e+00)
%17 = fptosi double %16 to i32
%18 = call i32 @bfsearch(%struct.vtx_data** %0, i32 %17, i32* %5, i32* %2, i32* %3, i32 0)
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, %1
br i1 %20, label %45, label %21
21: ; preds = %13, %39
%22 = phi i32 [ %42, %39 ], [ 1, %13 ]
%23 = call double (...) @drandom()
%24 = call double @llvm.fmuladd.f64(double %14, double %23, double 1.000000e+00)
%25 = fptosi double %24 to i32
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %2, i64 %26
%28 = load i32, i32* %27
%29 = icmp sgt i32 %28, -1
br i1 %29, label %30, label %39
30: ; preds = %21, %30
%31 = phi i32 [ %34, %30 ], [ %25, %21 ]
%32 = add nsw i32 %31, 1
%33 = icmp slt i32 %31, %1
%34 = select i1 %33, i32 %32, i32 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %2, i64 %35
%37 = load i32, i32* %36
%38 = icmp sgt i32 %37, -1
br i1 %38, label %30, label %39
39: ; preds = %30, %21
%40 = phi i32 [ %25, %21 ], [ %34, %30 ]
%41 = call i32 @bfsearch(%struct.vtx_data** %0, i32 %40, i32* %5, i32* %2, i32* %3, i32 %22)
%42 = add i32 %22, 1
%43 = load i32, i32* %5
%44 = icmp eq i32 %43, %1
br i1 %44, label %45, label %21
45: ; preds = %39, %13
%46 = phi i32 [ 1, %13 ], [ %42, %39 ]
ret i32 %46
}