#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 */
float fabsf(float);
int /*<<< orphan*/ planeBoxOverlap(float *, float *, float *);
int triBoxOverlap(float boxcenter[3], float boxhalfsize[3],
                  float triverts[3][3]) {
  float v0[3], v1[3], v2[3];
  float min, max, p0, p1, p2, rad, fex, fey, fez;
  float normal[3], e0[3], e1[3], e2[3];
  ;
  ;
  ;
  ;
  ;
  ;
  fex = fabsf(e0[0]);
  fey = fabsf(e0[1]);
  fez = fabsf(e0[2]);
  ;
  ;
  ;
  fex = fabsf(e1[0]);
  fey = fabsf(e1[1]);
  fez = fabsf(e1[2]);
  ;
  ;
  ;
  fex = fabsf(e2[0]);
  fey = fabsf(e2[1]);
  fez = fabsf(e2[2]);
  ;
  ;
  ;
  ;
  if (min > boxhalfsize[0] || max < -boxhalfsize[0])
    return 0;
  ;
  if (min > boxhalfsize[1] || max < -boxhalfsize[1])
    return 0;
  ;
  if (min > boxhalfsize[2] || max < -boxhalfsize[2])
    return 0;
  ;
  if (!planeBoxOverlap(normal, v0, boxhalfsize))
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<triBoxOverlap>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movss  -0x80(%rbp),%xmm0
movaps 0xecd(%rip),%xmm1
pand   %xmm1,%xmm0
movss  %xmm0,-0x60(%rbp)
movss  -0x7c(%rbp),%xmm0
movaps 0xeb8(%rip),%xmm1
pand   %xmm1,%xmm0
movss  %xmm0,-0x64(%rbp)
movss  -0x78(%rbp),%xmm0
movaps 0xea3(%rip),%xmm1
pand   %xmm1,%xmm0
movss  %xmm0,-0x68(%rbp)
movss  -0x8c(%rbp),%xmm0
ff
movaps 0xe8b(%rip),%xmm1
pand   %xmm1,%xmm0
movss  %xmm0,-0x60(%rbp)
movss  -0x88(%rbp),%xmm0
ff
movaps 0xe73(%rip),%xmm1
pand   %xmm1,%xmm0
movss  %xmm0,-0x64(%rbp)
movss  -0x84(%rbp),%xmm0
ff
movaps 0xe5b(%rip),%xmm1
pand   %xmm1,%xmm0
movss  %xmm0,-0x68(%rbp)
movss  -0x98(%rbp),%xmm0
ff
movaps 0xe43(%rip),%xmm1
pand   %xmm1,%xmm0
movss  %xmm0,-0x60(%rbp)
movss  -0x94(%rbp),%xmm0
ff
movaps 0xe2b(%rip),%xmm1
pand   %xmm1,%xmm0
movss  %xmm0,-0x64(%rbp)
movss  -0x90(%rbp),%xmm0
ff
movaps 0xe13(%rip),%xmm1
pand   %xmm1,%xmm0
movss  %xmm0,-0x68(%rbp)
movss  -0x48(%rbp),%xmm0
mov    -0x18(%rbp),%rax
ucomiss (%rax),%xmm0
ja     122b <triBoxOverlap+0x11b>
movss  -0x4c(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
ucomiss %xmm1,%xmm0
jbe    1237 <triBoxOverlap+0x127>
movl   $0x0,-0x4(%rbp)
jmp    12ea <triBoxOverlap+0x1da>
movss  -0x48(%rbp),%xmm0
mov    -0x18(%rbp),%rax
ucomiss 0x4(%rax),%xmm0
ja     126e <triBoxOverlap+0x15e>
movss  -0x4c(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movss  0x4(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
ucomiss %xmm1,%xmm0
jbe    127a <triBoxOverlap+0x16a>
movl   $0x0,-0x4(%rbp)
jmp    12ea <triBoxOverlap+0x1da>
movss  -0x48(%rbp),%xmm0
mov    -0x18(%rbp),%rax
ucomiss 0x8(%rax),%xmm0
ja     12b1 <triBoxOverlap+0x1a1>
movss  -0x4c(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movss  0x8(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
ucomiss %xmm1,%xmm0
jbe    12bd <triBoxOverlap+0x1ad>
movl   $0x0,-0x4(%rbp)
jmp    12ea <triBoxOverlap+0x1da>
lea    -0x74(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <planeBoxOverlap@plt>
cmp    $0x0,%eax
jne    12e3 <triBoxOverlap+0x1d3>
movl   $0x0,-0x4(%rbp)
jmp    12ea <triBoxOverlap+0x1da>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<triBoxOverlap>:
sub    $0x18,%rsp
mov    %rsi,%rdx
mov    %rsp,%rdi
lea    0xc(%rsp),%rsi
call   1030 <planeBoxOverlap@plt>
xor    %ecx,%ecx
test   %eax,%eax
setne  %cl
mov    %ecx,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32 @triBoxOverlap(float* %0, float* %1, [3 x float]* %2) {
%4 = alloca i32
%5 = alloca float*
%6 = alloca float*
%7 = alloca [3 x float]*
%8 = alloca [3 x float]
%9 = alloca [3 x float]
%10 = alloca [3 x float]
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca float
%20 = alloca [3 x float]
%21 = alloca [3 x float]
%22 = alloca [3 x float]
%23 = alloca [3 x float]
store float* %0, float** %5
store float* %1, float** %6
store [3 x float]* %2, [3 x float]** %7
%24 = getelementptr inbounds [3 x float], [3 x float]* %21, i64 0, i64 0
%25 = load float, float* %24
%26 = call float @llvm.fabs.f32(float %25)
store float %26, float* %17
%27 = getelementptr inbounds [3 x float], [3 x float]* %21, i64 0, i64 1
%28 = load float, float* %27
%29 = call float @llvm.fabs.f32(float %28)
store float %29, float* %18
%30 = getelementptr inbounds [3 x float], [3 x float]* %21, i64 0, i64 2
%31 = load float, float* %30
%32 = call float @llvm.fabs.f32(float %31)
store float %32, float* %19
%33 = getelementptr inbounds [3 x float], [3 x float]* %22, i64 0, i64 0
%34 = load float, float* %33
%35 = call float @llvm.fabs.f32(float %34)
store float %35, float* %17
%36 = getelementptr inbounds [3 x float], [3 x float]* %22, i64 0, i64 1
%37 = load float, float* %36
%38 = call float @llvm.fabs.f32(float %37)
store float %38, float* %18
%39 = getelementptr inbounds [3 x float], [3 x float]* %22, i64 0, i64 2
%40 = load float, float* %39
%41 = call float @llvm.fabs.f32(float %40)
store float %41, float* %19
%42 = getelementptr inbounds [3 x float], [3 x float]* %23, i64 0, i64 0
%43 = load float, float* %42
%44 = call float @llvm.fabs.f32(float %43)
store float %44, float* %17
%45 = getelementptr inbounds [3 x float], [3 x float]* %23, i64 0, i64 1
%46 = load float, float* %45
%47 = call float @llvm.fabs.f32(float %46)
store float %47, float* %18
%48 = getelementptr inbounds [3 x float], [3 x float]* %23, i64 0, i64 2
%49 = load float, float* %48
%50 = call float @llvm.fabs.f32(float %49)
store float %50, float* %19
%51 = load float, float* %11
%52 = load float*, float** %6
%53 = getelementptr inbounds float, float* %52, i64 0
%54 = load float, float* %53
%55 = fcmp ogt float %51, %54
br i1 %55, label %63, label %56
56: ; preds = %3
%57 = load float, float* %12
%58 = load float*, float** %6
%59 = getelementptr inbounds float, float* %58, i64 0
%60 = load float, float* %59
%61 = fneg float %60
%62 = fcmp olt float %57, %61
br i1 %62, label %63, label %64
63: ; preds = %56, %3
store i32 0, i32* %4
br label %100
64: ; preds = %56
%65 = load float, float* %11
%66 = load float*, float** %6
%67 = getelementptr inbounds float, float* %66, i64 1
%68 = load float, float* %67
%69 = fcmp ogt float %65, %68
br i1 %69, label %77, label %70
70: ; preds = %64
%71 = load float, float* %12
%72 = load float*, float** %6
%73 = getelementptr inbounds float, float* %72, i64 1
%74 = load float, float* %73
%75 = fneg float %74
%76 = fcmp olt float %71, %75
br i1 %76, label %77, label %78
77: ; preds = %70, %64
store i32 0, i32* %4
br label %100
78: ; preds = %70
%79 = load float, float* %11
%80 = load float*, float** %6
%81 = getelementptr inbounds float, float* %80, i64 2
%82 = load float, float* %81
%83 = fcmp ogt float %79, %82
br i1 %83, label %91, label %84
84: ; preds = %78
%85 = load float, float* %12
%86 = load float*, float** %6
%87 = getelementptr inbounds float, float* %86, i64 2
%88 = load float, float* %87
%89 = fneg float %88
%90 = fcmp olt float %85, %89
br i1 %90, label %91, label %92
91: ; preds = %84, %78
store i32 0, i32* %4
br label %100
92: ; preds = %84
%93 = getelementptr inbounds [3 x float], [3 x float]* %20, i64 0, i64 0
%94 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 0
%95 = load float*, float** %6
%96 = call i32 @planeBoxOverlap(float* %93, float* %94, float* %95)
%97 = icmp ne i32 %96, 0
br i1 %97, label %99, label %98
98: ; preds = %92
store i32 0, i32* %4
br label %100
99: ; preds = %92
store i32 1, i32* %4
br label %100
100: ; preds = %99, %98, %91, %77, %63
%101 = load i32, i32* %4
ret i32 %101
}

LLVM IR (-O2):
define i32 @triBoxOverlap(float* nocapture readnone %0, float* %1, [3 x float]* nocapture readnone %2) {
%4 = alloca [3 x float]
%5 = alloca [3 x float]
%6 = bitcast [3 x float]* %4 to i8*
%7 = bitcast [3 x float]* %5 to i8*
%8 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 0
%9 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 0
%10 = call i32 @planeBoxOverlap(float* %8, float* %9, float* %1)
%11 = icmp ne i32 %10, 0
%12 = zext i1 %11 to i32
ret i32 %12
}