#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*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ bbox_from_npoints(float **, int, float **);
int /*<<< orphan*/ box_is_bbox(float const **);
int /*<<< orphan*/ mat4_mul_vec3(float const **, float const *, float *);
int /*<<< orphan*/ vec3_copy(float const *, float *);
void box_move_face(const float b[4][4], int f, const float p[3],
                   float out[4][4]) {
  const float PS[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},
  };
  const int FS[6][4] = {{0, 1, 2, 3}, {5, 4, 7, 6}, {0, 4, 5, 1},
                        {2, 6, 7, 3}, {1, 5, 6, 2}, {0, 3, 7, 4}};
  const int FO[6] = {1, 0, 3, 2, 5, 4};
  float ps[5][3];
  int i;
  assert(box_is_bbox(b));
  f = FO[f];
  for (i = 0; i < 4; i++)
    mat4_mul_vec3(b, PS[FS[f][i]], ps[i]);
  vec3_copy(p, ps[4]);
  bbox_from_npoints(out, 5, ps);
}


x86 assembly (clang, -O0):
<box_move_face>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xe7b(%rip),%rsi
mov    $0x60,%edx
call   1060 <memcpy@plt>
lea    -0xe0(%rbp),%rdi
lea    0xec3(%rip),%rsi
mov    $0x60,%edx
call   1060 <memcpy@plt>
mov    0xf12(%rip),%rax
mov    %rax,-0x100(%rbp)
mov    0xf0c(%rip),%rax
mov    %rax,-0xf8(%rbp)
mov    0xf06(%rip),%rax
mov    %rax,-0xf0(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <box_is_bbox@plt>
mov    %eax,%edi
call   1050 <assert@plt>
movslq -0xc(%rbp),%rax
mov    -0x100(%rbp,%rax,4),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x144(%rbp)
cmpl   $0x4,-0x144(%rbp)
jge    1260 <box_move_face+0x100>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rcx
lea    -0xe0(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x144(%rbp),%rcx
movslq (%rax,%rcx,4),%rax
lea    -0x80(%rbp),%rsi
imul   $0xc,%rax,%rax
add    %rax,%rsi
movslq -0x144(%rbp),%rax
lea    -0x140(%rbp),%rdx
imul   $0xc,%rax,%rax
add    %rax,%rdx
call   1080 <mat4_mul_vec3@plt>
mov    -0x144(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x144(%rbp)
jmp    11f9 <box_move_face+0x99>
mov    -0x18(%rbp),%rdi
lea    -0x140(%rbp),%rsi
add    $0x30,%rsi
call   1070 <vec3_copy@plt>
mov    -0x20(%rbp),%rdi
lea    -0x140(%rbp),%rdx
mov    $0x5,%esi
call   1040 <bbox_from_npoints@plt>
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<box_move_face>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%ebp
mov    %rdi,%rbx
movaps 0xedd(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xec1(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xea5(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe89(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe6d(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe51(%rip),%xmm0
movaps %xmm0,(%rsp)
call   1030 <box_is_bbox@plt>
mov    %eax,%edi
call   1050 <assert@plt>
movslq %ebp,%rax
lea    0xef7(%rip),%rcx
movslq (%rcx,%rax,4),%rbp
shl    $0x4,%rbp
lea    0xe88(%rip),%r13
movslq 0x0(%rbp,%r13,1),%rax
lea    (%rax,%rax,2),%rax
lea    (%rsp,%rax,4),%rsi
lea    0x60(%rsp),%r12
mov    %rbx,%rdi
mov    %r12,%rdx
call   1070 <mat4_mul_vec3@plt>
movslq 0x4(%rbp,%r13,1),%rax
lea    (%rax,%rax,2),%rax
lea    (%rsp,%rax,4),%rsi
lea    0x6c(%rsp),%rdx
mov    %rbx,%rdi
call   1070 <mat4_mul_vec3@plt>
movslq 0x8(%rbp,%r13,1),%rax
lea    (%rax,%rax,2),%rax
lea    (%rsp,%rax,4),%rsi
lea    0x78(%rsp),%rdx
mov    %rbx,%rdi
call   1070 <mat4_mul_vec3@plt>
movslq 0xc(%rbp,%r13,1),%rax
lea    (%rax,%rax,2),%rax
lea    (%rsp,%rax,4),%rsi
lea    0x84(%rsp),%rdx
mov    %rbx,%rdi
call   1070 <mat4_mul_vec3@plt>
lea    0x90(%rsp),%rsi
mov    %r15,%rdi
call   1060 <vec3_copy@plt>
mov    %r14,%rdi
mov    $0x5,%esi
mov    %r12,%rdx
call   1040 <bbox_from_npoints@plt>
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.box_move_face.PS = [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]]
@__const.box_move_face.FS = [6 x [4 x i32]] [[4 x i32] [i32 0, i32 1, i32 2, i32 3], [4 x i32] [i32 5, i32 4, i32 7, i32 6], [4 x i32] [i32 0, i32 4, i32 5, i32 1], [4 x i32] [i32 2, i32 6, i32 7, i32 3], [4 x i32] [i32 1, i32 5, i32 6, i32 2], [4 x i32] [i32 0, i32 3, i32 7, i32 4]]
@__const.box_move_face.FO = [6 x i32] [i32 1, i32 0, i32 3, i32 2, i32 5, i32 4]
define void @box_move_face([4 x float]* %0, i32 %1, float* %2, [4 x float]* %3) {
%5 = alloca [4 x float]*
%6 = alloca i32
%7 = alloca float*
%8 = alloca [4 x float]*
%9 = alloca [8 x [3 x float]]
%10 = alloca [6 x [4 x i32]]
%11 = alloca [6 x i32]
%12 = alloca [5 x [3 x float]]
%13 = alloca i32
store [4 x float]* %0, [4 x float]** %5
store i32 %1, i32* %6
store float* %2, float** %7
store [4 x float]* %3, [4 x float]** %8
%14 = bitcast [8 x [3 x float]]* %9 to i8*
%15 = bitcast [6 x [4 x i32]]* %10 to i8*
%16 = bitcast [6 x i32]* %11 to i8*
%17 = load [4 x float]*, [4 x float]** %5
%18 = bitcast [4 x float]* %17 to float**
%19 = call i32 @box_is_bbox(float** %18)
%20 = call i32 @assert(i32 %19)
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [6 x i32], [6 x i32]* %11, i64 0, i64 %22
%24 = load i32, i32* %23
store i32 %24, i32* %6
store i32 0, i32* %13
br label %25
25: ; preds = %46, %4
%26 = load i32, i32* %13
%27 = icmp slt i32 %26, 4
br i1 %27, label %28, label %49
28: ; preds = %25
%29 = load [4 x float]*, [4 x float]** %5
%30 = bitcast [4 x float]* %29 to float**
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [6 x [4 x i32]], [6 x [4 x i32]]* %10, i64 0, i64 %32
%34 = load i32, i32* %13
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [4 x i32], [4 x i32]* %33, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [8 x [3 x float]], [8 x [3 x float]]* %9, i64 0, i64 %38
%40 = getelementptr inbounds [3 x float], [3 x float]* %39, i64 0, i64 0
%41 = load i32, i32* %13
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [5 x [3 x float]], [5 x [3 x float]]* %12, i64 0, i64 %42
%44 = getelementptr inbounds [3 x float], [3 x float]* %43, i64 0, i64 0
%45 = call i32 @mat4_mul_vec3(float** %30, float* %40, float* %44)
br label %46
46: ; preds = %28
%47 = load i32, i32* %13
%48 = add nsw i32 %47, 1
store i32 %48, i32* %13
br label %25
49: ; preds = %25
%50 = load float*, float** %7
%51 = getelementptr inbounds [5 x [3 x float]], [5 x [3 x float]]* %12, i64 0, i64 4
%52 = getelementptr inbounds [3 x float], [3 x float]* %51, i64 0, i64 0
%53 = call i32 @vec3_copy(float* %50, float* %52)
%54 = load [4 x float]*, [4 x float]** %8
%55 = bitcast [4 x float]* %54 to float**
%56 = getelementptr inbounds [5 x [3 x float]], [5 x [3 x float]]* %12, i64 0, i64 0
%57 = bitcast [3 x float]* %56 to float**
%58 = call i32 @bbox_from_npoints(float** %55, i32 5, float** %57)
ret void
}

LLVM IR (-O2):
@__const.box_move_face.PS = [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]]
@__const.box_move_face.FS = [6 x [4 x i32]] [[4 x i32] [i32 0, i32 1, i32 2, i32 3], [4 x i32] [i32 5, i32 4, i32 7, i32 6], [4 x i32] [i32 0, i32 4, i32 5, i32 1], [4 x i32] [i32 2, i32 6, i32 7, i32 3], [4 x i32] [i32 1, i32 5, i32 6, i32 2], [4 x i32] [i32 0, i32 3, i32 7, i32 4]]
@__const.box_move_face.FO = [6 x i32] [i32 1, i32 0, i32 3, i32 2, i32 5, i32 4]
define void @box_move_face([4 x float]* %0, i32 %1, float* %2, [4 x float]* %3) {
%5 = alloca [8 x [3 x float]]
%6 = alloca [5 x [3 x float]]
%7 = bitcast [8 x [3 x float]]* %5 to i8*
%8 = bitcast [5 x [3 x float]]* %6 to i8*
%9 = bitcast [4 x float]* %0 to float**
%10 = tail call i32 @box_is_bbox(float** %9)
%11 = tail call i32 @assert(i32 %10)
%12 = sext i32 %1 to i64
%13 = getelementptr inbounds [6 x i32], [6 x i32]* @__const.box_move_face.FO, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [6 x [4 x i32]], [6 x [4 x i32]]* @__const.box_move_face.FS, i64 0, i64 %15, i64 0
%17 = load i32, i32* %16
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [8 x [3 x float]], [8 x [3 x float]]* %5, i64 0, i64 %18, i64 0
%20 = getelementptr inbounds [5 x [3 x float]], [5 x [3 x float]]* %6, i64 0, i64 0, i64 0
%21 = call i32 @mat4_mul_vec3(float** %9, float* %19, float* %20)
%22 = getelementptr inbounds [6 x [4 x i32]], [6 x [4 x i32]]* @__const.box_move_face.FS, i64 0, i64 %15, i64 1
%23 = load i32, i32* %22
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [8 x [3 x float]], [8 x [3 x float]]* %5, i64 0, i64 %24, i64 0
%26 = getelementptr inbounds [5 x [3 x float]], [5 x [3 x float]]* %6, i64 0, i64 1, i64 0
%27 = call i32 @mat4_mul_vec3(float** %9, float* %25, float* %26)
%28 = getelementptr inbounds [6 x [4 x i32]], [6 x [4 x i32]]* @__const.box_move_face.FS, i64 0, i64 %15, i64 2
%29 = load i32, i32* %28
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [8 x [3 x float]], [8 x [3 x float]]* %5, i64 0, i64 %30, i64 0
%32 = getelementptr inbounds [5 x [3 x float]], [5 x [3 x float]]* %6, i64 0, i64 2, i64 0
%33 = call i32 @mat4_mul_vec3(float** %9, float* %31, float* %32)
%34 = getelementptr inbounds [6 x [4 x i32]], [6 x [4 x i32]]* @__const.box_move_face.FS, i64 0, i64 %15, i64 3
%35 = load i32, i32* %34
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [8 x [3 x float]], [8 x [3 x float]]* %5, i64 0, i64 %36, i64 0
%38 = getelementptr inbounds [5 x [3 x float]], [5 x [3 x float]]* %6, i64 0, i64 3, i64 0
%39 = call i32 @mat4_mul_vec3(float** %9, float* %37, float* %38)
%40 = getelementptr inbounds [5 x [3 x float]], [5 x [3 x float]]* %6, i64 0, i64 4, i64 0
%41 = call i32 @vec3_copy(float* %2, float* %40)
%42 = bitcast [4 x float]* %3 to float**
%43 = bitcast [5 x [3 x float]]* %6 to float**
%44 = call i32 @bbox_from_npoints(float** %42, i32 5, float** %43)
ret void
}