#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*/ printSet(int *, int);
int /*<<< orphan*/ printf(char *);
int removeDuplicates(int *, int);
int /*<<< orphan*/ sort(int *, int);
int findUnion(int *set1, int len1, int *set2, int len2) {
  int unionarr[200], i, j, len;
  for (i = 0; i < len1; i++)
    unionarr[i] = set1[i];
  for (i = len1, j = 0; i < (len1 + len2); i++, j++)
    unionarr[i] = set2[j];
  sort(unionarr, (len1 + len2));
  len = removeDuplicates(unionarr, (len1 + len2));
  printf("\nUnion ::");
  printSet(unionarr, len);
  return 0;
}


x86 assembly (clang, -O0):
<findUnion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x350,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x344(%rbp)
mov    -0x344(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a2 <findUnion+0x62>
mov    -0x8(%rbp),%rax
movslq -0x344(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
movslq -0x344(%rbp),%rax
mov    %ecx,-0x340(%rbp,%rax,4)
mov    -0x344(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x344(%rbp)
jmp    1163 <findUnion+0x23>
mov    -0xc(%rbp),%eax
mov    %eax,-0x344(%rbp)
movl   $0x0,-0x348(%rbp)
mov    -0x344(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    -0x1c(%rbp),%ecx
cmp    %ecx,%eax
jge    1208 <findUnion+0xc8>
mov    -0x18(%rbp),%rax
movslq -0x348(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
movslq -0x344(%rbp),%rax
mov    %ecx,-0x340(%rbp,%rax,4)
mov    -0x344(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x344(%rbp)
mov    -0x348(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x348(%rbp)
jmp    11b5 <findUnion+0x75>
lea    -0x340(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    -0x1c(%rbp),%esi
call   1040 <sort@plt>
lea    -0x340(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    -0x1c(%rbp),%esi
call   1050 <removeDuplicates@plt>
mov    %eax,-0x34c(%rbp)
lea    0xdc7(%rip),%rdi
call   1030 <printf@plt>
lea    -0x340(%rbp),%rdi
mov    -0x34c(%rbp),%esi
call   1060 <printSet@plt>
xor    %eax,%eax
add    $0x350,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findUnion>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x328,%rsp
mov    %ecx,%r15d
mov    %rdx,%r14
mov    %esi,%ebx
test   %esi,%esi
jle    117a <findUnion+0x2a>
mov    %rdi,%rsi
mov    %ebx,%edx
shl    $0x2,%rdx
mov    %rsp,%rdi
call   1060 <memcpy@plt>
lea    (%r15,%rbx,1),%ebp
test   %r15d,%r15d
jle    11a6 <findUnion+0x56>
movslq %ebx,%rax
lea    0x1(%rbx),%ecx
cmp    %ecx,%ebp
cmovg  %ebp,%ecx
lea    (%rsp,%rax,4),%rdi
not    %ebx
add    %ecx,%ebx
lea    0x4(,%rbx,4),%rdx
mov    %r14,%rsi
call   1060 <memcpy@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <sort@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <removeDuplicates@plt>
mov    %eax,%ebp
lea    0xe3a(%rip),%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1070 <printSet@plt>
xor    %eax,%eax
add    $0x328,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c"\0AUnion ::\00"
define i32 @findUnion(i32* nocapture %0, i32 %1, i32* nocapture %2, i32 %3) {
%5 = bitcast i32* %2 to i8*
%6 = alloca [200 x i32]
%7 = bitcast [200 x i32]* %6 to i8*
%8 = icmp sgt i32 %1, 0
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = bitcast i32* %0 to i8*
%11 = zext i32 %1 to i64
%12 = shl nuw nsw i64 %11, 2
br label %13
13: ; preds = %9, %4
%14 = add i32 %3, %1
%15 = icmp sgt i32 %3, 0
br i1 %15, label %16, label %27
16: ; preds = %13
%17 = sext i32 %1 to i64
%18 = getelementptr [200 x i32], [200 x i32]* %6, i64 0, i64 %17
%19 = bitcast i32* %18 to i8*
%20 = add i32 %1, 1
%21 = call i32 @llvm.smax.i32(i32 %14, i32 %20)
%22 = xor i32 %1, -1
%23 = add i32 %21, %22
%24 = zext i32 %23 to i64
%25 = shl nuw nsw i64 %24, 2
%26 = add nuw nsw i64 %25, 4
br label %27
27: ; preds = %16, %13
%28 = getelementptr inbounds [200 x i32], [200 x i32]* %6, i64 0, i64 0
%29 = call i32 @sort(i32* %28, i32 %14)
%30 = call i32 @removeDuplicates(i32* %28, i32 %14)
%31 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%32 = call i32 @printSet(i32* %28, i32 %30)
ret i32 0
}