#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 */
typedef int /*<<< orphan*/ pairs;

/* Variables and functions */
int /*<<< orphan*/ printData(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ setUnion(int *, int, int, int);
void testSetUnion(int data[], int size, int bySize) {
  int i;
  int pairs[][2] = {{1, 2}, {1, 3},   {4, 5},  {6, 7}, {4, 6},
                    {8, 9}, {10, 11}, {8, 10}, {4, 8}};
  int pairSize = sizeof(pairs) / sizeof(int[2]);
  printf("----------Test SetUnion----------\n");
  printData(data, size);
  for (i = 0; i < pairSize; i++) {
    printf("Union by %s: %2d, %2d\n", (bySize > 0) ? "size" : "height",
           pairs[i][0], pairs[i][1]);
    setUnion(data, pairs[i][0], pairs[i][1], bySize);
    printData(data, size);
  }
}


x86 assembly (clang, -O0):
<testSetUnion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x48,%edx
call   1050 <memcpy@plt>
movl   $0x9,-0x64(%rbp)
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1060 <printData@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    1207 <testSetUnion+0xc7>
mov    -0x10(%rbp),%ecx
lea    0xee2(%rip),%rsi
lea    0xed6(%rip),%rax
cmp    $0x0,%ecx
cmovg  %rax,%rsi
movslq -0x14(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%edx
movslq -0x14(%rbp),%rax
mov    -0x5c(%rbp,%rax,8),%ecx
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%esi
movslq -0x14(%rbp),%rax
mov    -0x5c(%rbp,%rax,8),%edx
mov    -0x10(%rbp),%ecx
call   1030 <setUnion@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1060 <printData@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118f <testSetUnion+0x4f>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testSetUnion>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r15d
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1060 <printData@plt>
test   %r15d,%r15d
lea    0xea5(%rip),%rax
lea    0xea3(%rip),%rbp
cmovg  %rax,%rbp
lea    0xe7c(%rip),%r12
mov    %r12,%rdi
mov    %rbp,%rsi
mov    $0x1,%edx
mov    $0x2,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
mov    %r15d,%ecx
call   1040 <setUnion@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1060 <printData@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    $0x1,%edx
mov    $0x3,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    %r15d,%ecx
call   1040 <setUnion@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1060 <printData@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    $0x4,%edx
mov    $0x5,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x5,%edx
mov    %r15d,%ecx
call   1040 <setUnion@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1060 <printData@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    $0x6,%edx
mov    $0x7,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0x7,%edx
mov    %r15d,%ecx
call   1040 <setUnion@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1060 <printData@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    $0x4,%edx
mov    $0x6,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x6,%edx
mov    %r15d,%ecx
call   1040 <setUnion@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1060 <printData@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    $0x8,%edx
mov    $0x9,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
mov    $0x9,%edx
mov    %r15d,%ecx
call   1040 <setUnion@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1060 <printData@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    $0xa,%edx
mov    $0xb,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0xb,%edx
mov    %r15d,%ecx
call   1040 <setUnion@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1060 <printData@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    $0x8,%edx
mov    $0xa,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
mov    $0xa,%edx
mov    %r15d,%ecx
call   1040 <setUnion@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1060 <printData@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    $0x4,%edx
mov    $0x8,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x8,%edx
mov    %r15d,%ecx
call   1040 <setUnion@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <printData@plt>

LLVM IR (-O0):
@__const.testSetUnion.pairs = [9 x [2 x i32]] [[2 x i32] [i32 1, i32 2], [2 x i32] [i32 1, i32 3], [2 x i32] [i32 4, i32 5], [2 x i32] [i32 6, i32 7], [2 x i32] [i32 4, i32 6], [2 x i32] [i32 8, i32 9], [2 x i32] [i32 10, i32 11], [2 x i32] [i32 8, i32 10], [2 x i32] [i32 4, i32 8]]
@.str = [35 x i8] c"----------Test SetUnion----------\0A\00"
@.str.1 = [23 x i8] c"Union by %s: %2d, %2d\0A\00"
@.str.2 = [5 x i8] c"size\00"
@.str.3 = [7 x i8] c"height\00"
define void @testSetUnion(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [9 x [2 x i32]]
%9 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = bitcast [9 x [2 x i32]]* %8 to i8*
store i32 9, i32* %9
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%12 = load i32*, i32** %4
%13 = load i32, i32* %5
%14 = call i32 @printData(i32* %12, i32 %13)
store i32 0, i32* %7
br label %15
15: ; preds = %51, %3
%16 = load i32, i32* %7
%17 = load i32, i32* %9
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %54
19: ; preds = %15
%20 = load i32, i32* %6
%21 = icmp sgt i32 %20, 0
%22 = zext i1 %21 to i64
%23 = select i1 %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0)
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [9 x [2 x i32]], [9 x [2 x i32]]* %8, i64 0, i64 %25
%27 = getelementptr inbounds [2 x i32], [2 x i32]* %26, i64 0, i64 0
%28 = load i32, i32* %27
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [9 x [2 x i32]], [9 x [2 x i32]]* %8, i64 0, i64 %30
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %31, i64 0, i64 1
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %23, i32 %28, i32 %33)
%35 = load i32*, i32** %4
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [9 x [2 x i32]], [9 x [2 x i32]]* %8, i64 0, i64 %37
%39 = getelementptr inbounds [2 x i32], [2 x i32]* %38, i64 0, i64 0
%40 = load i32, i32* %39
%41 = load i32, i32* %7
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [9 x [2 x i32]], [9 x [2 x i32]]* %8, i64 0, i64 %42
%44 = getelementptr inbounds [2 x i32], [2 x i32]* %43, i64 0, i64 1
%45 = load i32, i32* %44
%46 = load i32, i32* %6
%47 = call i32 @setUnion(i32* %35, i32 %40, i32 %45, i32 %46)
%48 = load i32*, i32** %4
%49 = load i32, i32* %5
%50 = call i32 @printData(i32* %48, i32 %49)
br label %51
51: ; preds = %19
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
store i32 %53, i32* %7
br label %15
54: ; preds = %15
ret void
}

