#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*/ add3d(float *, float *, float *);
int /*<<< orphan*/ cross3d(float *, float const *, float const *);
float dot3d(float const *, float const *);
float *malloc(int);
int /*<<< orphan*/ memset(float *, int /*<<< orphan*/, int);
int /*<<< orphan*/ normalize3d(float *, float *);
int /*<<< orphan*/ scale3d(float *, float const *, float);
int /*<<< orphan*/ sub3d(float *, float const *, float *);
float *CalculateTangentSpace(int Triangles, int VertexCount, int *Indices,
                             float *verts, float *normals, float *texs) {
  int i;
  float *tans = 0;
  if (normals && texs && verts) {
    tans = malloc(VertexCount * sizeof(float) * 4);
    memset(tans, 0, VertexCount * sizeof(float) * 4);
    float *tan1 = malloc(VertexCount * sizeof(float) * 3);
    float *tan2 = malloc(VertexCount * sizeof(float) * 3);
    memset(tan1, 0, VertexCount * sizeof(float) * 3);
    memset(tan2, 0, VertexCount * sizeof(float) * 3);
    for (i = 0; i < Triangles; i++) {
      int v1 = Indices[i * 3 + 0];
      int v2 = Indices[i * 3 + 1];
      int v3 = Indices[i * 3 + 2];
      float *t1 = &texs[v1 * 3];
      float *t2 = &texs[v2 * 3];
      float *t3 = &texs[v3 * 3];
      float *p1 = &verts[v1 * 3];
      float *p2 = &verts[v2 * 3];
      float *p3 = &verts[v3 * 3];
      float vec1[3];
      float vec2[3];
      float tex1[3];
      float tex2[3];
      sub3d(vec1, p2, p1);
      sub3d(vec2, p3, p1);
      sub3d(tex1, t2, t1);
      sub3d(tex2, t3, t1);
      float r = 1.0f / (tex1[0] * tex2[1] - tex2[0] * tex1[1]);
      float sdir[3] = {(tex2[1] * vec1[0] - tex1[1] * vec2[0]) * r,
                       (tex2[1] * vec1[1] - tex1[1] * vec2[1]) * r,
                       (tex2[1] * vec1[2] - tex1[1] * vec2[2]) * r};
      float tdir[3] = {(tex1[0] * vec2[0] - tex2[0] * vec1[0]) * r,
                       (tex1[0] * vec2[1] - tex2[0] * vec1[1]) * r,
                       (tex1[0] * vec2[2] - tex2[0] * vec1[2]) * r};
      add3d(&tan1[v1 * 3], &tan1[v1 * 3], sdir);
      add3d(&tan1[v2 * 3], &tan1[v2 * 3], sdir);
      add3d(&tan1[v3 * 3], &tan1[v3 * 3], sdir);
      add3d(&tan2[v1 * 3], &tan2[v1 * 3], sdir);
      add3d(&tan2[v2 * 3], &tan2[v2 * 3], sdir);
      add3d(&tan2[v3 * 3], &tan2[v3 * 3], sdir);
    }
    for (i = 0; i < VertexCount; i++) {
      const float *n = &normals[i * 3];
      const float *t = &tan1[i * 3];
      float tmp[3];
      float tdn[3];
      float thisdot = dot3d(n, t);
      scale3d(tdn, n, thisdot);
      sub3d(tmp, t, tdn);
      normalize3d(&tans[i * 4], tmp);
      cross3d(tmp, n, t);
      tans[i * 4 + 3] = (dot3d(tmp, &tan2[i * 3]) < 0) ? -1 : 1;
    }
  }
  return tans;
}


