int print_union(struct union_element *p_array, int size) {
  int ret_tmp = 0;
  int ret_grp = 0;
  if (!p_array) {
    printf("function:%s line:%d 'p_array' is NULL\n", __FUNCTION__, 123);
    return -1;
  }
  int tmp = 0;
  int grp = 0;
  for (grp = 0; grp < size; grp++) {
    for (tmp = 0; tmp < size; tmp++) {
      if (tmp == 0) {
        printf("######### group :%d ##########\n", grp);
      }
      ret_tmp = quick_root_element(p_array, size, tmp);
      ret_grp = quick_root_element(p_array, size, grp);
      if (ret_grp != grp) {
        break;
      }
      if (ret_tmp < 0 || ret_grp < 0) {
        return 0;
      }
      if (ret_tmp == ret_grp) {
        printf("%3d ", tmp);
      }
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<print_union>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116e <print_union+0x4e>
lea    0xeb1(%rip),%rdi
lea    0xed1(%rip),%rsi
mov    $0x7b,%edx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1269 <print_union+0x149>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1262 <print_union+0x142>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1246 <print_union+0x126>
cmpl   $0x0,-0x20(%rbp)
jne    11bd <print_union+0x9d>
mov    -0x24(%rbp),%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    $0x0,%al
call   1040 <quick_root_element@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    $0x0,%al
call   1040 <quick_root_element@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
je     11f6 <print_union+0xd6>
jmp    1246 <print_union+0x126>
cmpl   $0x0,-0x18(%rbp)
jl     120a <print_union+0xea>
cmpl   $0x0,-0x1c(%rbp)
jge    1216 <print_union+0xf6>
movl   $0x0,-0x4(%rbp)
jmp    1269 <print_union+0x149>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    1233 <print_union+0x113>
mov    -0x20(%rbp),%esi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1238 <print_union+0x118>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1196 <print_union+0x76>
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1183 <print_union+0x63>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_union>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     11dd <print_union+0xad>
mov    %esi,%r13d
test   %esi,%esi
jle    11d9 <print_union+0xa9>
mov    %rdi,%r14
lea    0xefa(%rip),%r12
xor    %ebp,%ebp
jmp    1172 <print_union+0x42>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    %r13d,%ebp
je     11d9 <print_union+0xa9>
xor    %ebx,%ebx
jmp    1188 <print_union+0x58>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    %ebx,%r13d
je     1160 <print_union+0x30>
test   %ebx,%ebx
jne    119c <print_union+0x6c>
lea    0xea0(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r13d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <quick_root_element@plt>
mov    %eax,%r15d
mov    %r14,%rdi
mov    %r13d,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <quick_root_element@plt>
cmp    %ebp,%eax
jne    1160 <print_union+0x30>
test   %r15d,%r15d
js     11d9 <print_union+0xa9>
cmp    %ebp,%r15d
jne    1180 <print_union+0x50>
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1180 <print_union+0x50>
xor    %eax,%eax
jmp    11fc <print_union+0xcc>
lea    0xe1c(%rip),%rdi
lea    0xe3c(%rip),%rsi
mov    $0x7b,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.union_element = type opaque
@.str = [39 x i8] c"function:%s line:%d 'p_array' is NULL\0A\00"
@__FUNCTION__.print_union = [12 x i8] c"print_union\00"
@.str.1 = [32 x i8] c"######### group :%d ##########\0A\00"
@.str.2 = [5 x i8] c"%3d \00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @print_union(%struct.union_element* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.union_element*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store %struct.union_element* %0, %struct.union_element** %4
store i32 %1, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%10 = load %struct.union_element*, %struct.union_element** %4
%11 = icmp ne %struct.union_element* %10, null
br i1 %11, label %14, label %12
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @__FUNCTION__.print_union, i64 0, i64 0), i32 123)
store i32 -1, i32* %3
br label %67
14: ; preds = %2
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %9
br label %15
15: ; preds = %63, %14
%16 = load i32, i32* %9
%17 = load i32, i32* %5
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %66
19: ; preds = %15
store i32 0, i32* %8
br label %20
20: ; preds = %58, %19
%21 = load i32, i32* %8
%22 = load i32, i32* %5
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %61
24: ; preds = %20
%25 = load i32, i32* %8
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i32, i32* %9
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %27, %24
%31 = load %struct.union_element*, %struct.union_element** %4
%32 = load i32, i32* %5
%33 = load i32, i32* %8
%34 = call i32 (%struct.union_element*, i32, i32, ...) bitcast (i32 (...)* @quick_root_element to i32 (%struct.union_element*, i32, i32, ...)*)(%struct.union_element* %31, i32 %32, i32 %33)
store i32 %34, i32* %6
%35 = load %struct.union_element*, %struct.union_element** %4
%36 = load i32, i32* %5
%37 = load i32, i32* %9
%38 = call i32 (%struct.union_element*, i32, i32, ...) bitcast (i32 (...)* @quick_root_element to i32 (%struct.union_element*, i32, i32, ...)*)(%struct.union_element* %35, i32 %36, i32 %37)
store i32 %38, i32* %7
%39 = load i32, i32* %7
%40 = load i32, i32* %9
%41 = icmp ne i32 %39, %40
br i1 %41, label %42, label %43
42: ; preds = %30
br label %61
43: ; preds = %30
%44 = load i32, i32* %6
%45 = icmp slt i32 %44, 0
br i1 %45, label %49, label %46
46: ; preds = %43
%47 = load i32, i32* %7
%48 = icmp slt i32 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %46, %43
store i32 0, i32* %3
br label %67
50: ; preds = %46
%51 = load i32, i32* %6
%52 = load i32, i32* %7
%53 = icmp eq i32 %51, %52
br i1 %53, label %54, label %57
54: ; preds = %50
%55 = load i32, i32* %8
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %55)
br label %57
57: ; preds = %54, %50
br label %58
58: ; preds = %57
%59 = load i32, i32* %8
%60 = add nsw i32 %59, 1
store i32 %60, i32* %8
br label %20
61: ; preds = %42, %20
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %63
63: ; preds = %61
%64 = load i32, i32* %9
%65 = add nsw i32 %64, 1
store i32 %65, i32* %9
br label %15
66: ; preds = %15
store i32 0, i32* %3
br label %67
67: ; preds = %66, %49, %12
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
%struct.union_element = type opaque
@.str = [39 x i8] c"function:%s line:%d 'p_array' is NULL\0A\00"
@__FUNCTION__.print_union = [12 x i8] c"print_union\00"
@.str.1 = [32 x i8] c"######### group :%d ##########\0A\00"
@.str.2 = [5 x i8] c"%3d \00"
define i32 @print_union(%struct.union_element* %0, i32 %1) {
%3 = icmp eq %struct.union_element* %0, null
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = icmp sgt i32 %1, 0
br i1 %5, label %8, label %32
6: ; preds = %2
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @__FUNCTION__.print_union, i64 0, i64 0), i32 123)
br label %32
8: ; preds = %4, %28
%9 = phi i32 [ %30, %28 ], [ 0, %4 ]
br label %10
10: ; preds = %8, %25
%11 = phi i32 [ %26, %25 ], [ 0, %8 ]
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %15
15: ; preds = %13, %10
%16 = tail call i32 (%struct.union_element*, i32, i32, ...) bitcast (i32 (...)* @quick_root_element to i32 (%struct.union_element*, i32, i32, ...)*)(%struct.union_element* %0, i32 %1, i32 %11)
%17 = tail call i32 (%struct.union_element*, i32, i32, ...) bitcast (i32 (...)* @quick_root_element to i32 (%struct.union_element*, i32, i32, ...)*)(%struct.union_element* %0, i32 %1, i32 %9)
%18 = icmp eq i32 %17, %9
br i1 %18, label %19, label %28
19: ; preds = %15
%20 = icmp slt i32 %16, 0
br i1 %20, label %32, label %21
21: ; preds = %19
%22 = icmp eq i32 %16, %9
br i1 %22, label %23, label %25
23: ; preds = %21
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %11)
br label %25
25: ; preds = %21, %23
%26 = add nuw nsw i32 %11, 1
%27 = icmp eq i32 %26, %1
br i1 %27, label %28, label %10
28: ; preds = %25, %15
%29 = tail call i32 @putchar(i32 10)
%30 = add nuw nsw i32 %9, 1
%31 = icmp eq i32 %30, %1
br i1 %31, label %32, label %8
32: ; preds = %28, %19, %4, %6
%33 = phi i32 [ -1, %6 ], [ 0, %4 ], [ 0, %19 ], [ 0, %28 ]
ret i32 %33
}