#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 */
scalar_t__ find(int, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ unionn(int, int, int *, int *);
int main() {
  int n = 10;
  int parent[n];
  int rank[n];
  for (int i = 0; i < 10; i++)
    parent[i] = i;
  for (int i = 0; i < 10; i++)
    rank[i] = 1;
  unionn(3, 8, parent, rank);
  unionn(3, 6, parent, rank);
  printf("the parent of 8 is %d\n", find(8, parent));
  unionn(1, 9, parent, rank);
  unionn(2, 8, parent, rank);
  unionn(5, 8, parent, rank);
  unionn(2, 9, parent, rank);
  printf("the parent of 2 is %d\n", find(2, parent));
  printf("the parent of 8 is%d\n", find(8, parent));
  if (find(5, parent) == find(7, parent))
    printf("5 is a friend of 7\n");
  else
    printf("5 is not a friend of 7\n");
  if (find(3, parent) == find(1, parent))
    printf("3 is a friend of 1\n");
  else
    printf("3 is not a friend of 1\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0xa,-0x24(%rbp)
jge    11ba <main+0x8a>
mov    -0x38(%rbp),%rax
mov    -0x24(%rbp),%edx
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1194 <main+0x64>
movl   $0x0,-0x28(%rbp)
cmpl   $0xa,-0x28(%rbp)
jge    11e8 <main+0xb8>
mov    -0x30(%rbp),%rax
movslq -0x28(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11c1 <main+0x91>
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    $0x3,%edi
mov    $0x8,%esi
call   1050 <unionn@plt>
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%rdx
mov    $0x3,%edi
mov    $0x6,%esi
call   1050 <unionn@plt>
mov    -0x38(%rbp),%rsi
mov    $0x8,%edi
call   1040 <find@plt>
mov    %rax,%rsi
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%rdx
mov    $0x1,%edi
mov    $0x9,%esi
call   1050 <unionn@plt>
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%rdx
mov    $0x2,%edi
mov    $0x8,%esi
call   1050 <unionn@plt>
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%rdx
mov    $0x5,%edi
mov    $0x8,%esi
call   1050 <unionn@plt>
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%rdx
mov    $0x2,%edi
mov    $0x9,%esi
call   1050 <unionn@plt>
mov    -0x38(%rbp),%rsi
mov    $0x2,%edi
call   1040 <find@plt>
mov    %rax,%rsi
lea    0xd6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rsi
mov    $0x8,%edi
call   1040 <find@plt>
mov    %rax,%rsi
lea    0xd66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rsi
mov    $0x5,%edi
call   1040 <find@plt>
mov    -0x38(%rbp),%rsi
mov    %rax,-0x40(%rbp)
mov    $0x7,%edi
call   1040 <find@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cmp    %rcx,%rax
jne    1312 <main+0x1e2>
lea    0xd3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1320 <main+0x1f0>
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rsi
mov    $0x3,%edi
call   1040 <find@plt>
mov    -0x38(%rbp),%rsi
mov    %rax,-0x48(%rbp)
mov    $0x1,%edi
call   1040 <find@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
cmp    %rcx,%rax
jne    1363 <main+0x233>
lea    0xd19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1371 <main+0x241>
lea    0xd1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
movaps 0xeb0(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movabs $0x900000008,%rax
mov    %rax,0x50(%rsp)
movaps 0xea9(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x10(%rsp)
movabs $0x100000001,%rax
mov    %rax,0x20(%rsp)
lea    0x30(%rsp),%r15
mov    %rsp,%r14
mov    $0x3,%edi
mov    $0x8,%esi
mov    %r15,%rdx
mov    %r14,%rcx
call   1060 <unionn@plt>
mov    $0x3,%edi
mov    $0x6,%esi
mov    %r15,%rdx
mov    %r14,%rcx
call   1060 <unionn@plt>
mov    $0x8,%edi
mov    %r15,%rsi
call   1050 <find@plt>
lea    0xe5b(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
mov    $0x9,%esi
mov    %r15,%rdx
mov    %r14,%rcx
call   1060 <unionn@plt>
mov    $0x2,%edi
mov    $0x8,%esi
mov    %r15,%rdx
mov    %r14,%rcx
call   1060 <unionn@plt>
mov    $0x5,%edi
mov    $0x8,%esi
mov    %r15,%rdx
mov    %r14,%rcx
call   1060 <unionn@plt>
mov    $0x2,%edi
mov    $0x9,%esi
mov    %r15,%rdx
mov    %r14,%rcx
call   1060 <unionn@plt>
mov    $0x2,%edi
mov    %r15,%rsi
call   1050 <find@plt>
lea    0xe00(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x8,%edi
mov    %r15,%rsi
call   1050 <find@plt>
lea    0xdf9(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x5,%edi
mov    %r15,%rsi
call   1050 <find@plt>
mov    %rax,%rbx
mov    $0x7,%edi
mov    %r15,%rsi
call   1050 <find@plt>
cmp    %rax,%rbx
lea    0xe1f(%rip),%rax
lea    0xdd7(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
mov    %r15,%rsi
call   1050 <find@plt>
mov    %rax,%rbx
mov    $0x1,%edi
mov    %r15,%rsi
call   1050 <find@plt>
cmp    %rax,%rbx
lea    0xdd5(%rip),%rax
lea    0xdb7(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [23 x i8] c"the parent of 8 is %d\0A\00"
@.str.1 = [23 x i8] c"the parent of 2 is %d\0A\00"
@.str.2 = [22 x i8] c"the parent of 8 is%d\0A\00"
@.str.3 = [20 x i8] c"5 is a friend of 7\0A\00"
@.str.4 = [24 x i8] c"5 is not a friend of 7\0A\00"
@.str.5 = [20 x i8] c"3 is a friend of 1\0A\00"
@.str.6 = [24 x i8] c"3 is not a friend of 1\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %2
%8 = load i32, i32* %2
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %3
%11 = alloca i32, i64 %9
store i64 %9, i64* %4
%12 = load i32, i32* %2
%13 = zext i32 %12 to i64
%14 = alloca i32, i64 %13
store i64 %13, i64* %5
store i32 0, i32* %6
br label %15
15: ; preds = %23, %0
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 10
br i1 %17, label %18, label %26
18: ; preds = %15
%19 = load i32, i32* %6
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %11, i64 %21
store i32 %19, i32* %22
br label %23
23: ; preds = %18
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %15
26: ; preds = %15
store i32 0, i32* %7
br label %27
27: ; preds = %34, %26
%28 = load i32, i32* %7
%29 = icmp slt i32 %28, 10
br i1 %29, label %30, label %37
30: ; preds = %27
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %14, i64 %32
store i32 1, i32* %33
br label %34
34: ; preds = %30
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %27
37: ; preds = %27
%38 = call i32 @unionn(i32 3, i32 8, i32* %11, i32* %14)
%39 = call i32 @unionn(i32 3, i32 6, i32* %11, i32* %14)
%40 = call i64 @find(i32 8, i32* %11)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 %40)
%42 = call i32 @unionn(i32 1, i32 9, i32* %11, i32* %14)
%43 = call i32 @unionn(i32 2, i32 8, i32* %11, i32* %14)
%44 = call i32 @unionn(i32 5, i32 8, i32* %11, i32* %14)
%45 = call i32 @unionn(i32 2, i32 9, i32* %11, i32* %14)
%46 = call i64 @find(i32 2, i32* %11)
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i64 %46)
%48 = call i64 @find(i32 8, i32* %11)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i64 %48)
%50 = call i64 @find(i32 5, i32* %11)
%51 = call i64 @find(i32 7, i32* %11)
%52 = icmp eq i64 %50, %51
br i1 %52, label %53, label %55
53: ; preds = %37
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %57
55: ; preds = %37
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %57
57: ; preds = %55, %53
%58 = call i64 @find(i32 3, i32* %11)
%59 = call i64 @find(i32 1, i32* %11)
%60 = icmp eq i64 %58, %59
br i1 %60, label %61, label %63
61: ; preds = %57
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %65
63: ; preds = %57
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
br label %65
65: ; preds = %63, %61
store i32 0, i32* %1
%66 = load i8*, i8** %3
%67 = load i32, i32* %1
ret i32 %67
}

LLVM IR (-O2):
@.str = [23 x i8] c"the parent of 8 is %d\0A\00"
@.str.1 = [23 x i8] c"the parent of 2 is %d\0A\00"
@.str.2 = [22 x i8] c"the parent of 8 is%d\0A\00"
@str = [23 x i8] c"5 is not a friend of 7\00"
@str.7 = [23 x i8] c"3 is not a friend of 1\00"
@str.8 = [19 x i8] c"3 is a friend of 1\00"
@str.9 = [19 x i8] c"5 is a friend of 7\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = alloca [10 x i32]
%3 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%4 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%5 = bitcast [10 x i32]* %1 to <4 x i32>*
store <4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32>* %5
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%7 = bitcast i32* %6 to <4 x i32>*
store <4 x i32> <i32 4, i32 5, i32 6, i32 7>, <4 x i32>* %7
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
store i32 8, i32* %8
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
store i32 9, i32* %9
%10 = bitcast [10 x i32]* %2 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %10
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 4
%12 = bitcast i32* %11 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %12
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 8
store i32 1, i32* %13
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 9
store i32 1, i32* %14
%15 = call i32 @unionn(i32 3, i32 8, i32* %4, i32* %3)
%16 = call i32 @unionn(i32 3, i32 6, i32* %4, i32* %3)
%17 = call i64 @find(i32 8, i32* %4)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 %17)
%19 = call i32 @unionn(i32 1, i32 9, i32* %4, i32* %3)
%20 = call i32 @unionn(i32 2, i32 8, i32* %4, i32* %3)
%21 = call i32 @unionn(i32 5, i32 8, i32* %4, i32* %3)
%22 = call i32 @unionn(i32 2, i32 9, i32* %4, i32* %3)
%23 = call i64 @find(i32 2, i32* %4)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i64 %23)
%25 = call i64 @find(i32 8, i32* %4)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i64 %25)
%27 = call i64 @find(i32 5, i32* %4)
%28 = call i64 @find(i32 7, i32* %4)
%29 = icmp eq i64 %27, %28
%30 = select i1 %29, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @str.9, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0)
%31 = call i32 @puts(i8* dereferenceable(1) %30)
%32 = call i64 @find(i32 3, i32* %4)
%33 = call i64 @find(i32 1, i32* %4)
%34 = icmp eq i64 %32, %33
%35 = select i1 %34, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @str.8, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @str.7, i64 0, i64 0)
%36 = call i32 @puts(i8* dereferenceable(1) %35)
ret i32 0
}