#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*/ bbox_from_npoints(float **, int, float **);
int /*<<< orphan*/ box_get_vertices(float const **, float **);
scalar_t__ box_is_null(float const **);
int /*<<< orphan*/ mat4_copy(float const **, float **);
void box_union(const float a[4][4], const float b[4][4], float out[4][4]) {
  float verts[16][3];
  if (box_is_null(a)) {
    mat4_copy(b, out);
    return;
  }
  if (box_is_null(b)) {
    mat4_copy(a, out);
    return;
  }
  box_get_vertices(a, verts + 0);
  box_get_vertices(b, verts + 8);
  bbox_from_npoints(out, 16, verts);
}


x86 assembly (clang, -O0):
<box_union>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <box_is_null@plt>
cmp    $0x0,%rax
je     117c <box_union+0x3c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <mat4_copy@plt>
jmp    11da <box_union+0x9a>
mov    -0x10(%rbp),%rdi
call   1030 <box_is_null@plt>
cmp    $0x0,%rax
je     11a1 <box_union+0x61>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <mat4_copy@plt>
jmp    11da <box_union+0x9a>
mov    -0x8(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1050 <box_get_vertices@plt>
mov    -0x10(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
add    $0x60,%rsi
call   1050 <box_get_vertices@plt>
mov    -0x18(%rbp),%rdi
lea    -0xe0(%rbp),%rdx
mov    $0x10,%esi
call   1040 <bbox_from_npoints@plt>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<box_union>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xc8,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1030 <box_is_null@plt>
test   %rax,%rax
je     1166 <box_union+0x26>
mov    %r15,%rdi
jmp    1176 <box_union+0x36>
mov    %r15,%rdi
call   1030 <box_is_null@plt>
test   %rax,%rax
je     118c <box_union+0x4c>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1060 <mat4_copy@plt>
mov    %rsp,%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <box_get_vertices@plt>
lea    0x60(%rsp),%rsi
mov    %r15,%rdi
call   1050 <box_get_vertices@plt>
mov    %r14,%rdi
mov    $0x10,%esi
mov    %r12,%rdx
call   1040 <bbox_from_npoints@plt>
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @box_union([4 x float]* %0, [4 x float]* %1, [4 x float]* %2) {
%4 = alloca [4 x float]*
%5 = alloca [4 x float]*
%6 = alloca [4 x float]*
%7 = alloca [16 x [3 x float]]
store [4 x float]* %0, [4 x float]** %4
store [4 x float]* %1, [4 x float]** %5
store [4 x float]* %2, [4 x float]** %6
%8 = load [4 x float]*, [4 x float]** %4
%9 = bitcast [4 x float]* %8 to float**
%10 = call i64 @box_is_null(float** %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %3
%13 = load [4 x float]*, [4 x float]** %5
%14 = bitcast [4 x float]* %13 to float**
%15 = load [4 x float]*, [4 x float]** %6
%16 = bitcast [4 x float]* %15 to float**
%17 = call i32 @mat4_copy(float** %14, float** %16)
br label %47
18: ; preds = %3
%19 = load [4 x float]*, [4 x float]** %5
%20 = bitcast [4 x float]* %19 to float**
%21 = call i64 @box_is_null(float** %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %18
%24 = load [4 x float]*, [4 x float]** %4
%25 = bitcast [4 x float]* %24 to float**
%26 = load [4 x float]*, [4 x float]** %6
%27 = bitcast [4 x float]* %26 to float**
%28 = call i32 @mat4_copy(float** %25, float** %27)
br label %47
29: ; preds = %18
%30 = load [4 x float]*, [4 x float]** %4
%31 = bitcast [4 x float]* %30 to float**
%32 = getelementptr inbounds [16 x [3 x float]], [16 x [3 x float]]* %7, i64 0, i64 0
%33 = getelementptr inbounds [3 x float], [3 x float]* %32, i64 0
%34 = bitcast [3 x float]* %33 to float**
%35 = call i32 @box_get_vertices(float** %31, float** %34)
%36 = load [4 x float]*, [4 x float]** %5
%37 = bitcast [4 x float]* %36 to float**
%38 = getelementptr inbounds [16 x [3 x float]], [16 x [3 x float]]* %7, i64 0, i64 0
%39 = getelementptr inbounds [3 x float], [3 x float]* %38, i64 8
%40 = bitcast [3 x float]* %39 to float**
%41 = call i32 @box_get_vertices(float** %37, float** %40)
%42 = load [4 x float]*, [4 x float]** %6
%43 = bitcast [4 x float]* %42 to float**
%44 = getelementptr inbounds [16 x [3 x float]], [16 x [3 x float]]* %7, i64 0, i64 0
%45 = bitcast [3 x float]* %44 to float**
%46 = call i32 @bbox_from_npoints(float** %43, i32 16, float** %45)
br label %47
47: ; preds = %29, %23, %12
ret void
}

LLVM IR (-O2):
define void @box_union([4 x float]* %0, [4 x float]* %1, [4 x float]* %2) {
%4 = alloca [16 x [3 x float]]
%5 = bitcast [16 x [3 x float]]* %4 to i8*
%6 = bitcast [4 x float]* %0 to float**
%7 = tail call i64 @box_is_null(float** %6)
%8 = icmp eq i64 %7, 0
%9 = bitcast [4 x float]* %1 to float**
br i1 %8, label %13, label %10
10: ; preds = %3
%11 = bitcast [4 x float]* %2 to float**
%12 = tail call i32 @mat4_copy(float** %9, float** %11)
br label %27
13: ; preds = %3
%14 = tail call i64 @box_is_null(float** %9)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = bitcast [4 x float]* %2 to float**
%18 = tail call i32 @mat4_copy(float** %6, float** %17)
br label %27
19: ; preds = %13
%20 = bitcast [16 x [3 x float]]* %4 to float**
%21 = call i32 @box_get_vertices(float** %6, float** %20)
%22 = getelementptr inbounds [16 x [3 x float]], [16 x [3 x float]]* %4, i64 0, i64 8
%23 = bitcast [3 x float]* %22 to float**
%24 = call i32 @box_get_vertices(float** %9, float** %23)
%25 = bitcast [4 x float]* %2 to float**
%26 = call i32 @bbox_from_npoints(float** %25, i32 16, float** %20)
br label %27
27: ; preds = %19, %16, %10
ret void
}