LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Triad::Draw() const
void R3Triad::
Draw(void) const
{
    // Draw three rays
    R3BeginLine();
    R3LoadPoint(R3zero_point);
    R3LoadPoint((R3zero_point + Axis(RN_X)));
    R3EndLine();
    R3BeginLine();
    R3LoadPoint(R3zero_point);
    R3LoadPoint((R3zero_point + Axis(RN_Y)));
    R3EndLine();
    R3BeginLine();
    R3LoadPoint(R3zero_point);
    R3LoadPoint((R3zero_point + Axis(RN_Z)));
    R3EndLine();
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
callq 0x21c38
leaq 0x4a06a8(%rip), %r14    # 0x4dba70
movq %r14, %rdi
callq 0xe130
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x37e13
movq %r15, %rdi
callq 0xe130
callq 0xe5f0
callq 0x21c38
movq %r14, %rdi
callq 0xe130
leaq 0x18(%rbx), %rdx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x37e13
movq %r15, %rdi
callq 0xe130
callq 0xe5f0
callq 0x21c38
movq %r14, %rdi
callq 0xe130
addq $0x30, %rbx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x37e13
movq %r15, %rdi
callq 0xe130
callq 0xe5f0
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3CoordSystem::Draw() const
void R3CoordSystem::
Draw(void) const
{
    // Draw three rays
    R3BeginLine();
    R3LoadPoint(Origin());
    R3LoadPoint((Origin() + Axes().Axis(RN_X)));
    R3EndLine();
    R3BeginLine();
    R3LoadPoint(Origin());
    R3LoadPoint((Origin() + Axes().Axis(RN_Y)));
    R3EndLine();
    R3BeginLine();
    R3LoadPoint(Origin());
    R3LoadPoint((Origin() + Axes().Axis(RN_Z)));
    R3EndLine();
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
callq 0x21c38
movq %rbx, %rdi
callq 0xe130
leaq 0x18(%rbx), %rdx
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x37e13
movq %r14, %rdi
callq 0xe130
callq 0xe5f0
callq 0x21c38
movq %rbx, %rdi
callq 0xe130
leaq 0x30(%rbx), %rdx
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x37e13
movq %r14, %rdi
callq 0xe130
callq 0xe5f0
callq 0x21c38
movq %rbx, %rdi
callq 0xe130
leaq 0x48(%rbx), %rdx
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x37e13
movq %r14, %rdi
callq 0xe130
callq 0xe5f0
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Affine::Load() const
void R3Affine::
Load(void) const
{
    // Load matrix onto stack
    Matrix().Load();

    // Set mirror flag
    if (IsMirrored()) {
        R3draw_mirrored = !R3draw_mirrored;
#if (RN_3D_GRFX == RN_OPENGL)
        glFrontFace((R3draw_mirrored) ? GL_CW : GL_CCW);
#else
	RNAbort("Not Implemented");
#endif
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
addq $0x8, %rdi
callq 0x3b348
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x18(%rax)
testl %eax, %eax
je 0x3b529
xorl %edi, %edi
cmpl $0x0, 0x4a066d(%rip)    # 0x4dbb80
sete %dil
movl %edi, 0x4a0663(%rip)    # 0x4dbb80
xorl $0x901, %edi            # imm = 0x901
popq %rbx
jmp 0xe0d0
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Affine::Draw() const
void R3Affine::
Draw(void) const
{
    // Multiply top of stack by matrix
    Matrix().Draw();

    // Set mirror flag - this screws up Push/Pop ???
    if (IsMirrored()) {
        R3draw_mirrored = !R3draw_mirrored;
#if (RN_3D_GRFX == RN_OPENGL)
        glFrontFace((R3draw_mirrored) ? GL_CW : GL_CCW);
#else
	RNAbort("Not Implemented");
#endif
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
addq $0x8, %rdi
callq 0x3b370
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x18(%rax)
testl %eax, %eax
je 0x3b565
xorl %edi, %edi
cmpl $0x0, 0x4a0631(%rip)    # 0x4dbb80
sete %dil
movl %edi, 0x4a0627(%rip)    # 0x4dbb80
xorl $0x901, %edi            # imm = 0x901
popq %rbx
jmp 0xe0d0
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Affine::Push() const
void R3Affine::
Push(void) const
{
    // Push matrix onto stack
    Matrix().Push();

    // Set mirror flag
    if (IsMirrored()) {
        R3draw_mirrored = !R3draw_mirrored;
#if (RN_3D_GRFX == RN_OPENGL)
        glFrontFace((R3draw_mirrored) ? GL_CW : GL_CCW);
#else
	RNAbort("Not Implemented");
#endif
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
addq $0x8, %rdi
callq 0x3b398
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x18(%rax)
testl %eax, %eax
je 0x3b5a1
xorl %edi, %edi
cmpl $0x0, 0x4a05f5(%rip)    # 0x4dbb80
sete %dil
movl %edi, 0x4a05eb(%rip)    # 0x4dbb80
xorl $0x901, %edi            # imm = 0x901
popq %rbx
jmp 0xe0d0
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Affine::Pop() const
void R3Affine::
Pop(void) const
{
    // Pop matrix off stack
    Matrix().Pop();

    // Restore mirror flag
    if (IsMirrored()) {
        R3draw_mirrored = !R3draw_mirrored;
#if (RN_3D_GRFX == RN_OPENGL)
        glFrontFace((R3draw_mirrored) ? GL_CW : GL_CCW);
#else
	RNAbort("Not Implemented");
#endif
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0xe880
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x18(%rax)
testl %eax, %eax
je 0x3b5d9
xorl %edi, %edi
cmpl $0x0, 0x4a05bd(%rip)    # 0x4dbb80
sete %dil
movl %edi, 0x4a05b3(%rip)    # 0x4dbb80
xorl $0x901, %edi            # imm = 0x901
popq %rbx
jmp 0xe0d0
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Vector::Draw() const
void R3Vector::
Draw(void) const
{
    // Draw vector from (0,0,0)
    R3BeginLine();
    R3LoadPoint(R3zero_point);
    R3LoadPoint((R3zero_point + *this));
    R3EndLine();
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
callq 0x21c38
leaq 0x4a047c(%rip), %r14    # 0x4dba70
movq %r14, %rdi
callq 0xe130
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x37e13
movq %r15, %rdi
callq 0xe130
callq 0xe5f0
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Line::Draw() const
void R3Line::
Draw(void) const
{
    // Draw line
    R3BeginLine();
    R3LoadPoint(Point());
    R3LoadPoint(Point() + Vector());
    R3EndLine();
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
callq 0x21c38
movq %rbx, %rdi
callq 0xe130
leaq 0x18(%rbx), %rdx
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x37e13
movq %r14, %rdi
callq 0xe130
callq 0xe5f0
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Span::Draw() const
void R3Span::
Draw(void) const
{
    // Draw span
    R3BeginLine();
    R3LoadPoint(Start());
    R3LoadPoint(End());
    R3EndLine();
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x21c38
movq %rbx, %rdi
callq 0xe130
addq $0x30, %rbx
movq %rbx, %rdi
callq 0xe130
popq %rbx
jmp 0xe5f0
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Circle::Draw(gaps::RNFlags) const
void R3Circle::
Draw(const R3DrawFlags draw_flags) const
{
    // Push matrix (Zaxis -> ScaledNormal + OffsetToCenter)
    R4Matrix matrix = R4identity_matrix;
    matrix.Translate(center.Vector());
    matrix.Rotate(R3posz_vector, Normal());
    matrix.Push();

    // Draw surface
    if (draw_flags[R3_SURFACES_DRAW_FLAG]) {
	// Load normal
	if (draw_flags[R3_SURFACE_NORMALS_DRAW_FLAG]) 
	    R3LoadNormal(R3posz_vector);

	// Draw circle in XY plane
	R3BeginPolygon();
	for (int i = 0; i < R3circle_npoints; i++) {
	    if (draw_flags[R3_VERTEX_TEXTURE_COORDS_DRAW_FLAG]) 
		R3LoadTextureCoords(R3circle_texcoords[i]);
	    R3LoadPoint(R3circle_points[i] * radius);
	}
	R3EndPolygon();
    }

    // Draw edges
    if (draw_flags[R3_EDGES_DRAW_FLAG]) {
	R3BeginLoop();
	for (int i = 0; i < R3circle_npoints; i++) 
	    R3LoadPoint(R3circle_points[i] * radius);
	R3EndLoop();
    }

    // Pop matrix
    matrix.Pop();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x58224(%rip), %rsi     # 0x93df0
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x2967c
leaq 0x8(%rbx), %rsi
leaq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0x212f8
movq %r15, %rdi
movq %r12, %rsi
callq 0x2a5cc
leaq 0x28(%rbx), %rdx
leaq 0x5daf0(%rip), %rsi     # 0x996f0
movq %r15, %rdi
callq 0x2aa9a
movq %r15, %rdi
callq 0x3b398
testb $0x2, %r14b
je 0x3bc9a
movq %r14, 0x8(%rsp)
testb $0x20, %r14b
je 0x3bc31
leaq 0x5dac4(%rip), %rdi     # 0x996f0
callq 0xe6e0
callq 0x21c40
leaq 0x5e483(%rip), %rax     # 0x9a0c0
movslq (%rax), %rbp
leaq 0x4a0439(%rip), %r15    # 0x4dc080
leaq 0x4a0732(%rip), %r12    # 0x4dc380
xorl %r14d, %r14d
leaq 0x10(%rsp), %r13
cmpq %rbp, %r14
jge 0x3bc90
btl $0x9, 0x8(%rsp)
jae 0x3bc6b
movq %r12, %rdi
callq 0xe120
movsd 0x20(%rbx), %xmm0
movq %r13, %rdi
movq %r15, %rsi
callq 0x382c0
movq %r13, %rdi
callq 0xe130
incq %r14
addq $0x18, %r15
addq $0x10, %r12
jmp 0x3bc56
callq 0xe5f0
movq 0x8(%rsp), %r14
testb $0x1, %r14b
je 0x3bce9
callq 0x3cc8e
leaq 0x5e414(%rip), %rax     # 0x9a0c0
movslq (%rax), %r12
leaq 0x4a03ca(%rip), %r14    # 0x4dc080
xorl %r13d, %r13d
leaq 0x10(%rsp), %r15
cmpq %r12, %r13
jge 0x3bce4
movsd 0x20(%rbx), %xmm0
movq %r15, %rdi
movq %r14, %rsi
callq 0x382c0
movq %r15, %rdi
callq 0xe130
incq %r13
addq $0x18, %r14
jmp 0x3bcbe
callq 0xe5f0
callq 0xe880
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Ellipse::Draw(gaps::RNFlags) const
void R3Ellipse::
Draw(const R3DrawFlags draw_flags) const
{
    // Push matrix
    R4Matrix matrix = R4identity_matrix;
    matrix.Transform(cs.Matrix());
    matrix.Scale(R3Vector(radii.X(), radii.Y(), 1.0));
    matrix.Push();

    // Draw unit sphere
    R3unit_circle.Draw(draw_flags);

    // Pop matrix
    matrix.Pop();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x580d5(%rip), %rsi     # 0x93df0
leaq 0x88(%rsp), %r14
movq %r14, %rdi
callq 0x2967c
leaq 0x8(%r15), %rsi
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x27dbc
movq %r14, %rdi
movq %r12, %rsi
callq 0x280fe
movsd 0x68(%r15), %xmm0
movsd 0x70(%r15), %xmm1
leaq 0x8(%rsp), %r15
movsd 0x572a8(%rip), %xmm2    # 0x93008
movq %r15, %rdi
callq 0x3830c
movq %r14, %rdi
movq %r15, %rsi
callq 0x2a6d4
movq %r14, %rdi
callq 0x3b398
leaq 0x4a016e(%rip), %rdi    # 0x4dbef0
movq %rbx, %rsi
callq 0x3bbae
callq 0xe880
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Polygon::Draw(gaps::RNFlags) const
void R3Polygon::
Draw(const R3DrawFlags draw_flags) const
{
    // Draw polygon
    if (draw_flags[R3_SURFACES_DRAW_FLAG]) {
        R3BeginPolygon();
        if (draw_flags[R3_SURFACE_NORMALS_DRAW_FLAG] ||
            draw_flags[R3_VERTEX_NORMALS_DRAW_FLAG])
            R3LoadNormal(plane.Normal());
        for (int i = 0; i < npoints; i++) {
            R3LoadPoint(points[i]);
        }
        R3EndPolygon();
    }
    if (draw_flags[R3_EDGES_DRAW_FLAG]) {
        R3BeginLoop();
        for (int i = 0; i < npoints; i++) {
            R3LoadPoint(points[i]);
        }
        R3EndLoop();
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
testb $0x2, %r14b
je 0x3bfe9
callq 0x21c40
testw $0x120, %r14w           # imm = 0x120
je 0x3bfc0
leaq 0x18(%rbx), %rdi
callq 0xe6e0
xorl %r15d, %r15d
xorl %r12d, %r12d
movslq 0x10(%rbx), %rax
cmpq %rax, %r12
jge 0x3bfe4
movq 0x8(%rbx), %rdi
addq %r15, %rdi
callq 0xe130
incq %r12
addq $0x18, %r15
jmp 0x3bfc6
callq 0xe5f0
testb $0x1, %r14b
jne 0x3bffb
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
callq 0x3cc8e
xorl %r14d, %r14d
xorl %r15d, %r15d
movslq 0x10(%rbx), %rax
cmpq %rax, %r15
jge 0x3c024
movq 0x8(%rbx), %rdi
addq %r14, %rdi
callq 0xe130
incq %r15
addq $0x18, %r14
jmp 0x3c006
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xe5f0
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Sphere::Draw(gaps::RNFlags) const
void R3Sphere::
Draw(const R3DrawFlags draw_flags) const
{
    // Draw sphere - sphdraw uses n3f only ???
#if (RN_3D_GRFX == RN_OPENGL)
    // Create GLU quadric
    static GLUquadricObj *sphere = gluNewQuadric(); // ???

    // Push matrix 
    R4Matrix matrix = R4identity_matrix;
    matrix.Translate(center.Vector());
    matrix.Push();

    // Draw surface
    if (draw_flags[R3_SURFACES_DRAW_FLAG]) {
	if (draw_flags[R3_VERTEX_NORMALS_DRAW_FLAG]) gluQuadricNormals(sphere, (GLenum) GLU_SMOOTH);
	else if (draw_flags[R3_SURFACE_NORMALS_DRAW_FLAG]) gluQuadricNormals(sphere, (GLenum) GLU_FLAT);
	if (draw_flags[R3_VERTEX_TEXTURE_COORDS_DRAW_FLAG]) gluQuadricTexture(sphere, GL_TRUE);
	else gluQuadricTexture(sphere, GL_FALSE);
	gluQuadricDrawStyle(sphere, (GLenum) GLU_FILL);
	gluSphere(sphere, radius, 16, 8);
    }

    // Draw edges
    if (draw_flags[R3_EDGES_DRAW_FLAG]) {
	gluQuadricNormals(sphere, (GLenum) GLU_NONE);
	gluQuadricTexture(sphere, GL_FALSE);
	gluQuadricDrawStyle(sphere, (GLenum) GLU_SILHOUETTE);
	gluSphere(sphere, radius, 16, 8);
    }

    // Pop matrix
    matrix.Pop();
#else
    RNAbort("Not Implemented");
#endif
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movb 0x49f294(%rip), %al     # 0x4dbd40
testb %al, %al
je 0x3cbb1
leaq 0x57335(%rip), %rsi     # 0x93df0
leaq 0x18(%rsp), %r15
movq %r15, %rdi
callq 0x2967c
leaq 0x8(%rbx), %rsi
movq %rsp, %r12
movq %r12, %rdi
callq 0x212f8
movq %r15, %rdi
movq %r12, %rsi
callq 0x2a5cc
movq %r15, %rdi
callq 0x3b398
testb $0x2, %r14b
je 0x3cb50
movl $0x186a0, %esi          # imm = 0x186A0
btl $0x8, %r14d
jb 0x3cb07
movl $0x186a1, %esi          # imm = 0x186A1
testb $0x20, %r14b
je 0x3cb13
movq 0x49f22a(%rip), %rdi    # 0x4dbd38
callq 0xe1d0
movl %r14d, %esi
shrl $0x9, %esi
movq 0x49f218(%rip), %rdi    # 0x4dbd38
andl $0x1, %esi
callq 0xe860
movq 0x49f209(%rip), %rdi    # 0x4dbd38
movl $0x186ac, %esi          # imm = 0x186AC
callq 0xe7a0
movq 0x49f1f8(%rip), %rdi    # 0x4dbd38
movsd 0x20(%rbx), %xmm0
pushq $0x10
popq %rsi
pushq $0x8
popq %rdx
callq 0xe230
testb $0x1, %r14b
je 0x3cb9d
movq 0x49f1db(%rip), %rdi    # 0x4dbd38
movl $0x186a2, %esi          # imm = 0x186A2
callq 0xe1d0
movq 0x49f1ca(%rip), %rdi    # 0x4dbd38
xorl %esi, %esi
callq 0xe860
movq 0x49f1bc(%rip), %rdi    # 0x4dbd38
movl $0x186ad, %esi          # imm = 0x186AD
callq 0xe7a0
movq 0x49f1ab(%rip), %rdi    # 0x4dbd38
movsd 0x20(%rbx), %xmm0
pushq $0x10
popq %rsi
pushq $0x8
popq %rdx
callq 0xe230
callq 0xe880
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x49f188(%rip), %rdi    # 0x4dbd40
callq 0xe840
testl %eax, %eax
je 0x3cab4
callq 0xe520
movq %rax, 0x49f167(%rip)    # 0x4dbd38
leaq 0x49f168(%rip), %rdi    # 0x4dbd40
callq 0xe2f0
jmp 0x3cab4
movq %rax, %rbx
leaq 0x49f154(%rip), %rdi    # 0x4dbd40
callq 0xe2e0
movq %rbx, %rdi
callq 0xe810
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Ellipsoid::Draw(gaps::RNFlags) const
void R3Ellipsoid::
Draw(const R3DrawFlags draw_flags) const
{
    // Push matrix
    R4Matrix matrix = R4identity_matrix;
    matrix.Transform(cs.Matrix());
    matrix.Scale(radii);
    matrix.Push();

    // Draw unit sphere
    R3unit_sphere.Draw(draw_flags);

    // Pop matrix
    matrix.Pop();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x571db(%rip), %rsi     # 0x93df0
leaq 0x88(%rsp), %r15
movq %r15, %rdi
callq 0x2967c
leaq 0x8(%r14), %rsi
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x27dbc
movq %r15, %rdi
movq %r12, %rsi
callq 0x280fe
addq $0x68, %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x2a6d4
movq %r15, %rdi
callq 0x3b398
leaq 0x9e141(%rip), %rdi     # 0xdada0
movq %rbx, %rsi
callq 0x3ca92
callq 0xe880
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Line const&, gaps::R3Span const&, gaps::R3Point*, double*)
RNClassID R3Intersects(const R3Line& line, const R3Span& span, 
    R3Point *hit_point, RNScalar *hit_t)
{
    // Intersect line with span's ray
    RNScalar s;
    switch (R3Intersects(line, span.Ray(), hit_point, &s)) {
    case RN_NULL_CLASS_ID:
	// Span and line do not intersect
	return RN_NULL_CLASS_ID;

    case R3_RAY_CLASS_ID:
	// Line contains span
	return R3_SPAN_CLASS_ID;

    case R3_POINT_CLASS_ID: 
	// Check if intersection point is on span
	if (RNIsGreater(s, span.Length())) {
	    // Span's ray intersects line beyond span endpoint
	    return RN_NULL_CLASS_ID;
	}
	else {
	    // Span and line intersect at point
	    if (hit_t) *hit_t = s;
	    return R3_POINT_CLASS_ID;
	}
	break;

    default:
	RNAbort("Illegal intersection");
	break;
    }

    // Should never get here
    RNAbort("Should never get here");
    return RN_NULL_CLASS_ID;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rcx, %r14
movq %rsi, %r15
leaq 0x8(%rsp), %rcx
callq 0x3d0f9
movl %eax, %ebx
movl %eax, %eax
leaq 0x5cc50(%rip), %rcx     # 0x99f08
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsd 0x8(%rsp), %xmm0
leaq 0x9d8da(%rip), %rax     # 0xdaba8
movapd %xmm0, %xmm1
subsd 0x48(%r15), %xmm1
xorl %ebx, %ebx
ucomisd (%rax), %xmm1
ja 0x3d312
pushq $0x1
popq %rbx
testq %r14, %r14
je 0x3d312
movsd %xmm0, (%r14)
jmp 0x3d312
leaq 0x5cc86(%rip), %rdi     # 0x99f7c
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x680f0
leaq 0x5cc8b(%rip), %rdi     # 0x99f91
xorl %eax, %eax
callq 0x680f0
jmp 0x3d312
pushq $0x4
popq %rbx
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Line const&, gaps::R3Plane const&, gaps::R3Point*)
RNClassID R3Intersects(const R3Line& line, const R3Plane& plane, 
    R3Point *hit_point)
{
    // Compute dot product of line vector and plane normal
    RNScalar denom = plane.Normal().Dot(line.Vector());

    // Check if line and plane are parallel
    if (RNIsZero(denom)) {
	// Check if line lies in plane	
	if (R3Contains(plane, line.Point())) {
	    // Line lies in plane
	    return R3_LINE_CLASS_ID;
	}
	else {
	    // Line is parallel to plane, but not in it
	    return RN_NULL_CLASS_ID;
	}
    }
    else {
	// Line and plane are not parallel - they must intersect at a point
	if (hit_point) {
	    RNScalar t = -(R3SignedDistance(plane, line.Point())) / denom;
	    *hit_point = line.Point() + line.Vector() * t;
	}
	return R3_POINT_CLASS_ID;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r14
leaq 0x18(%rdi), %r15
movq %rsi, %rdi
movq %r15, %rsi
callq 0x38586
leaq 0x9d85f(%rip), %rax     # 0xdaba8
movsd (%rax), %xmm2
movapd 0x55cdb(%rip), %xmm1    # 0x93030
xorpd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x3d37c
ucomisd %xmm0, %xmm2
jb 0x3d37c
movq %r12, %rdi
movq %r14, %rsi
callq 0x415ce
xorl %ebp, %ebp
testl %eax, %eax
setne %bpl
addl %ebp, %ebp
jmp 0x3d3d1
pushq $0x1
popq %rbp
testq %rbx, %rbx
je 0x3d3d1
movq %r12, %rdi
movq %r14, %rsi
movsd %xmm0, 0x8(%rsp)
callq 0x43420
xorpd 0x55c93(%rip), %xmm0    # 0x93030
divsd 0x8(%rsp), %xmm0
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x38a02
leaq 0x28(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x37e13
movq %rbx, %rdi
movq %r15, %rsi
callq 0x37e36
movl %ebp, %eax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Line const&, gaps::R3Triangle const&, gaps::R3Point*)
RNClassID R3Intersects(const R3Line& line, const R3Triangle& triangle, 
    R3Point *hit_point)
{
    // Find intersection of line and plane
    R3Point p;
    switch (R3Intersects(line, triangle.Plane(), &p)) {
    case RN_NULL_CLASS_ID:
	// Line does not intersect triangle plane
	return RN_NULL_CLASS_ID;
	
    case R3_POINT_CLASS_ID:
	// Line intersects triangle plane in a single point
	// Check whether triangle contains intersection point
	if (!R3Contains(triangle, p)) return RN_NULL_CLASS_ID;
	if (hit_point) *hit_point = p;
	return R3_POINT_CLASS_ID;

    case R3_LINE_CLASS_ID: 
	// Line lies in triangle plane 
	// Intersect line and triangle in 2D
        // RNAbort("Case not implemented");
	return R3_SPAN_CLASS_ID;

    default:
	RNAbort("Invalid intersection result");
	break;
    }

    // Should never get here
    RNAbort("Should never get here");
    return RN_NULL_CLASS_ID;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x37b4a
leaq 0x20(%r14), %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x3d31e
movl %eax, %ebp
testl %eax, %eax
je 0x3d44b
cmpl $0x2, %ebp
jne 0x3d421
pushq $0x4
popq %rbp
jmp 0x3d44b
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x4182a
testl %eax, %eax
je 0x3d449
pushq $0x1
popq %rbp
testq %rbx, %rbx
je 0x3d44b
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x37e36
jmp 0x3d44b
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Line const&, gaps::R3Halfspace const&, gaps::R3Ray*)
RNClassID R3Intersects(const R3Line& line, const R3Halfspace& halfspace, 
    R3Ray *result)
{
    // Compute dot product of line vector and halfspace plane normal
    RNScalar denom = halfspace.Plane().Normal().Dot(line.Vector());

    // Check if line and halfspace plane are parallel
    if (RNIsZero(denom)) {
	// Check if line lies in halfspace
	if (R3Contains(halfspace, line.Point())) {
	    // Line lies in halfspace
	    return R3_LINE_CLASS_ID;
	}
	else {
	    // Line is parallel to halfspace plane, but not in halfspace
	    return RN_NULL_CLASS_ID;
	}
    }
    else {
	// Line and halfspace plane are not parallel - intersection must be a ray
	if (result) {
	    RNScalar t = -(R3SignedDistance(halfspace.Plane(), line.Point())) / denom;
	    R3Point point = line.Point() + line.Vector() * t;
	    R3Vector vector = (RNIsPositive(denom)) ? line.Vector() : -(line.Vector());
	    *result = R3Ray(point, vector);
	}
	return R3_RAY_CLASS_ID;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r15
leaq 0x18(%rdi), %r14
movq %rsi, %rdi
movq %r14, %rsi
callq 0x38586
leaq 0x9d721(%rip), %r13     # 0xdaba8
movsd (%r13), %xmm2
movapd 0x55b9b(%rip), %xmm1    # 0x93030
xorpd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x3d4bf
ucomisd %xmm0, %xmm2
jb 0x3d4bf
movq %r12, %rdi
movq %r15, %rsi
callq 0x41e66
xorl %ebp, %ebp
testl %eax, %eax
setne %bpl
addl %ebp, %ebp
jmp 0x3d555
pushq $0x3
popq %rbp
testq %rbx, %rbx
je 0x3d555
movq %r12, %rdi
movq %r15, %rsi
movsd %xmm0, (%rsp)
callq 0x43420
xorpd 0x55b4d(%rip), %xmm0    # 0x93030
divsd (%rsp), %xmm0
leaq 0x38(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x38a02
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x37e13
movsd (%rsp), %xmm0
ucomisd (%r13), %xmm0
ja 0x3d524
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x38c72
jmp 0x3d531
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x3831c
leaq 0x38(%rsp), %r14
leaq 0x20(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x3775e
movq %rbx, %rdi
movq %r14, %rsi
callq 0x22b4c
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Line const&, gaps::R3OrientedBox const&, gaps::R3Point*)
RNClassID R3Intersects(const R3Line& line, const R3OrientedBox& box, 
    R3Point *hit_point)
{
    // Check if box is empty
    if (box.IsEmpty()) return RN_NULL_CLASS_ID;

    // Transform line into std coordinate system
    R3Line transformed_line = line;
    R3Affine cs_to_std_xform(box.CoordSystem().InverseMatrix());
    transformed_line.Transform(cs_to_std_xform);

    // Intersect in std coordinate system
    R3Box axis_aligned_box(-box.Radius(0), -box.Radius(1), -box.Radius(2), box.Radius(0), box.Radius(1), box.Radius(2));
    int status = R3Intersects(transformed_line, axis_aligned_box, hit_point);
    if (status == RN_NULL_CLASS_ID) return RN_NULL_CLASS_ID;

    // Compute hit point
    if (hit_point) {
      R3Affine std_to_cs_xform(box.CoordSystem().Matrix());
      hit_point->Transform(std_to_cs_xform);
    }

    // Return whether hit
    return status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x308, %rsp            # imm = 0x308
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq %rsi, %rdi
callq 0x22b76
xorl %ebp, %ebp
testl %eax, %eax
jne 0x3d822
leaq 0x38(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x3783c
leaq 0x8(%r15), %r14
leaq 0x68(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x27e20
leaq 0x1f8(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x276a0
movq %r12, %rdi
movq %rbp, %rsi
callq 0x37a4a
movsd 0x68(%r15), %xmm3
movsd 0x70(%r15), %xmm4
movaps 0x5589c(%rip), %xmm2    # 0x93030
movaps %xmm3, %xmm0
xorps %xmm2, %xmm0
movaps %xmm4, %xmm1
xorps %xmm2, %xmm1
movsd 0x78(%r15), %xmm5
xorps %xmm5, %xmm2
movq %rsp, %rdi
callq 0x24bde
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
movq %rbx, %rdx
callq 0x3d566
movl %eax, %ebp
testl %eax, %eax
sete %al
testq %rbx, %rbx
sete %cl
orb %al, %cl
jne 0x3d80d
leaq 0x178(%rsp), %rdi
movq %r14, %rsi
callq 0x27dbc
leaq 0x68(%rsp), %rdi
leaq 0x178(%rsp), %rsi
xorl %edx, %edx
callq 0x276a0
leaq 0x68(%rsp), %rsi
movq %rbx, %rdi
callq 0x38192
leaq 0x68(%rsp), %rdi
callq 0x276ee
movq %rsp, %rdi
callq 0x25832
leaq 0x1f8(%rsp), %rdi
callq 0x276ee
movl %ebp, %eax
addq $0x308, %rsp            # imm = 0x308
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x276ee
jmp 0x3d84a
jmp 0x3d847
movq %rax, %rbx
movq %rsp, %rdi
callq 0x25832
jmp 0x3d859
jmp 0x3d856
movq %rax, %rbx
leaq 0x1f8(%rsp), %rdi
callq 0x276ee
movq %rbx, %rdi
callq 0xe810
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Line const&, gaps::R3Sphere const&, gaps::R3Point*)
RNClassID R3Intersects(const R3Line& line, const R3Sphere& sphere, 
    R3Point *hit_point)
{
    // Check if sphere contains line point
    if (R3Contains(sphere, line.Point())) {
	if (hit_point) *hit_point = line.Point();
	return R3_SPAN_CLASS_ID;
    }
    else {
	// Check if line points towards sphere
	R3Vector EO = sphere.Center() - line.Point();
	RNScalar v = EO.Dot(line.Vector());

	// Compute possible intersection -- Graphics Gems I, p. 388    
	RNScalar disc = sphere.Radius() * sphere.Radius() - (EO.Dot(EO) - v*v);
	if (RNIsNegative(disc)) {
	    // No intersection
	    return RN_NULL_CLASS_ID;
	}
	else {
	    // Line intersects sphere (it grazes if disc is zero)
	    if (hit_point) {
		RNScalar d = sqrt(disc);
		RNScalar t = v - d;
		*hit_point = line.Point() + t * line.Vector();
	    }
	    
	    // Return result
	    if (RNIsZero(disc)) return R3_POINT_CLASS_ID;
	    else return R3_SPAN_CLASS_ID;
	}
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r14
movq %rsi, %rdi
movq %r14, %rsi
callq 0x42b58
testl %eax, %eax
je 0x3d8b0
pushq $0x4
popq %rbp
testq %rbx, %rbx
je 0x3d9be
movq %rbx, %rdi
movq %r14, %rsi
callq 0x37e36
jmp 0x3d9be
leaq 0x8(%r12), %rsi
leaq 0x40(%rsp), %r13
movq %r13, %rdi
movq %r14, %rdx
callq 0x37d29
leaq 0x18(%r14), %r15
movq %r13, %rdi
movq %r15, %rsi
callq 0x38586
movsd %xmm0, 0x8(%rsp)
movsd 0x20(%r12), %xmm0
movsd %xmm0, (%rsp)
movq %r13, %rdi
movq %r13, %rsi
callq 0x38586
movsd (%rsp), %xmm2
movsd 0x8(%rsp), %xmm1
mulsd %xmm1, %xmm1
subsd %xmm1, %xmm0
mulsd %xmm2, %xmm2
subsd %xmm0, %xmm2
leaq 0x9d295(%rip), %r13     # 0xdaba8
movsd (%r13), %xmm1
movapd 0x5570f(%rip), %xmm0    # 0x93030
xorpd %xmm1, %xmm0
xorl %ebp, %ebp
ucomisd %xmm2, %xmm0
ja 0x3d9be
testq %rbx, %rbx
je 0x3d9a7
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm2
movsd %xmm2, (%rsp)
jb 0x3d94b
sqrtsd %xmm2, %xmm0
jmp 0x3d954
movapd %xmm2, %xmm0
callq 0xe350
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movapd %xmm1, %xmm0
callq 0x38a02
leaq 0x28(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x37e13
movq %rbx, %rdi
movq %r15, %rsi
callq 0x37e36
movsd (%r13), %xmm1
movapd 0x55692(%rip), %xmm0    # 0x93030
xorpd %xmm1, %xmm0
movsd (%rsp), %xmm2
xorl %eax, %eax
ucomisd %xmm2, %xmm1
setb %al
ucomisd %xmm0, %xmm2
leal 0x1(%rax,%rax,2), %eax
pushq $0x4
popq %rbp
cmovael %eax, %ebp
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Ray const&, gaps::R3Span const&, gaps::R3Point*, double*, double*)
RNClassID R3Intersects(const R3Ray& ray, const R3Span& span, 
    R3Point *hit_point, RNScalar *hit_tray, RNScalar *hit_tspan)
{
    // Intersect ray with span's ray
    RNScalar s1 = 0, s2 = 0;
    switch (R3Intersects(ray, span.Ray(), hit_point, &s1, &s2)) {
    case RN_NULL_CLASS_ID:
	// Span and ray do not intersect
	return RN_NULL_CLASS_ID;

    case R3_SPAN_CLASS_ID:
	// Ray and span point at each other on same line
	return R3_SPAN_CLASS_ID;

    case R3_RAY_CLASS_ID:
	// Ray and span point in same direction on same line
	if (RNIsGreater(s2, span.Length())) {
	    // Intersection is beyond span endpoint 
	    return RN_NULL_CLASS_ID;
	}
	else if (RNIsEqual(s2, span.Length())) {
	    // Span endpoint is ray start point
	    if (hit_tray) *hit_tray = s1;
	    if (hit_tspan) *hit_tspan = s2;
	    return R3_POINT_CLASS_ID;
	}
	else {
	    // Span and ray have non-null intersection in same line
	    return R3_SPAN_CLASS_ID;
	}
	break;

    case R3_POINT_CLASS_ID: 
	// Check if intersection point is on span
	if (RNIsGreater(s2, span.Length())) {
	    // Intersection is beyond span endpoint 
	    return RN_NULL_CLASS_ID;
	}
	else {
	    // Span and ray intersect at point
	    if (hit_tray) *hit_tray = s1;
	    if (hit_tspan) *hit_tspan = s2;
	    return R3_POINT_CLASS_ID;
	}
	break;

    default:
	RNAbort("Illegal intersection");
	break;
    }

    // Should never get here
    RNAbort("Should never get here");
    return RN_NULL_CLASS_ID;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %r8, %rbx
movq %rcx, %r14
movq %rsi, %r15
leaq 0x10(%rsp), %rcx
andq $0x0, (%rcx)
leaq 0x8(%rsp), %r8
andq $0x0, (%r8)
callq 0x3d9f7
cmpl $0x4, %eax
ja 0x3dc07
movl %eax, %ebp
movl %eax, %eax
leaq 0x5c3a7(%rip), %rcx     # 0x99f28
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsd 0x8(%rsp), %xmm0
movapd %xmm0, %xmm1
subsd 0x48(%r15), %xmm1
leaq 0x9d007(%rip), %rax     # 0xdaba8
ucomisd (%rax), %xmm1
jbe 0x3dbe5
jmp 0x3dc03
movsd 0x8(%rsp), %xmm0
leaq 0x9cff2(%rip), %rax     # 0xdaba8
movsd (%rax), %xmm1
movapd %xmm0, %xmm2
subsd 0x48(%r15), %xmm2
ucomisd %xmm1, %xmm2
ja 0x3dc03
movapd 0x5545e(%rip), %xmm3    # 0x93030
xorpd %xmm1, %xmm3
ucomisd %xmm3, %xmm2
pushq $0x4
popq %rbp
jb 0x3dc25
ucomisd %xmm2, %xmm1
jb 0x3dc25
testq %r14, %r14
je 0x3dbf5
movsd 0x10(%rsp), %xmm1
movsd %xmm1, (%r14)
pushq $0x1
popq %rbp
testq %rbx, %rbx
je 0x3dc25
movsd %xmm0, (%rbx)
jmp 0x3dc25
xorl %ebp, %ebp
jmp 0x3dc25
leaq 0x5c36e(%rip), %rdi     # 0x99f7c
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x680f0
leaq 0x5c373(%rip), %rdi     # 0x99f91
xorl %eax, %eax
callq 0x680f0
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Ray const&, gaps::R3Plane const&, gaps::R3Point*, double*)
RNClassID R3Intersects(const R3Ray& ray, const R3Plane& plane, 
    R3Point *hit_point, RNScalar *hit_t)
{
    // Compute dot product of ray vector and plane normal
    RNScalar denom = plane.Normal().Dot(ray.Vector());

    // Check if ray and plane are parallel
    if (RNIsZero(denom)) {
	// Check if ray lies in plane	
	if (R3Contains(plane, ray.Start())) {
	    // Ray lies in plane
	    return R3_RAY_CLASS_ID;
	}
	else {
	    // Ray is parallel to plane, but not in it
	    return RN_NULL_CLASS_ID;
	}
    }
    else {
	// Ray and plane are not parallel - compute parametric value on ray
	RNScalar s = -(R3SignedDistance(plane, ray.Start())) / denom;
	if (RNIsNegative(s)) {
	    // Ray is directed away from plane
	    return RN_NULL_CLASS_ID;
	}
	else {
	    // Ray is not parallel to plane and is pointing at plane - it must intersect
	    if (hit_point) *hit_point = ray.Start() + ray.Vector() * s;
	    if (hit_t) *hit_t = s;
	    return R3_POINT_CLASS_ID;
	}
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %r15
leaq 0x18(%rdi), %r12
movq %rsi, %rdi
movq %r12, %rsi
callq 0x38586
leaq 0x9cf46(%rip), %rbp     # 0xdaba8
movsd (%rbp), %xmm2
movapd 0x553c1(%rip), %xmm1    # 0x93030
xorpd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x3dc96
ucomisd %xmm0, %xmm2
jb 0x3dc96
movq %r13, %rdi
movq %r15, %rsi
callq 0x415ce
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
leal (%rcx,%rcx,2), %eax
jmp 0x3dd11
movq %r13, %rdi
movq %r15, %rsi
movsd %xmm0, (%rsp)
callq 0x43420
movapd 0x55382(%rip), %xmm2    # 0x93030
xorpd %xmm2, %xmm0
divsd (%rsp), %xmm0
movsd (%rbp), %xmm1
xorpd %xmm2, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
ja 0x3dd11
testq %r14, %r14
je 0x3dd05
leaq 0x18(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
movapd %xmm0, (%rsp)
callq 0x38a02
leaq 0x30(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x37e13
movq %r14, %rdi
movq %r12, %rsi
callq 0x37e36
movapd (%rsp), %xmm0
pushq $0x1
popq %rax
testq %rbx, %rbx
je 0x3dd11
movsd %xmm0, (%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Ray const&, gaps::R3Halfspace const&, gaps::R3Point*, double*)
RNClassID R3Intersects(const R3Ray& ray, const R3Halfspace& halfspace, 
    R3Point *hit_point, RNScalar *hit_t)
{
    // Check if halfspace contains point
    RNBoolean pinside = R3Contains(halfspace, ray.Start());

    // Check whether vectors point in same direction
    RNBoolean vinside = RNIsPositive(halfspace.Normal().Dot(ray.Vector()));

    // Classify ray with respect to halfspace
    if (pinside) {
	// Start point of ray is inside halfspace
	if (hit_point) *hit_point = ray.Start();
	if (hit_t) *hit_t = 0.0;
	if (vinside) return R3_RAY_CLASS_ID;
	else return R3_SPAN_CLASS_ID;
    }
    else {
	if (vinside) return R3Intersects(ray, halfspace.Plane(), hit_point, hit_t);
	else return RN_NULL_CLASS_ID;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r15
movq %rsi, %rdi
movq %r15, %rsi
callq 0x41e66
movl %eax, %ebp
leaq 0x18(%r15), %rsi
movq %r12, %rdi
callq 0x38586
leaq 0x9ce50(%rip), %rax     # 0xdaba8
movsd (%rax), %xmm1
testl %ebp, %ebp
je 0x3dd9d
testq %r14, %r14
je 0x3dd86
movq %r14, %rdi
movq %r15, %rsi
movsd %xmm0, 0x8(%rsp)
movsd %xmm1, (%rsp)
callq 0x37e36
movsd (%rsp), %xmm1
movsd 0x8(%rsp), %xmm0
testq %rbx, %rbx
je 0x3dd8f
andq $0x0, (%rbx)
xorl %eax, %eax
ucomisd %xmm1, %xmm0
setbe %al
addl $0x3, %eax
jmp 0x3dda5
xorl %eax, %eax
ucomisd %xmm1, %xmm0
ja 0x3ddb2
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %rbx, %rcx
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x3dc32
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Ray const&, gaps::R3Triangle const&, gaps::R3Point*, gaps::R3Vector*, double*)
RNClassID R3Intersects(const R3Ray& ray, const R3Triangle& triangle, 
    R3Point *hit_point, R3Vector *hit_normal, RNScalar *hit_t)
{
    // Find intersection of ray and plane
    R3Point p1;
    RNScalar t1;
    switch (R3Intersects(ray, triangle.Plane(), &p1, &t1)) {
    case RN_NULL_CLASS_ID:
	// Ray does not intersect triangle plane
	return RN_NULL_CLASS_ID;
	
    case R3_POINT_CLASS_ID:
	// Ray intersects triangle plane in a single point
	// Check whether triangle contains intersection point
	if (!R3Contains(triangle, p1)) return RN_NULL_CLASS_ID;
	if (hit_point) *hit_point = p1;
	if (hit_normal) *hit_normal = triangle.Normal();
	if (hit_t) *hit_t = t1;
	return R3_POINT_CLASS_ID;

    case R3_RAY_CLASS_ID: 
	// Ray lies in triangle plane 
	// Intersect ray and triangle in 2D
	// RNAbort("Case not implemented");
	// return R3_SPAN_CLASS_ID;
	return RN_NULL_CLASS_ID;

    default:
	RNAbort("Invalid intersection result");
	break;
    }

    // Should never get here
    RNAbort("Should never get here");
    return RN_NULL_CLASS_ID;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, (%rsp)
movq %rcx, %r12
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %rbp
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x37b4a
leaq 0x20(%r13), %r15
leaq 0x8(%rsp), %rcx
movq %rbp, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x3dc32
xorl %ebp, %ebp
movl %eax, %eax
leaq 0x5c120(%rip), %rcx     # 0x99f3c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r14, %rbx
movq (%rsp), %r14
leaq 0x10(%rsp), %rsi
movq %r13, %rdi
callq 0x4182a
testl %eax, %eax
je 0x3de92
testq %rbx, %rbx
je 0x3de4f
movq %rbx, %rdi
leaq 0x10(%rsp), %rsi
callq 0x37e36
testq %r12, %r12
je 0x3de5f
movq %r12, %rdi
movq %r15, %rsi
callq 0x3887c
pushq $0x1
popq %rbp
testq %r14, %r14
je 0x3de92
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%r14)
jmp 0x3de92
leaq 0x5c12c(%rip), %rdi     # 0x99fa7
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x680f0
leaq 0x5c106(%rip), %rdi     # 0x99f91
xorl %eax, %eax
callq 0x680f0
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Ray const&, gaps::R3TriangleArray const&, gaps::R3Point*, gaps::R3Vector*, double*)
RNClassID R3Intersects(const R3Ray& ray, const R3TriangleArray& array,
    R3Point *hit_point, R3Vector *hit_normal, RNScalar *hit_t)
{
    // This could be more efficient ???
    // Sort intersections with front-facing planes 
    //   before do any point-in-triangle operations

    // Check bounding volume for intersection 
    if (!R3Intersects(ray, array.Box())) 
	return RN_NULL_CLASS_ID;

    // Check each triangle for intersection
    RNClassID status = RN_NULL_CLASS_ID;
    RNScalar min_t = FLT_MAX;
    for (int i = 0; i < array.NTriangles(); i++) {
        R3Point point;
        R3Vector normal;
	RNScalar t;
        if (R3Intersects(ray, *(array.Triangle(i)), &point, &normal, &t) == R3_POINT_CLASS_ID) {
	    if (t < min_t) {
	        status = R3_POINT_CLASS_ID;
	        if (hit_point) *hit_point = point;
	        if (hit_normal) *hit_normal = normal;
	        min_t = t;
	    }
	}
    }

    // Update hit t
    if (hit_t) *hit_t = min_t;

    // Return whether hit any triangle
    return status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
addq $0x28, %rsi
xorl %ebp, %ebp
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x3dfb5
testl %eax, %eax
je 0x3dfa4
movq %r14, 0x20(%rsp)
movq %rbx, 0x18(%rsp)
movsd 0x5512c(%rip), %xmm0    # 0x93018
movsd %xmm0, 0x8(%rsp)
xorl %r14d, %r14d
leaq 0x40(%rsp), %rbp
leaq 0x28(%rsp), %rbx
movq $0x0, (%rsp)
movslq 0x24(%r12), %rax
cmpq %rax, %r14
jge 0x3df8c
movq %rbp, %rdi
callq 0x37b4a
movq %rbx, %rdi
callq 0x3830a
movq 0x18(%r12), %rax
movq (%rax,%r14,8), %rsi
movq %r13, %rdi
movq %rbp, %rdx
movq %rbx, %rcx
leaq 0x10(%rsp), %r8
callq 0x3ddcf
testl %eax, %eax
je 0x3df84
movsd 0x8(%rsp), %xmm0
ucomisd 0x10(%rsp), %xmm0
jbe 0x3df84
testq %r15, %r15
je 0x3df5f
movq %r15, %rdi
movq %rbp, %rsi
callq 0x37e36
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x3df71
movq %rbx, %rsi
callq 0x3887c
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
pushq $0x1
popq %rax
movq %rax, (%rsp)
incq %r14
jmp 0x3df07
movq 0x18(%rsp), %rax
testq %rax, %rax
je 0x3dfa0
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rax)
movq (%rsp), %rbp
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Ray const&, gaps::R3Circle const&, gaps::R3Point*, gaps::R3Vector*, double*)
RNClassID R3Intersects(const R3Ray& ray, const R3Circle& circle, 
    R3Point *hit_point, R3Vector *hit_normal, RNScalar *hit_t)
{
    // Check for empty circle
    if (circle.IsEmpty()) return RN_NULL_CLASS_ID;
    
    // Find intersection of ray and plane
    R3Point p1;
    RNScalar t1;
    switch (R3Intersects(ray, circle.Plane(), &p1, &t1)) {
    case RN_NULL_CLASS_ID:
	// Ray does not intersect circle plane
	return RN_NULL_CLASS_ID;
	
    case R3_POINT_CLASS_ID:
    {
	// Ray intersects circle plane in a single point
	// Check whether circle contains intersection point
	RNScalar radius_squared = circle.Radius() * circle.Radius();
	R3Vector v = circle.Center() - p1;
	RNScalar distance_squared = v.X() * v.X() + v.Y() * v.Y() + v.Z() * v.Z();
	if (RNIsGreater(distance_squared, radius_squared)) return RN_NULL_CLASS_ID;
	if (hit_point) *hit_point = p1;
	if (hit_normal) *hit_normal = circle.Normal();
	if (hit_t) *hit_t = t1;
	return R3_POINT_CLASS_ID;
    }

    case R3_RAY_CLASS_ID: 
	// Ray lies in circle plane 
	// Intersect ray and circle in 2D
        // RNAbort("Case not implemented");
	return R3_SPAN_CLASS_ID;

    default:
	RNAbort("Invalid intersection result");
	break;
    }

    // Should never get here
    RNAbort("Should never get here");
    return RN_NULL_CLASS_ID;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
xorl %ebp, %ebp
xorpd %xmm0, %xmm0
ucomisd 0x20(%rsi), %xmm0
ja 0x3e311
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %rbx
movq %r8, 0x8(%rsp)
leaq 0x18(%rsp), %rbp
movq %rbp, %rdi
callq 0x37b4a
leaq 0x28(%r13), %r12
leaq 0x10(%rsp), %rcx
movq %rbx, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x3dc32
movl %eax, %ebp
movl %eax, %eax
leaq 0x5bd00(%rip), %rcx     # 0x99f4c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsd 0x20(%r13), %xmm0
mulsd %xmm0, %xmm0
movsd %xmm0, (%rsp)
addq $0x8, %r13
leaq 0x30(%rsp), %rbx
leaq 0x18(%rsp), %rdx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x37d29
movsd (%rbx), %xmm0
movsd 0x8(%rbx), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movsd 0x10(%rbx), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
subsd (%rsp), %xmm1
leaq 0x9c8fd(%rip), %rax     # 0xdaba8
xorl %ebp, %ebp
ucomisd (%rax), %xmm1
ja 0x3e311
testq %r15, %r15
je 0x3e2c5
leaq 0x18(%rsp), %rsi
movq %r15, %rdi
callq 0x37e36
testq %r14, %r14
je 0x3e2d5
movq %r14, %rdi
movq %r12, %rsi
callq 0x3887c
pushq $0x1
popq %rbp
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0x3e311
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
jmp 0x3e311
leaq 0x5bcb2(%rip), %rdi     # 0x99fa7
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x680f0
leaq 0x5bc8c(%rip), %rdi     # 0x99f91
xorl %eax, %eax
callq 0x680f0
jmp 0x3e311
pushq $0x4
popq %rbp
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Ray const&, gaps::R3Ellipse const&, gaps::R3Point*, gaps::R3Vector*, double*)
RNClassID R3Intersects(const R3Ray& ray, const R3Ellipse& ellipse, 
    R3Point *hit_point, R3Vector *hit_normal, RNScalar *hit_t)
{
    // Check for empty ellipse
    if (ellipse.IsEmpty()) return RN_NULL_CLASS_ID;
    
    // Find intersection of ray and plane
    R3Point p1;
    RNScalar t1;
    switch (R3Intersects(ray, ellipse.Plane(), &p1, &t1)) {
    case RN_NULL_CLASS_ID:
	// Ray does not intersect ellipse plane
	return RN_NULL_CLASS_ID;
	
    case R3_POINT_CLASS_ID:
    {
	// Ray intersects ellipse plane in a single point
	// Check whether ellipse contains intersection point
        if (!R3Contains(ellipse, p1)) return RN_NULL_CLASS_ID;
  	if (hit_point) *hit_point = p1;
	if (hit_normal) *hit_normal = ellipse.Normal();
	if (hit_t) *hit_t = t1;
	return R3_POINT_CLASS_ID;
    }

    case R3_RAY_CLASS_ID: 
	// Ray lies in ellipse plane 
	// Intersect ray and ellipse in 2D
        // RNAbort("Case not implemented");
	return R3_SPAN_CLASS_ID;

    default:
	RNAbort("Invalid intersection result");
	break;
    }

    // Should never get here
    RNAbort("Should never get here");
    return RN_NULL_CLASS_ID;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
xorl %ebp, %ebp
xorpd %xmm0, %xmm0
ucomisd 0x68(%rsi), %xmm0
ja 0x3e416
movq %rsi, %r15
ucomisd 0x70(%rsi), %xmm0
ja 0x3e416
movq %rcx, %r14
movq %rdx, %r12
movq %rdi, %r13
movq %r8, (%rsp)
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
callq 0x37b4a
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x40d1a
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x3dc32
movl %eax, %ebp
movl %eax, %eax
leaq 0x5bbc5(%rip), %rcx     # 0x99f5c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0x41cca
testl %eax, %eax
je 0x3e414
testq %r12, %r12
je 0x3e3c3
leaq 0x10(%rsp), %rsi
movq %r12, %rdi
callq 0x37e36
testq %r14, %r14
je 0x3e3d7
addq $0x50, %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x3887c
pushq $0x1
popq %rbp
movq (%rsp), %rax
testq %rax, %rax
je 0x3e416
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rax)
jmp 0x3e416
leaq 0x5bbb1(%rip), %rdi     # 0x99fa7
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x680f0
leaq 0x5bb8b(%rip), %rdi     # 0x99f91
xorl %eax, %eax
callq 0x680f0
jmp 0x3e416
pushq $0x4
popq %rbp
jmp 0x3e416
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq