#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*/ mat4_mul_vec3(float const **, float *, float *);
void box_get_bbox(const float b[4][4], float out[4][4]) {
  float p[8][3] = {
      {-1, -1, +1}, {+1, -1, +1}, {+1, +1, +1}, {-1, +1, +1},
      {-1, -1, -1}, {+1, -1, -1}, {+1, +1, -1}, {-1, +1, -1},
  };
  int i;
  for (i = 0; i < 8; i++) {
    mat4_mul_vec3(b, p[i], p[i]);
  }
  bbox_from_npoints(out, 8, p);
}


x86 assembly (clang, -O0):
<box_get_bbox>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xeb2(%rip),%rsi
mov    $0x60,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x74(%rbp)
cmpl   $0x8,-0x74(%rbp)
jge    119e <box_get_bbox+0x6e>
mov    -0x8(%rbp),%rdi
movslq -0x74(%rbp),%rax
lea    -0x70(%rbp),%rsi
imul   $0xc,%rax,%rax
add    %rax,%rsi
movslq -0x74(%rbp),%rax
lea    -0x70(%rbp),%rdx
imul   $0xc,%rax,%rax
add    %rax,%rdx
call   1050 <mat4_mul_vec3@plt>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    115f <box_get_bbox+0x2f>
mov    -0x10(%rbp),%rdi
lea    -0x70(%rbp),%rdx
mov    $0x8,%esi
call   1030 <bbox_from_npoints@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<box_get_bbox>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movaps 0xf18(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xefc(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xee0(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xea8(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe8c(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x30(%rsp),%r12
mov    %rsp,%r15
mov    %r15,%rsi
mov    %r15,%rdx
call   1040 <mat4_mul_vec3@plt>
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
mov    %rdx,%rsi
call   1040 <mat4_mul_vec3@plt>
lea    0x18(%rsp),%rdx
mov    %rbx,%rdi
mov    %rdx,%rsi
call   1040 <mat4_mul_vec3@plt>
lea    0x24(%rsp),%rdx
mov    %rbx,%rdi
mov    %rdx,%rsi
call   1040 <mat4_mul_vec3@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r12,%rdx
call   1040 <mat4_mul_vec3@plt>
lea    0x3c(%rsp),%rdx
mov    %rbx,%rdi
mov    %rdx,%rsi
call   1040 <mat4_mul_vec3@plt>
lea    0x48(%rsp),%rdx
mov    %rbx,%rdi
mov    %rdx,%rsi
call   1040 <mat4_mul_vec3@plt>
lea    0x54(%rsp),%rdx
mov    %rbx,%rdi
mov    %rdx,%rsi
call   1040 <mat4_mul_vec3@plt>
mov    %r14,%rdi
mov    $0x8,%esi
mov    %r15,%rdx
call   1030 <bbox_from_npoints@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.box_get_bbox.p = [8 x [3 x float]] [[3 x float] [float -1.000000e+00, float -1.000000e+00, float 1.000000e+00], [3 x float] [float 1.000000e+00, float -1.000000e+00, float 1.000000e+00], [3 x float] [float 1.000000e+00, float 1.000000e+00, float 1.000000e+00], [3 x float] [float -1.000000e+00, float 1.000000e+00, float 1.000000e+00], [3 x float] [float -1.000000e+00, float -1.000000e+00, float -1.000000e+00], [3 x float] [float 1.000000e+00, float -1.000000e+00, float -1.000000e+00], [3 x float] [float 1.000000e+00, float 1.000000e+00, float -1.000000e+00], [3 x float] [float -1.000000e+00, float 1.000000e+00, float -1.000000e+00]]
define void @box_get_bbox([4 x float]* %0, [4 x float]* %1) {
%3 = alloca [4 x float]*
%4 = alloca [4 x float]*
%5 = alloca [8 x [3 x float]]
%6 = alloca i32
store [4 x float]* %0, [4 x float]** %3
store [4 x float]* %1, [4 x float]** %4
%7 = bitcast [8 x [3 x float]]* %5 to i8*
store i32 0, i32* %6
br label %8
8: ; preds = %23, %2
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 8
br i1 %10, label %11, label %26
11: ; preds = %8
%12 = load [4 x float]*, [4 x float]** %3
%13 = bitcast [4 x float]* %12 to float**
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [8 x [3 x float]], [8 x [3 x float]]* %5, i64 0, i64 %15
%17 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 0
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [8 x [3 x float]], [8 x [3 x float]]* %5, i64 0, i64 %19
%21 = getelementptr inbounds [3 x float], [3 x float]* %20, i64 0, i64 0
%22 = call i32 @mat4_mul_vec3(float** %13, float* %17, float* %21)
br label %23
23: ; preds = %11
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %8
26: ; preds = %8
%27 = load [4 x float]*, [4 x float]** %4
%28 = bitcast [4 x float]* %27 to float**
%29 = getelementptr inbounds [8 x [3 x float]], [8 x [3 x float]]* %5, i64 0, i64 0
%30 = bitcast [3 x float]* %29 to float**
%31 = call i32 @bbox_from_npoints(float** %28, i32 8, float** %30)
ret void
}

LLVM IR (-O2):
@__const.box_get_bbox.p = [8 x [3 x float]] [[3 x float] [float -1.000000e+00, float -1.000000e+00, float 1.000000e+00], [3 x float] [float 1.000000e+00, float -1.000000e+00, float 1.000000e+00], [3 x float] [float 1.000000e+00, float 1.000000e+00, float 1.000000e+00], [3 x float] [float -1.000000e+00, float 1.000000e+00, float 1.000000e+00], [3 x float] [float -1.000000e+00, float -1.000000e+00, float -1.000000e+00], [3 x float] [float 1.000000e+00, float -1.000000e+00, float -1.000000e+00], [3 x float] [float 1.000000e+00, float 1.000000e+00, float -1.000000e+00], [3 x float] [float -1.000000e+00, float 1.000000e+00, float -1.000000e+00]]
define void @box_get_bbox([4 x float]* %0, [4 x float]* %1) {
%3 = alloca [8 x [3 x float]]
%4 = bitcast [8 x [3 x float]]* %3 to i8*
%5 = bitcast [4 x float]* %0 to float**
%6 = getelementptr inbounds [8 x [3 x float]], [8 x [3 x float]]* %3, i64 0, i64 0, i64 0
%7 = call i32 @mat4_mul_vec3(float** %5, float* %6, float* %6)
%8 = getelementptr inbounds [8 x [3 x float]], [8 x [3 x float]]* %3, i64 0, i64 1, i64 0
%9 = call i32 @mat4_mul_vec3(float** %5, float* %8, float* %8)
%10 = getelementptr inbounds [8 x [3 x float]], [8 x [3 x float]]* %3, i64 0, i64 2, i64 0
%11 = call i32 @mat4_mul_vec3(float** %5, float* %10, float* %10)
%12 = getelementptr inbounds [8 x [3 x float]], [8 x [3 x float]]* %3, i64 0, i64 3, i64 0
%13 = call i32 @mat4_mul_vec3(float** %5, float* %12, float* %12)
%14 = getelementptr inbounds [8 x [3 x float]], [8 x [3 x float]]* %3, i64 0, i64 4, i64 0
%15 = call i32 @mat4_mul_vec3(float** %5, float* %14, float* %14)
%16 = getelementptr inbounds [8 x [3 x float]], [8 x [3 x float]]* %3, i64 0, i64 5, i64 0
%17 = call i32 @mat4_mul_vec3(float** %5, float* %16, float* %16)
%18 = getelementptr inbounds [8 x [3 x float]], [8 x [3 x float]]* %3, i64 0, i64 6, i64 0
%19 = call i32 @mat4_mul_vec3(float** %5, float* %18, float* %18)
%20 = getelementptr inbounds [8 x [3 x float]], [8 x [3 x float]]* %3, i64 0, i64 7, i64 0
%21 = call i32 @mat4_mul_vec3(float** %5, float* %20, float* %20)
%22 = bitcast [4 x float]* %1 to float**
%23 = bitcast [8 x [3 x float]]* %3 to float**
%24 = call i32 @bbox_from_npoints(float** %22, i32 8, float** %23)
ret void
}