x86 assembly (clang, -O0):
<CalculateTangentSpace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
movq   $0x0,-0x38(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     17b9 <CalculateTangentSpace+0x639>
cmpq   $0x0,-0x28(%rbp)
je     17b9 <CalculateTangentSpace+0x639>
cmpq   $0x0,-0x18(%rbp)
je     17b9 <CalculateTangentSpace+0x639>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
shl    $0x2,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1060 <memset@plt>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
imul   $0x3,%rax,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x40(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
imul   $0x3,%rax,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rdi
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
imul   $0x3,%rax,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    -0x48(%rbp),%rdi
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
imul   $0x3,%rax,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1060 <memset@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    168c <CalculateTangentSpace+0x50c>
mov    -0x10(%rbp),%rax
imul   $0x3,-0x2c(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
imul   $0x3,-0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
imul   $0x3,-0x2c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x54(%rbp)
mov    -0x28(%rbp),%rax
imul   $0x3,-0x4c(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x60(%rbp)
mov    -0x28(%rbp),%rax
imul   $0x3,-0x50(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x68(%rbp)
mov    -0x28(%rbp),%rax
imul   $0x3,-0x54(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x70(%rbp)
mov    -0x18(%rbp),%rax
imul   $0x3,-0x4c(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x78(%rbp)
mov    -0x18(%rbp),%rax
imul   $0x3,-0x50(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x80(%rbp)
mov    -0x18(%rbp),%rax
imul   $0x3,-0x54(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x88(%rbp)
lea    -0x94(%rbp),%rdi
mov    -0x80(%rbp),%rsi
mov    -0x78(%rbp),%rdx
call   1040 <sub3d@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x88(%rbp),%rsi
mov    -0x78(%rbp),%rdx
call   1040 <sub3d@plt>
lea    -0xac(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    -0x60(%rbp),%rdx
call   1040 <sub3d@plt>
lea    -0xb8(%rbp),%rdi
mov    -0x70(%rbp),%rsi
mov    -0x60(%rbp),%rdx
call   1040 <sub3d@plt>
movss  -0xac(%rbp),%xmm1
ff
movss  -0xb4(%rbp),%xmm2
ff
movss  -0xb8(%rbp),%xmm0
ff
mulss  -0xa8(%rbp),%xmm0
ff
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  0xc40(%rip),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0xbc(%rbp)
ff
movss  -0xb4(%rbp),%xmm0
ff
movss  -0x94(%rbp),%xmm2
ff
movss  -0xa8(%rbp),%xmm1
ff
mulss  -0xa0(%rbp),%xmm1
ff
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mulss  -0xbc(%rbp),%xmm0
ff
movss  %xmm0,-0xc8(%rbp)
ff
movss  -0xb4(%rbp),%xmm0
ff
movss  -0x90(%rbp),%xmm2
ff
movss  -0xa8(%rbp),%xmm1
ff
mulss  -0x9c(%rbp),%xmm1
ff
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mulss  -0xbc(%rbp),%xmm0
ff
movss  %xmm0,-0xc4(%rbp)
ff
movss  -0xb4(%rbp),%xmm0
ff
movss  -0x8c(%rbp),%xmm2
ff
movss  -0xa8(%rbp),%xmm1
ff
mulss  -0x98(%rbp),%xmm1
ff
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mulss  -0xbc(%rbp),%xmm0
ff
movss  %xmm0,-0xc0(%rbp)
ff
movss  -0xac(%rbp),%xmm0
ff
movss  -0xa0(%rbp),%xmm2
ff
movss  -0xb8(%rbp),%xmm1
ff
mulss  -0x94(%rbp),%xmm1
ff
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mulss  -0xbc(%rbp),%xmm0
ff
movss  %xmm0,-0xd4(%rbp)
ff
movss  -0xac(%rbp),%xmm0
ff
movss  -0x9c(%rbp),%xmm2
ff
movss  -0xb8(%rbp),%xmm1
ff
mulss  -0x90(%rbp),%xmm1
ff
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mulss  -0xbc(%rbp),%xmm0
ff
movss  %xmm0,-0xd0(%rbp)
ff
movss  -0xac(%rbp),%xmm0
ff
movss  -0x98(%rbp),%xmm2
ff
movss  -0xb8(%rbp),%xmm1
ff
mulss  -0x8c(%rbp),%xmm1
ff
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mulss  -0xbc(%rbp),%xmm0
ff
movss  %xmm0,-0xcc(%rbp)
ff
mov    -0x40(%rbp),%rdi
imul   $0x3,-0x4c(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x40(%rbp),%rsi
imul   $0x3,-0x4c(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
lea    -0xc8(%rbp),%rdx
call   1070 <add3d@plt>
mov    -0x40(%rbp),%rdi
imul   $0x3,-0x50(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x40(%rbp),%rsi
imul   $0x3,-0x50(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
lea    -0xc8(%rbp),%rdx
call   1070 <add3d@plt>
mov    -0x40(%rbp),%rdi
imul   $0x3,-0x54(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x40(%rbp),%rsi
imul   $0x3,-0x54(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
lea    -0xc8(%rbp),%rdx
call   1070 <add3d@plt>
mov    -0x48(%rbp),%rdi
imul   $0x3,-0x4c(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x48(%rbp),%rsi
imul   $0x3,-0x4c(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
lea    -0xc8(%rbp),%rdx
call   1070 <add3d@plt>
mov    -0x48(%rbp),%rdi
imul   $0x3,-0x50(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x48(%rbp),%rsi
imul   $0x3,-0x50(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
lea    -0xc8(%rbp),%rdx
call   1070 <add3d@plt>
mov    -0x48(%rbp),%rdi
imul   $0x3,-0x54(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x48(%rbp),%rsi
imul   $0x3,-0x54(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
lea    -0xc8(%rbp),%rdx
call   1070 <add3d@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1261 <CalculateTangentSpace+0xe1>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    17b4 <CalculateTangentSpace+0x634>
mov    -0x20(%rbp),%rax
imul   $0x3,-0x2c(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0xe0(%rbp)
mov    -0x40(%rbp),%rax
imul   $0x3,-0x2c(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0xe8(%rbp)
mov    -0xe0(%rbp),%rdi
mov    -0xe8(%rbp),%rsi
call   1030 <dot3d@plt>
movss  %xmm0,-0x104(%rbp)
ff
lea    -0x100(%rbp),%rdi
mov    -0xe0(%rbp),%rsi
movss  -0x104(%rbp),%xmm0
ff
call   10a0 <scale3d@plt>
lea    -0xf4(%rbp),%rdi
mov    -0xe8(%rbp),%rsi
lea    -0x100(%rbp),%rdx
call   1040 <sub3d@plt>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%eax
shl    $0x2,%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
lea    -0xf4(%rbp),%rsi
call   1080 <normalize3d@plt>
lea    -0xf4(%rbp),%rdi
mov    -0xe0(%rbp),%rsi
mov    -0xe8(%rbp),%rdx
call   1050 <cross3d@plt>
lea    -0xf4(%rbp),%rdi
mov    -0x48(%rbp),%rsi
imul   $0x3,-0x2c(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
call   1030 <dot3d@plt>
movaps %xmm0,%xmm1
xorps  %xmm0,%xmm0
mov    $0x1,%eax
mov    $0xffffffff,%ecx
ucomiss %xmm1,%xmm0
cmova  %ecx,%eax
cvtsi2ss %eax,%xmm0
mov    -0x38(%rbp),%rax
mov    -0x2c(%rbp),%ecx
shl    $0x2,%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1693 <CalculateTangentSpace+0x513>
jmp    17b9 <CalculateTangentSpace+0x639>
mov    -0x38(%rbp),%rax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CalculateTangentSpace>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
xor    %ebp,%ebp
test   %rcx,%rcx
je     150e <CalculateTangentSpace+0x38e>
test   %r8,%r8
je     150e <CalculateTangentSpace+0x38e>
test   %r9,%r9
je     150e <CalculateTangentSpace+0x38e>
mov    %esi,%r15d
mov    %r8,0x48(%rsp)
mov    %esi,%ebp
shl    $0x4,%ebp
mov    %edi,(%rsp)
mov    %ebp,%edi
mov    %r9,%r13
mov    %rcx,0x70(%rsp)
mov    %rdx,%rbx
call   1090 <malloc@plt>
mov    %rax,0x28(%rsp)
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1060 <memset@plt>
mov    %r15,0x50(%rsp)
lea    0x0(,%r15,4),%eax
lea    (%rax,%rax,2),%ebp
mov    %ebp,%edi
call   1090 <malloc@plt>
mov    %rax,%r15
mov    %ebp,%edi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    %r15,0x30(%rsp)
mov    %r15,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1060 <memset@plt>
mov    %r14,%r12
mov    %r14,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1060 <memset@plt>
mov    (%rsp),%eax
test   %eax,%eax
jle    1441 <CalculateTangentSpace+0x2c1>
mov    %eax,%eax
shl    $0x2,%rax
lea    (%rax,%rax,2),%rax
mov    %rax,0x58(%rsp)
xor    %eax,%eax
mov    %r12,0x68(%rsp)
mov    %r13,0x8(%rsp)
mov    %rbx,0x60(%rsp)
mov    %rax,(%rsp)
mov    (%rsp),%rax
movslq (%rbx,%rax,1),%rax
mov    (%rsp),%rcx
movslq 0x4(%rbx,%rcx,1),%rcx
mov    (%rsp),%rdx
movslq 0x8(%rbx,%rdx,1),%rdx
shl    $0x2,%rax
lea    (%rax,%rax,2),%r14
lea    (%r14,%r13,1),%rax
mov    %rax,0x88(%rsp)
shl    $0x2,%rcx
lea    (%rcx,%rcx,2),%r13
mov    0x8(%rsp),%rax
add    %r13,%rax
mov    %rax,0x78(%rsp)
shl    $0x2,%rdx
lea    (%rdx,%rdx,2),%r15
mov    0x8(%rsp),%rax
add    %r15,%rax
mov    %rax,0x80(%rsp)
mov    0x70(%rsp),%rax
lea    (%rax,%r14,1),%rbx
lea    (%rax,%r13,1),%rsi
lea    (%rax,%r15,1),%r12
lea    0x1c(%rsp),%rdi
mov    %rbx,%rdx
call   1040 <sub3d@plt>
lea    0x10(%rsp),%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    0x30(%rsp),%rbp
call   1040 <sub3d@plt>
lea    0x9c(%rsp),%rdi
mov    0x78(%rsp),%rsi
mov    0x88(%rsp),%rbx
mov    %rbx,%rdx
call   1040 <sub3d@plt>
lea    0x90(%rsp),%rdi
mov    0x80(%rsp),%rsi
mov    %rbx,%rdx
call   1040 <sub3d@plt>
movss  0x94(%rsp),%xmm0
movss  0xa0(%rsp),%xmm1
movss  0x90(%rsp),%xmm2
mulss  %xmm1,%xmm2
movss  0x9c(%rsp),%xmm3
mulss  %xmm0,%xmm3
subss  %xmm2,%xmm3
movss  0xcb1(%rip),%xmm2
divss  %xmm3,%xmm2
movss  0x10(%rsp),%xmm3
mulss  %xmm1,%xmm3
movss  0x1c(%rsp),%xmm4
mulss  %xmm0,%xmm4
subss  %xmm3,%xmm4
mulss  %xmm2,%xmm4
movss  %xmm4,0x3c(%rsp)
movss  0x14(%rsp),%xmm3
mulss  %xmm1,%xmm3
movss  0x20(%rsp),%xmm4
mulss  %xmm0,%xmm4
subss  %xmm3,%xmm4
mulss  %xmm2,%xmm4
movss  %xmm4,0x40(%rsp)
mulss  0x18(%rsp),%xmm1
mulss  0x24(%rsp),%xmm0
subss  %xmm1,%xmm0
mulss  %xmm2,%xmm0
movss  %xmm0,0x44(%rsp)
lea    0x0(%rbp,%r14,1),%rdi
mov    %rdi,%rsi
lea    0x3c(%rsp),%r12
mov    %r12,%rdx
call   1070 <add3d@plt>
mov    %rbp,%rdi
add    %r13,%rdi
mov    %rdi,%rsi
mov    %r12,%rdx
call   1070 <add3d@plt>
lea    (%r15,%rbp,1),%rdi
mov    %rdi,%rsi
mov    %r12,%rdx
call   1070 <add3d@plt>
mov    0x68(%rsp),%rbp
add    %rbp,%r14
mov    %r14,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1070 <add3d@plt>
add    %rbp,%r13
mov    %r13,%rdi
mov    %r13,%rsi
mov    0x60(%rsp),%rbx
mov    0x8(%rsp),%r13
mov    %r12,%rdx
mov    %r12,%r14
call   1070 <add3d@plt>
mov    %rbp,%r12
add    %rbp,%r15
mov    %r15,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1070 <add3d@plt>
mov    (%rsp),%rax
add    $0xc,%rax
cmp    %rax,0x58(%rsp)
jne    1250 <CalculateTangentSpace+0xd0>
mov    0x30(%rsp),%rbx
mov    0x50(%rsp),%rax
test   %eax,%eax
jle    1509 <CalculateTangentSpace+0x389>
mov    %eax,%eax
shl    $0x2,%rax
mov    %rax,(%rsp)
xor    %r14d,%r14d
mov    0x28(%rsp),%rbp
mov    %r12,%r15
mov    0x48(%rsp),%r12
nopl   (%rax)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <dot3d@plt>
lea    0x10(%rsp),%rdi
mov    %r12,%rsi
call   10a0 <scale3d@plt>
lea    0x1c(%rsp),%r13
mov    %r13,%rdi
mov    %rbx,%rsi
lea    0x10(%rsp),%rdx
call   1040 <sub3d@plt>
mov    %r14d,%eax
lea    0x0(,%rax,4),%rdi
add    %rbp,%rdi
mov    %r13,%rsi
call   1080 <normalize3d@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1050 <cross3d@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1030 <dot3d@plt>
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
seta   %al
lea    0xb2a(%rip),%rcx
movss  (%rcx,%rax,4),%xmm0
lea    0x3(%r14),%eax
movss  %xmm0,0x0(%rbp,%rax,4)
add    $0xc,%r15
add    $0xc,%rbx
add    $0xc,%r12
add    $0x4,%r14
cmp    %r14,(%rsp)
jne    1470 <CalculateTangentSpace+0x2f0>
jmp    150e <CalculateTangentSpace+0x38e>
mov    0x28(%rsp),%rbp
mov    %rbp,%rax
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define float* @CalculateTangentSpace(i32 %0, i32 %1, i32* %2, float* %3, float* %4, float* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca float*
%11 = alloca float*
%12 = alloca float*
%13 = alloca i32
%14 = alloca float*
%15 = alloca float*
%16 = alloca float*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca float*
%21 = alloca float*
%22 = alloca float*
%23 = alloca float*
%24 = alloca float*
%25 = alloca float*
%26 = alloca [3 x float]
%27 = alloca [3 x float]
%28 = alloca [3 x float]
%29 = alloca [3 x float]
%30 = alloca float
%31 = alloca [3 x float]
%32 = alloca [3 x float]
%33 = alloca float*
%34 = alloca float*
%35 = alloca [3 x float]
%36 = alloca [3 x float]
%37 = alloca float
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32* %2, i32** %9
store float* %3, float** %10
store float* %4, float** %11
store float* %5, float** %12
store float* null, float** %14
%38 = load float*, float** %11
%39 = icmp ne float* %38, null
br i1 %39, label %40, label %388
40: ; preds = %6
%41 = load float*, float** %12
%42 = icmp ne float* %41, null
br i1 %42, label %43, label %388
43: ; preds = %40
%44 = load float*, float** %10
%45 = icmp ne float* %44, null
br i1 %45, label %46, label %388
46: ; preds = %43
%47 = load i32, i32* %8
%48 = sext i32 %47 to i64
%49 = mul i64 %48, 4
%50 = mul i64 %49, 4
%51 = trunc i64 %50 to i32
%52 = call float* @malloc(i32 %51)
store float* %52, float** %14
%53 = load float*, float** %14
%54 = load i32, i32* %8
%55 = sext i32 %54 to i64
%56 = mul i64 %55, 4
%57 = mul i64 %56, 4
%58 = trunc i64 %57 to i32
%59 = call i32 @memset(float* %53, i32 0, i32 %58)
%60 = load i32, i32* %8
%61 = sext i32 %60 to i64
%62 = mul i64 %61, 4
%63 = mul i64 %62, 3
%64 = trunc i64 %63 to i32
%65 = call float* @malloc(i32 %64)
store float* %65, float** %15
%66 = load i32, i32* %8
%67 = sext i32 %66 to i64
%68 = mul i64 %67, 4
%69 = mul i64 %68, 3
%70 = trunc i64 %69 to i32
%71 = call float* @malloc(i32 %70)
store float* %71, float** %16
%72 = load float*, float** %15
%73 = load i32, i32* %8
%74 = sext i32 %73 to i64
%75 = mul i64 %74, 4
%76 = mul i64 %75, 3
%77 = trunc i64 %76 to i32
%78 = call i32 @memset(float* %72, i32 0, i32 %77)
%79 = load float*, float** %16
%80 = load i32, i32* %8
%81 = sext i32 %80 to i64
%82 = mul i64 %81, 4
%83 = mul i64 %82, 3
%84 = trunc i64 %83 to i32
%85 = call i32 @memset(float* %79, i32 0, i32 %84)
store i32 0, i32* %13
br label %86
86: ; preds = %326, %46
%87 = load i32, i32* %13
%88 = load i32, i32* %7
%89 = icmp slt i32 %87, %88
br i1 %89, label %90, label %329
90: ; preds = %86
%91 = load i32*, i32** %9
%92 = load i32, i32* %13
%93 = mul nsw i32 %92, 3
%94 = add nsw i32 %93, 0
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i32, i32* %91, i64 %95
%97 = load i32, i32* %96
store i32 %97, i32* %17
%98 = load i32*, i32** %9
%99 = load i32, i32* %13
%100 = mul nsw i32 %99, 3
%101 = add nsw i32 %100, 1
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i32, i32* %98, i64 %102
%104 = load i32, i32* %103
store i32 %104, i32* %18
%105 = load i32*, i32** %9
%106 = load i32, i32* %13
%107 = mul nsw i32 %106, 3
%108 = add nsw i32 %107, 2
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds i32, i32* %105, i64 %109
%111 = load i32, i32* %110
store i32 %111, i32* %19
%112 = load float*, float** %12
%113 = load i32, i32* %17
%114 = mul nsw i32 %113, 3
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds float, float* %112, i64 %115
store float* %116, float** %20
%117 = load float*, float** %12
%118 = load i32, i32* %18
%119 = mul nsw i32 %118, 3
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds float, float* %117, i64 %120
store float* %121, float** %21
%122 = load float*, float** %12
%123 = load i32, i32* %19
%124 = mul nsw i32 %123, 3
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds float, float* %122, i64 %125
store float* %126, float** %22
%127 = load float*, float** %10
%128 = load i32, i32* %17
%129 = mul nsw i32 %128, 3
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds float, float* %127, i64 %130
store float* %131, float** %23
%132 = load float*, float** %10
%133 = load i32, i32* %18
%134 = mul nsw i32 %133, 3
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds float, float* %132, i64 %135
store float* %136, float** %24
%137 = load float*, float** %10
%138 = load i32, i32* %19
%139 = mul nsw i32 %138, 3
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds float, float* %137, i64 %140
store float* %141, float** %25
%142 = getelementptr inbounds [3 x float], [3 x float]* %26, i64 0, i64 0
%143 = load float*, float** %24
%144 = load float*, float** %23
%145 = call i32 @sub3d(float* %142, float* %143, float* %144)
%146 = getelementptr inbounds [3 x float], [3 x float]* %27, i64 0, i64 0
%147 = load float*, float** %25
%148 = load float*, float** %23
%149 = call i32 @sub3d(float* %146, float* %147, float* %148)
%150 = getelementptr inbounds [3 x float], [3 x float]* %28, i64 0, i64 0
%151 = load float*, float** %21
%152 = load float*, float** %20
%153 = call i32 @sub3d(float* %150, float* %151, float* %152)
%154 = getelementptr inbounds [3 x float], [3 x float]* %29, i64 0, i64 0
%155 = load float*, float** %22
%156 = load float*, float** %20
%157 = call i32 @sub3d(float* %154, float* %155, float* %156)
%158 = getelementptr inbounds [3 x float], [3 x float]* %28, i64 0, i64 0
%159 = load float, float* %158
%160 = getelementptr inbounds [3 x float], [3 x float]* %29, i64 0, i64 1
%161 = load float, float* %160
%162 = getelementptr inbounds [3 x float], [3 x float]* %29, i64 0, i64 0
%163 = load float, float* %162
%164 = getelementptr inbounds [3 x float], [3 x float]* %28, i64 0, i64 1
%165 = load float, float* %164
%166 = fmul float %163, %165
%167 = fneg float %166
%168 = call float @llvm.fmuladd.f32(float %159, float %161, float %167)
%169 = fdiv float 1.000000e+00, %168
store float %169, float* %30
%170 = getelementptr inbounds [3 x float], [3 x float]* %31, i64 0, i64 0
%171 = getelementptr inbounds [3 x float], [3 x float]* %29, i64 0, i64 1
%172 = load float, float* %171
%173 = getelementptr inbounds [3 x float], [3 x float]* %26, i64 0, i64 0
%174 = load float, float* %173
%175 = getelementptr inbounds [3 x float], [3 x float]* %28, i64 0, i64 1
%176 = load float, float* %175
%177 = getelementptr inbounds [3 x float], [3 x float]* %27, i64 0, i64 0
%178 = load float, float* %177
%179 = fmul float %176, %178
%180 = fneg float %179
%181 = call float @llvm.fmuladd.f32(float %172, float %174, float %180)
%182 = load float, float* %30
%183 = fmul float %181, %182
store float %183, float* %170
%184 = getelementptr inbounds float, float* %170, i64 1
%185 = getelementptr inbounds [3 x float], [3 x float]* %29, i64 0, i64 1
%186 = load float, float* %185
%187 = getelementptr inbounds [3 x float], [3 x float]* %26, i64 0, i64 1
%188 = load float, float* %187
%189 = getelementptr inbounds [3 x float], [3 x float]* %28, i64 0, i64 1
%190 = load float, float* %189
%191 = getelementptr inbounds [3 x float], [3 x float]* %27, i64 0, i64 1
%192 = load float, float* %191
%193 = fmul float %190, %192
%194 = fneg float %193
%195 = call float @llvm.fmuladd.f32(float %186, float %188, float %194)
%196 = load float, float* %30
%197 = fmul float %195, %196
store float %197, float* %184
%198 = getelementptr inbounds float, float* %184, i64 1
%199 = getelementptr inbounds [3 x float], [3 x float]* %29, i64 0, i64 1
%200 = load float, float* %199
%201 = getelementptr inbounds [3 x float], [3 x float]* %26, i64 0, i64 2
%202 = load float, float* %201
%203 = getelementptr inbounds [3 x float], [3 x float]* %28, i64 0, i64 1
%204 = load float, float* %203
%205 = getelementptr inbounds [3 x float], [3 x float]* %27, i64 0, i64 2
%206 = load float, float* %205
%207 = fmul float %204, %206
%208 = fneg float %207
%209 = call float @llvm.fmuladd.f32(float %200, float %202, float %208)
%210 = load float, float* %30
%211 = fmul float %209, %210
store float %211, float* %198
%212 = getelementptr inbounds [3 x float], [3 x float]* %32, i64 0, i64 0
%213 = getelementptr inbounds [3 x float], [3 x float]* %28, i64 0, i64 0
%214 = load float, float* %213
%215 = getelementptr inbounds [3 x float], [3 x float]* %27, i64 0, i64 0
%216 = load float, float* %215
%217 = getelementptr inbounds [3 x float], [3 x float]* %29, i64 0, i64 0
%218 = load float, float* %217
%219 = getelementptr inbounds [3 x float], [3 x float]* %26, i64 0, i64 0
%220 = load float, float* %219
%221 = fmul float %218, %220
%222 = fneg float %221
%223 = call float @llvm.fmuladd.f32(float %214, float %216, float %222)
%224 = load float, float* %30
%225 = fmul float %223, %224
store float %225, float* %212
%226 = getelementptr inbounds float, float* %212, i64 1
%227 = getelementptr inbounds [3 x float], [3 x float]* %28, i64 0, i64 0
%228 = load float, float* %227
%229 = getelementptr inbounds [3 x float], [3 x float]* %27, i64 0, i64 1
%230 = load float, float* %229
%231 = getelementptr inbounds [3 x float], [3 x float]* %29, i64 0, i64 0
%232 = load float, float* %231
%233 = getelementptr inbounds [3 x float], [3 x float]* %26, i64 0, i64 1
%234 = load float, float* %233
%235 = fmul float %232, %234
%236 = fneg float %235
%237 = call float @llvm.fmuladd.f32(float %228, float %230, float %236)
%238 = load float, float* %30
%239 = fmul float %237, %238
store float %239, float* %226
%240 = getelementptr inbounds float, float* %226, i64 1
%241 = getelementptr inbounds [3 x float], [3 x float]* %28, i64 0, i64 0
%242 = load float, float* %241
%243 = getelementptr inbounds [3 x float], [3 x float]* %27, i64 0, i64 2
%244 = load float, float* %243
%245 = getelementptr inbounds [3 x float], [3 x float]* %29, i64 0, i64 0
%246 = load float, float* %245
%247 = getelementptr inbounds [3 x float], [3 x float]* %26, i64 0, i64 2
%248 = load float, float* %247
%249 = fmul float %246, %248
%250 = fneg float %249
%251 = call float @llvm.fmuladd.f32(float %242, float %244, float %250)
%252 = load float, float* %30
%253 = fmul float %251, %252
store float %253, float* %240
%254 = load float*, float** %15
%255 = load i32, i32* %17
%256 = mul nsw i32 %255, 3
%257 = sext i32 %256 to i64
%258 = getelementptr inbounds float, float* %254, i64 %257
%259 = load float*, float** %15
%260 = load i32, i32* %17
%261 = mul nsw i32 %260, 3
%262 = sext i32 %261 to i64
%263 = getelementptr inbounds float, float* %259, i64 %262
%264 = getelementptr inbounds [3 x float], [3 x float]* %31, i64 0, i64 0
%265 = call i32 @add3d(float* %258, float* %263, float* %264)
%266 = load float*, float** %15
%267 = load i32, i32* %18
%268 = mul nsw i32 %267, 3
%269 = sext i32 %268 to i64
%270 = getelementptr inbounds float, float* %266, i64 %269
%271 = load float*, float** %15
%272 = load i32, i32* %18
%273 = mul nsw i32 %272, 3
%274 = sext i32 %273 to i64
%275 = getelementptr inbounds float, float* %271, i64 %274
%276 = getelementptr inbounds [3 x float], [3 x float]* %31, i64 0, i64 0
%277 = call i32 @add3d(float* %270, float* %275, float* %276)
%278 = load float*, float** %15
%279 = load i32, i32* %19
%280 = mul nsw i32 %279, 3
%281 = sext i32 %280 to i64
%282 = getelementptr inbounds float, float* %278, i64 %281
%283 = load float*, float** %15
%284 = load i32, i32* %19
%285 = mul nsw i32 %284, 3
%286 = sext i32 %285 to i64
%287 = getelementptr inbounds float, float* %283, i64 %286
%288 = getelementptr inbounds [3 x float], [3 x float]* %31, i64 0, i64 0
%289 = call i32 @add3d(float* %282, float* %287, float* %288)
%290 = load float*, float** %16
%291 = load i32, i32* %17
%292 = mul nsw i32 %291, 3
%293 = sext i32 %292 to i64
%294 = getelementptr inbounds float, float* %290, i64 %293
%295 = load float*, float** %16
%296 = load i32, i32* %17
%297 = mul nsw i32 %296, 3
%298 = sext i32 %297 to i64
%299 = getelementptr inbounds float, float* %295, i64 %298
%300 = getelementptr inbounds [3 x float], [3 x float]* %31, i64 0, i64 0
%301 = call i32 @add3d(float* %294, float* %299, float* %300)
%302 = load float*, float** %16
%303 = load i32, i32* %18
%304 = mul nsw i32 %303, 3
%305 = sext i32 %304 to i64
%306 = getelementptr inbounds float, float* %302, i64 %305
%307 = load float*, float** %16
%308 = load i32, i32* %18
%309 = mul nsw i32 %308, 3
%310 = sext i32 %309 to i64
%311 = getelementptr inbounds float, float* %307, i64 %310
%312 = getelementptr inbounds [3 x float], [3 x float]* %31, i64 0, i64 0
%313 = call i32 @add3d(float* %306, float* %311, float* %312)
%314 = load float*, float** %16
%315 = load i32, i32* %19
%316 = mul nsw i32 %315, 3
%317 = sext i32 %316 to i64
%318 = getelementptr inbounds float, float* %314, i64 %317
%319 = load float*, float** %16
%320 = load i32, i32* %19
%321 = mul nsw i32 %320, 3
%322 = sext i32 %321 to i64
%323 = getelementptr inbounds float, float* %319, i64 %322
%324 = getelementptr inbounds [3 x float], [3 x float]* %31, i64 0, i64 0
%325 = call i32 @add3d(float* %318, float* %323, float* %324)
br label %326
326: ; preds = %90
%327 = load i32, i32* %13
%328 = add nsw i32 %327, 1
store i32 %328, i32* %13
br label %86
329: ; preds = %86
store i32 0, i32* %13
br label %330
330: ; preds = %384, %329
%331 = load i32, i32* %13
%332 = load i32, i32* %8
%333 = icmp slt i32 %331, %332
br i1 %333, label %334, label %387
334: ; preds = %330
%335 = load float*, float** %11
%336 = load i32, i32* %13
%337 = mul nsw i32 %336, 3
%338 = sext i32 %337 to i64
%339 = getelementptr inbounds float, float* %335, i64 %338
store float* %339, float** %33
%340 = load float*, float** %15
%341 = load i32, i32* %13
%342 = mul nsw i32 %341, 3
%343 = sext i32 %342 to i64
%344 = getelementptr inbounds float, float* %340, i64 %343
store float* %344, float** %34
%345 = load float*, float** %33
%346 = load float*, float** %34
%347 = call float @dot3d(float* %345, float* %346)
store float %347, float* %37
%348 = getelementptr inbounds [3 x float], [3 x float]* %36, i64 0, i64 0
%349 = load float*, float** %33
%350 = load float, float* %37
%351 = call i32 @scale3d(float* %348, float* %349, float %350)
%352 = getelementptr inbounds [3 x float], [3 x float]* %35, i64 0, i64 0
%353 = load float*, float** %34
%354 = getelementptr inbounds [3 x float], [3 x float]* %36, i64 0, i64 0
%355 = call i32 @sub3d(float* %352, float* %353, float* %354)
%356 = load float*, float** %14
%357 = load i32, i32* %13
%358 = mul nsw i32 %357, 4
%359 = sext i32 %358 to i64
%360 = getelementptr inbounds float, float* %356, i64 %359
%361 = getelementptr inbounds [3 x float], [3 x float]* %35, i64 0, i64 0
%362 = call i32 @normalize3d(float* %360, float* %361)
%363 = getelementptr inbounds [3 x float], [3 x float]* %35, i64 0, i64 0
%364 = load float*, float** %33
%365 = load float*, float** %34
%366 = call i32 @cross3d(float* %363, float* %364, float* %365)
%367 = getelementptr inbounds [3 x float], [3 x float]* %35, i64 0, i64 0
%368 = load float*, float** %16
%369 = load i32, i32* %13
%370 = mul nsw i32 %369, 3
%371 = sext i32 %370 to i64
%372 = getelementptr inbounds float, float* %368, i64 %371
%373 = call float @dot3d(float* %367, float* %372)
%374 = fcmp olt float %373, 0.000000e+00
%375 = zext i1 %374 to i64
%376 = select i1 %374, i32 -1, i32 1
%377 = sitofp i32 %376 to float
%378 = load float*, float** %14
%379 = load i32, i32* %13
%380 = mul nsw i32 %379, 4
%381 = add nsw i32 %380, 3
%382 = sext i32 %381 to i64
%383 = getelementptr inbounds float, float* %378, i64 %382
store float %377, float* %383
br label %384
384: ; preds = %334
%385 = load i32, i32* %13
%386 = add nsw i32 %385, 1
store i32 %386, i32* %13
br label %330
387: ; preds = %330
br label %388
388: ; preds = %387, %43, %40, %6
%389 = load float*, float** %14
ret float* %389
}

LLVM IR (-O2):
define float* @CalculateTangentSpace(i32 %0, i32 %1, i32* nocapture %2, float* %3, float* %4, float* %5) {
%7 = alloca [3 x float]
%8 = alloca [3 x float]
%9 = alloca [3 x float]
%10 = alloca [3 x float]
%11 = alloca [3 x float]
%12 = alloca [3 x float]
%13 = alloca [3 x float]
%14 = icmp ne float* %4, null
%15 = icmp ne float* %5, null
%16 = and i1 %14, %15
%17 = icmp ne float* %3, null
%18 = and i1 %17, %16
br i1 %18, label %19, label %145
19: ; preds = %6
%20 = shl i32 %1, 4
%21 = tail call float* @malloc(i32 %20)
%22 = tail call i32 @memset(float* %21, i32 0, i32 %20)
%23 = mul i32 %1, 12
%24 = tail call float* @malloc(i32 %23)
%25 = tail call float* @malloc(i32 %23)
%26 = tail call i32 @memset(float* %24, i32 0, i32 %23)
%27 = tail call i32 @memset(float* %25, i32 0, i32 %23)
%28 = icmp sgt i32 %0, 0
br i1 %28, label %29, label %49
29: ; preds = %19
%30 = bitcast [3 x float]* %7 to i8*
%31 = bitcast [3 x float]* %8 to i8*
%32 = bitcast [3 x float]* %9 to i8*
%33 = bitcast [3 x float]* %10 to i8*
%34 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%35 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 0
%36 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%37 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
%38 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 1
%39 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 1
%40 = bitcast [3 x float]* %11 to i8*
%41 = getelementptr inbounds [3 x float], [3 x float]* %11, i64 0, i64 0
%42 = getelementptr inbounds [3 x float], [3 x float]* %11, i64 0, i64 1
%43 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 1
%44 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 1
%45 = getelementptr inbounds [3 x float], [3 x float]* %11, i64 0, i64 2
%46 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 2
%47 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 2
%48 = zext i32 %0 to i64
br label %57
49: ; preds = %57, %19
%50 = icmp sgt i32 %1, 0
br i1 %50, label %51, label %145
51: ; preds = %49
%52 = bitcast [3 x float]* %12 to i8*
%53 = bitcast [3 x float]* %13 to i8*
%54 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 0
%55 = getelementptr inbounds [3 x float], [3 x float]* %12, i64 0, i64 0
%56 = zext i32 %1 to i64
br label %122
57: ; preds = %29, %57
%58 = phi i64 [ 0, %29 ], [ %120, %57 ]
%59 = mul nuw nsw i64 %58, 3
%60 = getelementptr inbounds i32, i32* %2, i64 %59
%61 = load i32, i32* %60
%62 = add nuw nsw i64 %59, 1
%63 = getelementptr inbounds i32, i32* %2, i64 %62
%64 = load i32, i32* %63
%65 = add nuw nsw i64 %59, 2
%66 = getelementptr inbounds i32, i32* %2, i64 %65
%67 = load i32, i32* %66
%68 = mul nsw i32 %61, 3
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds float, float* %5, i64 %69
%71 = mul nsw i32 %64, 3
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds float, float* %5, i64 %72
%74 = mul nsw i32 %67, 3
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds float, float* %5, i64 %75
%77 = getelementptr inbounds float, float* %3, i64 %69
%78 = getelementptr inbounds float, float* %3, i64 %72
%79 = getelementptr inbounds float, float* %3, i64 %75
%80 = call i32 @sub3d(float* %34, float* %78, float* %77)
%81 = call i32 @sub3d(float* %35, float* %79, float* %77)
%82 = call i32 @sub3d(float* %36, float* %73, float* %70)
%83 = call i32 @sub3d(float* %37, float* %76, float* %70)
%84 = load float, float* %36
%85 = load float, float* %38
%86 = load float, float* %37
%87 = load float, float* %39
%88 = fneg float %86
%89 = fmul float %87, %88
%90 = call float @llvm.fmuladd.f32(float %84, float %85, float %89)
%91 = fdiv float 1.000000e+00, %90
%92 = load float, float* %34
%93 = load float, float* %35
%94 = fneg float %87
%95 = fmul float %93, %94
%96 = call float @llvm.fmuladd.f32(float %85, float %92, float %95)
%97 = fmul float %91, %96
store float %97, float* %41
%98 = load float, float* %43
%99 = load float, float* %44
%100 = fmul float %99, %94
%101 = call float @llvm.fmuladd.f32(float %85, float %98, float %100)
%102 = fmul float %91, %101
store float %102, float* %42
%103 = load float, float* %46
%104 = load float, float* %47
%105 = fmul float %104, %94
%106 = call float @llvm.fmuladd.f32(float %85, float %103, float %105)
%107 = fmul float %91, %106
store float %107, float* %45
%108 = getelementptr inbounds float, float* %24, i64 %69
%109 = call i32 @add3d(float* %108, float* %108, float* %41)
%110 = getelementptr inbounds float, float* %24, i64 %72
%111 = call i32 @add3d(float* %110, float* %110, float* %41)
%112 = getelementptr inbounds float, float* %24, i64 %75
%113 = call i32 @add3d(float* %112, float* %112, float* %41)
%114 = getelementptr inbounds float, float* %25, i64 %69
%115 = call i32 @add3d(float* %114, float* %114, float* %41)
%116 = getelementptr inbounds float, float* %25, i64 %72
%117 = call i32 @add3d(float* %116, float* %116, float* %41)
%118 = getelementptr inbounds float, float* %25, i64 %75
%119 = call i32 @add3d(float* %118, float* %118, float* %41)
%120 = add nuw nsw i64 %58, 1
%121 = icmp eq i64 %120, %48
br i1 %121, label %49, label %57
122: ; preds = %51, %122
%123 = phi i64 [ 0, %51 ], [ %143, %122 ]
%124 = mul nuw nsw i64 %123, 3
%125 = getelementptr inbounds float, float* %4, i64 %124
%126 = getelementptr inbounds float, float* %24, i64 %124
%127 = call float @dot3d(float* %125, float* %126)
%128 = call i32 @scale3d(float* %54, float* %125, float %127)
%129 = call i32 @sub3d(float* %55, float* %126, float* %54)
%130 = trunc i64 %123 to i32
%131 = shl nsw i32 %130, 2
%132 = zext i32 %131 to i64
%133 = getelementptr inbounds float, float* %21, i64 %132
%134 = call i32 @normalize3d(float* %133, float* %55)
%135 = call i32 @cross3d(float* %55, float* %125, float* %126)
%136 = getelementptr inbounds float, float* %25, i64 %124
%137 = call float @dot3d(float* %55, float* %136)
%138 = fcmp olt float %137, 0.000000e+00
%139 = select i1 %138, float -1.000000e+00, float 1.000000e+00
%140 = or i32 %131, 3
%141 = zext i32 %140 to i64
%142 = getelementptr inbounds float, float* %21, i64 %141
store float %139, float* %142
%143 = add nuw nsw i64 %123, 1
%144 = icmp eq i64 %143, %56
br i1 %144, label %145, label %122
145: ; preds = %122, %49, %6
%146 = phi float* [ null, %6 ], [ %21, %49 ], [ %21, %122 ]
ret float* %146
}