#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 */
struct BONDS {
  int dummy;
};

/* Variables and functions */
double BONDS_fr_i(struct BONDS *, int, double);
double sqrt(double const);
void BONDS_calc_force_spring_i(struct BONDS *bonds, int ib, const double *q,
                               double *f) {
  double Q = sqrt(q[0] * q[0] + q[1] * q[1] + q[2] * q[2]);
  double ex = q[0] / Q;
  double ey = q[1] / Q;
  double ez = q[2] / Q;
  double fr = BONDS_fr_i(bonds, ib, Q);
  f[0] = fr * ex;
  f[1] = fr * ey;
  f[2] = fr * ez;
}


x86 assembly (clang, -O0):
<BONDS_calc_force_spring_i>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
movsd  -0x28(%rbp),%xmm0
call   1030 <BONDS_fr_i@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BONDS_calc_force_spring_i>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rcx,%rbx
mov    %rdx,%rbp
mov    %esi,%r14d
mov    %rdi,%r15
movsd  (%rdx),%xmm1
movsd  0x8(%rdx),%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x10(%rdx),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1168 <BONDS_calc_force_spring_i+0x48>
sqrtsd %xmm0,%xmm0
jmp    116d <BONDS_calc_force_spring_i+0x4d>
call   1040 <sqrt@plt>
movupd 0x0(%rbp),%xmm2
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
divpd  %xmm1,%xmm2
movapd %xmm2,0x10(%rsp)
movsd  0x10(%rbp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %r15,%rdi
mov    %r14d,%esi
call   1030 <BONDS_fr_i@plt>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
unpcklpd %xmm0,%xmm0
mulpd  0x10(%rsp),%xmm0
movupd %xmm0,(%rbx)
movsd  %xmm1,0x10(%rbx)
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.BONDS = type { i32 }
define void @BONDS_calc_force_spring_i(%struct.BONDS* %0, i32 %1, double* %2, double* %3) {
%5 = alloca %struct.BONDS*
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
store %struct.BONDS* %0, %struct.BONDS** %5
store i32 %1, i32* %6
store double* %2, double** %7
store double* %3, double** %8
%14 = load double*, double** %7
%15 = getelementptr inbounds double, double* %14, i64 0
%16 = load double, double* %15
%17 = load double*, double** %7
%18 = getelementptr inbounds double, double* %17, i64 0
%19 = load double, double* %18
%20 = load double*, double** %7
%21 = getelementptr inbounds double, double* %20, i64 1
%22 = load double, double* %21
%23 = load double*, double** %7
%24 = getelementptr inbounds double, double* %23, i64 1
%25 = load double, double* %24
%26 = fmul double %22, %25
%27 = call double @llvm.fmuladd.f64(double %16, double %19, double %26)
%28 = load double*, double** %7
%29 = getelementptr inbounds double, double* %28, i64 2
%30 = load double, double* %29
%31 = load double*, double** %7
%32 = getelementptr inbounds double, double* %31, i64 2
%33 = load double, double* %32
%34 = call double @llvm.fmuladd.f64(double %30, double %33, double %27)
%35 = call double @sqrt(double %34)
store double %35, double* %9
%36 = load double*, double** %7
%37 = getelementptr inbounds double, double* %36, i64 0
%38 = load double, double* %37
%39 = load double, double* %9
%40 = fdiv double %38, %39
store double %40, double* %10
%41 = load double*, double** %7
%42 = getelementptr inbounds double, double* %41, i64 1
%43 = load double, double* %42
%44 = load double, double* %9
%45 = fdiv double %43, %44
store double %45, double* %11
%46 = load double*, double** %7
%47 = getelementptr inbounds double, double* %46, i64 2
%48 = load double, double* %47
%49 = load double, double* %9
%50 = fdiv double %48, %49
store double %50, double* %12
%51 = load %struct.BONDS*, %struct.BONDS** %5
%52 = load i32, i32* %6
%53 = load double, double* %9
%54 = call double @BONDS_fr_i(%struct.BONDS* %51, i32 %52, double %53)
store double %54, double* %13
%55 = load double, double* %13
%56 = load double, double* %10
%57 = fmul double %55, %56
%58 = load double*, double** %8
%59 = getelementptr inbounds double, double* %58, i64 0
store double %57, double* %59
%60 = load double, double* %13
%61 = load double, double* %11
%62 = fmul double %60, %61
%63 = load double*, double** %8
%64 = getelementptr inbounds double, double* %63, i64 1
store double %62, double* %64
%65 = load double, double* %13
%66 = load double, double* %12
%67 = fmul double %65, %66
%68 = load double*, double** %8
%69 = getelementptr inbounds double, double* %68, i64 2
store double %67, double* %69
ret void
}

LLVM IR (-O2):
%struct.BONDS = type { i32 }
define void @BONDS_calc_force_spring_i(%struct.BONDS* %0, i32 %1, double* nocapture %2, double* nocapture writeonly %3) {
%5 = load double, double* %2
%6 = getelementptr inbounds double, double* %2, i64 1
%7 = load double, double* %6
%8 = fmul double %7, %7
%9 = tail call double @llvm.fmuladd.f64(double %5, double %5, double %8)
%10 = getelementptr inbounds double, double* %2, i64 2
%11 = load double, double* %10
%12 = tail call double @llvm.fmuladd.f64(double %11, double %11, double %9)
%13 = tail call double @sqrt(double %12)
%14 = bitcast double* %2 to <2 x double>*
%15 = load <2 x double>, <2 x double>* %14
%16 = insertelement <2 x double> poison, double %13, i64 0
%17 = shufflevector <2 x double> %16, <2 x double> poison, <2 x i32> zeroinitializer
%18 = fdiv <2 x double> %15, %17
%19 = load double, double* %10
%20 = fdiv double %19, %13
%21 = tail call double @BONDS_fr_i(%struct.BONDS* %0, i32 %1, double %13)
%22 = insertelement <2 x double> poison, double %21, i64 0
%23 = shufflevector <2 x double> %22, <2 x double> poison, <2 x i32> zeroinitializer
%24 = fmul <2 x double> %18, %23
%25 = bitcast double* %3 to <2 x double>*
store <2 x double> %24, <2 x double>* %25
%26 = fmul double %21, %20
%27 = getelementptr inbounds double, double* %3, i64 2
store double %26, double* %27
ret void
}