LLVM IR (-O2):
@.str.1 = [23 x i8] c"Union by %s: %2d, %2d\0A\00"
@.str.2 = [5 x i8] c"size\00"
@.str.3 = [7 x i8] c"height\00"
@str = [34 x i8] c"----------Test SetUnion----------\00"
define void @testSetUnion(i32* %0, i32 %1, i32 %2) {
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @printData(i32* %0, i32 %1)
%6 = icmp sgt i32 %2, 0
%7 = select i1 %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 1, i32 2)
%9 = tail call i32 @setUnion(i32* %0, i32 1, i32 2, i32 %2)
%10 = tail call i32 @printData(i32* %0, i32 %1)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 1, i32 3)
%12 = tail call i32 @setUnion(i32* %0, i32 1, i32 3, i32 %2)
%13 = tail call i32 @printData(i32* %0, i32 %1)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 4, i32 5)
%15 = tail call i32 @setUnion(i32* %0, i32 4, i32 5, i32 %2)
%16 = tail call i32 @printData(i32* %0, i32 %1)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 6, i32 7)
%18 = tail call i32 @setUnion(i32* %0, i32 6, i32 7, i32 %2)
%19 = tail call i32 @printData(i32* %0, i32 %1)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 4, i32 6)
%21 = tail call i32 @setUnion(i32* %0, i32 4, i32 6, i32 %2)
%22 = tail call i32 @printData(i32* %0, i32 %1)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 8, i32 9)
%24 = tail call i32 @setUnion(i32* %0, i32 8, i32 9, i32 %2)
%25 = tail call i32 @printData(i32* %0, i32 %1)
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 10, i32 11)
%27 = tail call i32 @setUnion(i32* %0, i32 10, i32 11, i32 %2)
%28 = tail call i32 @printData(i32* %0, i32 %1)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 8, i32 10)
%30 = tail call i32 @setUnion(i32* %0, i32 8, i32 10, i32 %2)
%31 = tail call i32 @printData(i32* %0, i32 %1)
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 4, i32 8)
%33 = tail call i32 @setUnion(i32* %0, i32 4, i32 8, i32 %2)
%34 = tail call i32 @printData(i32* %0, i32 %1)
ret void
}