void orthogvec_float(float *vec1, int beg, int end, float *vec2) {
  float alpha;
  double dot_float();
  void scadd_float();
  alpha = -dot_float(vec1, beg, end, vec2) / dot_float(vec2, beg, end, vec2);
  scadd_float(vec1, beg, end, alpha, vec2);
}


x86 assembly (clang, -O0):
<orthogvec_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x0,%al
call   1030 <dot_float@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x0,%al
call   1030 <dot_float@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x18(%rbp),%rcx
mov    $0x1,%al
call   1040 <scadd_float@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<orthogvec_float>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%r15
xor    %eax,%eax
call   1030 <dot_float@plt>
xorpd  0xebc(%rip),%xmm0
movapd %xmm0,(%rsp)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <dot_float@plt>
movapd (%rsp),%xmm1
divsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %rbx,%rcx
mov    $0x1,%al
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <scadd_float@plt>

LLVM IR (-O0):
define void @orthogvec_float(float* %0, i32 %1, i32 %2, float* %3) {
%5 = alloca float*
%6 = alloca i32
%7 = alloca i32
%8 = alloca float*
%9 = alloca float
store float* %0, float** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store float* %3, float** %8
%10 = load float*, float** %5
%11 = load i32, i32* %6
%12 = load i32, i32* %7
%13 = load float*, float** %8
%14 = call double (float*, i32, i32, float*, ...) bitcast (double (...)* @dot_float to double (float*, i32, i32, float*, ...)*)(float* %10, i32 %11, i32 %12, float* %13)
%15 = fneg double %14
%16 = load float*, float** %8
%17 = load i32, i32* %6
%18 = load i32, i32* %7
%19 = load float*, float** %8
%20 = call double (float*, i32, i32, float*, ...) bitcast (double (...)* @dot_float to double (float*, i32, i32, float*, ...)*)(float* %16, i32 %17, i32 %18, float* %19)
%21 = fdiv double %15, %20
%22 = fptrunc double %21 to float
store float %22, float* %9
%23 = load float*, float** %5
%24 = load i32, i32* %6
%25 = load i32, i32* %7
%26 = load float, float* %9
%27 = fpext float %26 to double
%28 = load float*, float** %8
ret void
}

LLVM IR (-O2):
define void @orthogvec_float(float* %0, i32 %1, i32 %2, float* %3) {
%5 = tail call double (float*, i32, i32, float*, ...) bitcast (double (...)* @dot_float to double (float*, i32, i32, float*, ...)*)(float* %0, i32 %1, i32 %2, float* %3)
%6 = fneg double %5
%7 = tail call double (float*, i32, i32, float*, ...) bitcast (double (...)* @dot_float to double (float*, i32, i32, float*, ...)*)(float* %3, i32 %1, i32 %2, float* %3)
%8 = fdiv double %6, %7
%9 = fptrunc double %8 to float
%10 = fpext float %9 to double
tail call void (float*, i32, i32, double, float*, ...) bitcast (void (...)* @scadd_float to void (float*, i32, i32, double, float*, ...)*)(float* %0, i32 %1, i32 %2, double %10, float* %3)
ret void
}