void add_quats(float *q1, float *q2, float *dest) {
  static signed int count = 0;
  float t1[4l];
  float t2[4l];
  float t3[4l];
  float tf[4l];
  vcopy(q1, t1);
  vscale(t1, q2[(signed long int)3]);
  vcopy(q2, t2);
  vscale(t2, q1[(signed long int)3]);
  vcross(q2, q1, t3);
  vadd(t1, t2, tf);
  vadd(t3, tf, tf);
  float return_value_vdot$1;
  return_value_vdot$1 = vdot(q1, q2);
  tf[(signed long int)3] =
      q1[(signed long int)3] * q2[(signed long int)3] - return_value_vdot$1;
  dest[(signed long int)0] = tf[(signed long int)0];
  dest[(signed long int)1] = tf[(signed long int)1];
  dest[(signed long int)2] = tf[(signed long int)2];
  dest[(signed long int)3] = tf[(signed long int)3];
  count = count + 1;
  if (count > 97) {
    count = 0;
    normalize_quat(dest);
  }
}


x86 assembly (clang, -O0):
<add_quats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x0,%al
call   1080 <vcopy@plt>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
movss  0xc(%rax),%xmm0
cvtss2sd %xmm0,%xmm0
mov    $0x1,%al
call   1070 <vscale@plt>
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x0,%al
call   1080 <vcopy@plt>
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm0
cvtss2sd %xmm0,%xmm0
mov    $0x1,%al
call   1070 <vscale@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
lea    -0x50(%rbp),%rdx
mov    $0x0,%al
call   1050 <vcross@plt>
lea    -0x30(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x60(%rbp),%rdx
mov    $0x0,%al
call   1030 <vadd@plt>
lea    -0x50(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0x60(%rbp),%rdx
mov    $0x0,%al
call   1030 <vadd@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1060 <vdot@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x64(%rbp)
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm0
mov    -0x10(%rbp),%rax
movss  0xc(%rax),%xmm2
movss  -0x64(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x54(%rbp)
movss  -0x60(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x5c(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x58(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  -0x54(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0xc(%rax)
mov    0x2dd3(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2dca(%rip)
cmpl   $0x61,0x2dc3(%rip)
jle    12ac <add_quats+0x14c>
movl   $0x0,0x2db3(%rip)
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1040 <normalize_quat@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_quats>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0x10(%rsp),%rbp
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <vcopy@plt>
movss  0xc(%r15),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
mov    $0x1,%al
call   1070 <vscale@plt>
lea    0x30(%rsp),%r13
mov    %r15,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1080 <vcopy@plt>
movss  0xc(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r13,%rdi
mov    $0x1,%al
call   1070 <vscale@plt>
lea    0x20(%rsp),%rbp
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <vcross@plt>
mov    %rsp,%r12
lea    0x10(%rsp),%rdi
mov    %r13,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1030 <vadd@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1030 <vadd@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <vdot@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0xc(%rbx),%xmm1
mulss  0xc(%r15),%xmm1
subss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
movss  (%rsp),%xmm0
movss  %xmm0,(%r14)
movss  0x4(%rsp),%xmm0
movss  %xmm0,0x4(%r14)
movss  0x8(%rsp),%xmm0
movss  %xmm0,0x8(%r14)
movss  %xmm1,0xc(%r14)
mov    0x2e04(%rip),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0x2dfb(%rip)
cmp    $0x61,%eax
jl     1272 <add_quats+0x112>
movl   $0x0,0x2dec(%rip)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <normalize_quat@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@add_quats.count = internal global i32 0
define void @add_quats(float* %0, float* %1, float* %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca float*
%7 = alloca [4 x float]
%8 = alloca [4 x float]
%9 = alloca [4 x float]
%10 = alloca [4 x float]
%11 = alloca float
store float* %0, float** %4
store float* %1, float** %5
store float* %2, float** %6
%12 = load float*, float** %4
%13 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
%14 = call i32 (float*, float*, ...) bitcast (i32 (...)* @vcopy to i32 (float*, float*, ...)*)(float* %12, float* %13)
%15 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
%16 = load float*, float** %5
%17 = getelementptr inbounds float, float* %16, i64 3
%18 = load float, float* %17
%19 = fpext float %18 to double
%20 = call i32 (float*, double, ...) bitcast (i32 (...)* @vscale to i32 (float*, double, ...)*)(float* %15, double %19)
%21 = load float*, float** %5
%22 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%23 = call i32 (float*, float*, ...) bitcast (i32 (...)* @vcopy to i32 (float*, float*, ...)*)(float* %21, float* %22)
%24 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%25 = load float*, float** %4
%26 = getelementptr inbounds float, float* %25, i64 3
%27 = load float, float* %26
%28 = fpext float %27 to double
%29 = call i32 (float*, double, ...) bitcast (i32 (...)* @vscale to i32 (float*, double, ...)*)(float* %24, double %28)
%30 = load float*, float** %5
%31 = load float*, float** %4
%32 = getelementptr inbounds [4 x float], [4 x float]* %9, i64 0, i64 0
%33 = call i32 (float*, float*, float*, ...) bitcast (i32 (...)* @vcross to i32 (float*, float*, float*, ...)*)(float* %30, float* %31, float* %32)
%34 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
%35 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%36 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 0
%37 = call i32 (float*, float*, float*, ...) bitcast (i32 (...)* @vadd to i32 (float*, float*, float*, ...)*)(float* %34, float* %35, float* %36)
%38 = getelementptr inbounds [4 x float], [4 x float]* %9, i64 0, i64 0
%39 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 0
%40 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 0
%41 = call i32 (float*, float*, float*, ...) bitcast (i32 (...)* @vadd to i32 (float*, float*, float*, ...)*)(float* %38, float* %39, float* %40)
%42 = load float*, float** %4
%43 = load float*, float** %5
%44 = call i32 (float*, float*, ...) bitcast (i32 (...)* @vdot to i32 (float*, float*, ...)*)(float* %42, float* %43)
%45 = sitofp i32 %44 to float
store float %45, float* %11
%46 = load float*, float** %4
%47 = getelementptr inbounds float, float* %46, i64 3
%48 = load float, float* %47
%49 = load float*, float** %5
%50 = getelementptr inbounds float, float* %49, i64 3
%51 = load float, float* %50
%52 = load float, float* %11
%53 = fneg float %52
%54 = call float @llvm.fmuladd.f32(float %48, float %51, float %53)
%55 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 3
store float %54, float* %55
%56 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 0
%57 = load float, float* %56
%58 = load float*, float** %6
%59 = getelementptr inbounds float, float* %58, i64 0
store float %57, float* %59
%60 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 1
%61 = load float, float* %60
%62 = load float*, float** %6
%63 = getelementptr inbounds float, float* %62, i64 1
store float %61, float* %63
%64 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 2
%65 = load float, float* %64
%66 = load float*, float** %6
%67 = getelementptr inbounds float, float* %66, i64 2
store float %65, float* %67
%68 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 3
%69 = load float, float* %68
%70 = load float*, float** %6
%71 = getelementptr inbounds float, float* %70, i64 3
store float %69, float* %71
%72 = load i32, i32* @add_quats.count
%73 = add nsw i32 %72, 1
store i32 %73, i32* @add_quats.count
%74 = load i32, i32* @add_quats.count
%75 = icmp sgt i32 %74, 97
br i1 %75, label %76, label %79
76: ; preds = %3
store i32 0, i32* @add_quats.count
%77 = load float*, float** %6
%78 = call i32 (float*, ...) bitcast (i32 (...)* @normalize_quat to i32 (float*, ...)*)(float* %77)
br label %79
79: ; preds = %76, %3
ret void
}

LLVM IR (-O2):
@add_quats.count = internal unnamed_addr global i32 0
define void @add_quats(float* %0, float* %1, float* %2) {
%4 = alloca [4 x float]
%5 = alloca [4 x float]
%6 = alloca [4 x float]
%7 = alloca [4 x float]
%8 = bitcast [4 x float]* %4 to i8*
%9 = bitcast [4 x float]* %5 to i8*
%10 = bitcast [4 x float]* %6 to i8*
%11 = bitcast [4 x float]* %7 to i8*
%12 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 0, i64 0
%13 = call i32 (float*, float*, ...) bitcast (i32 (...)* @vcopy to i32 (float*, float*, ...)*)(float* %0, float* %12)
%14 = getelementptr inbounds float, float* %1, i64 3
%15 = load float, float* %14
%16 = fpext float %15 to double
%17 = call i32 (float*, double, ...) bitcast (i32 (...)* @vscale to i32 (float*, double, ...)*)(float* %12, double %16)
%18 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 0
%19 = call i32 (float*, float*, ...) bitcast (i32 (...)* @vcopy to i32 (float*, float*, ...)*)(float* %1, float* %18)
%20 = getelementptr inbounds float, float* %0, i64 3
%21 = load float, float* %20
%22 = fpext float %21 to double
%23 = call i32 (float*, double, ...) bitcast (i32 (...)* @vscale to i32 (float*, double, ...)*)(float* %18, double %22)
%24 = getelementptr inbounds [4 x float], [4 x float]* %6, i64 0, i64 0
%25 = call i32 (float*, float*, float*, ...) bitcast (i32 (...)* @vcross to i32 (float*, float*, float*, ...)*)(float* %1, float* %0, float* %24)
%26 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
%27 = call i32 (float*, float*, float*, ...) bitcast (i32 (...)* @vadd to i32 (float*, float*, float*, ...)*)(float* %12, float* %18, float* %26)
%28 = call i32 (float*, float*, float*, ...) bitcast (i32 (...)* @vadd to i32 (float*, float*, float*, ...)*)(float* %24, float* %26, float* %26)
%29 = call i32 (float*, float*, ...) bitcast (i32 (...)* @vdot to i32 (float*, float*, ...)*)(float* %0, float* %1)
%30 = sitofp i32 %29 to float
%31 = load float, float* %20
%32 = load float, float* %14
%33 = fneg float %30
%34 = call float @llvm.fmuladd.f32(float %31, float %32, float %33)
%35 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 3
store float %34, float* %35
%36 = load float, float* %26
store float %36, float* %2
%37 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 1
%38 = load float, float* %37
%39 = getelementptr inbounds float, float* %2, i64 1
store float %38, float* %39
%40 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 2
%41 = load float, float* %40
%42 = getelementptr inbounds float, float* %2, i64 2
store float %41, float* %42
%43 = getelementptr inbounds float, float* %2, i64 3
store float %34, float* %43
%44 = load i32, i32* @add_quats.count
%45 = add nsw i32 %44, 1
store i32 %45, i32* @add_quats.count
%46 = icmp sgt i32 %44, 96
br i1 %46, label %47, label %49
47: ; preds = %3
store i32 0, i32* @add_quats.count
%48 = call i32 (float*, ...) bitcast (i32 (...)* @normalize_quat to i32 (float*, ...)*)(float* %2)
br label %49
49: ; preds = %47, %3
ret void
}