#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 odem_particle {
  int dummy;
};

/* Variables and functions */
double odem_delta(struct odem_particle const *, struct odem_particle const *);
int /*<<< orphan*/ odem_me12(double *, struct odem_particle const *,
                             struct odem_particle const *);
int odem_mforce_collision_spring(double force_vec[],
                                 const struct odem_particle *pp1,
                                 const struct odem_particle *pp2,
                                 const double spring_constant) {
  int i;
  double delta;
  delta = odem_delta(pp1, pp2);
  if (delta < 0) {
    odem_me12(force_vec, pp1, pp2);
    for (i = 0; i < 2; i++)
      force_vec[i] *= delta * spring_constant;
    return 1;
  } else {
    for (i = 0; i < 2; i++)
      force_vec[i] = 0;
    return 0;
  }
}


x86 assembly (clang, -O0):
<odem_mforce_collision_spring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <odem_delta@plt>
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    11b1 <odem_mforce_collision_spring+0x91>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <odem_me12@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x2,-0x2c(%rbp)
jge    11a5 <odem_mforce_collision_spring+0x85>
movsd  -0x38(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1171 <odem_mforce_collision_spring+0x51>
movl   $0x1,-0x4(%rbp)
jmp    11e7 <odem_mforce_collision_spring+0xc7>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x2,-0x2c(%rbp)
jge    11e0 <odem_mforce_collision_spring+0xc0>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11b8 <odem_mforce_collision_spring+0x98>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<odem_mforce_collision_spring>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1030 <odem_delta@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    1186 <odem_mforce_collision_spring+0x66>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
movapd %xmm0,0x10(%rsp)
call   1040 <odem_me12@plt>
movapd 0x10(%rsp),%xmm1
mulsd  0x8(%rsp),%xmm1
movupd (%r14),%xmm0
unpcklpd %xmm1,%xmm1
mulpd  %xmm0,%xmm1
movupd %xmm1,(%r14)
mov    $0x1,%eax
jmp    1191 <odem_mforce_collision_spring+0x71>
xorpd  %xmm0,%xmm0
movupd %xmm0,(%r14)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.odem_particle = type { i32 }
define i32 @odem_mforce_collision_spring(double* %0, %struct.odem_particle* %1, %struct.odem_particle* %2, double %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca %struct.odem_particle*
%8 = alloca %struct.odem_particle*
%9 = alloca double
%10 = alloca i32
%11 = alloca double
store double* %0, double** %6
store %struct.odem_particle* %1, %struct.odem_particle** %7
store %struct.odem_particle* %2, %struct.odem_particle** %8
store double %3, double* %9
%12 = load %struct.odem_particle*, %struct.odem_particle** %7
%13 = load %struct.odem_particle*, %struct.odem_particle** %8
%14 = call double @odem_delta(%struct.odem_particle* %12, %struct.odem_particle* %13)
store double %14, double* %11
%15 = load double, double* %11
%16 = fcmp olt double %15, 0.000000e+00
br i1 %16, label %17, label %39
17: ; preds = %4
%18 = load double*, double** %6
%19 = load %struct.odem_particle*, %struct.odem_particle** %7
%20 = load %struct.odem_particle*, %struct.odem_particle** %8
%21 = call i32 @odem_me12(double* %18, %struct.odem_particle* %19, %struct.odem_particle* %20)
store i32 0, i32* %10
br label %22
22: ; preds = %35, %17
%23 = load i32, i32* %10
%24 = icmp slt i32 %23, 2
br i1 %24, label %25, label %38
25: ; preds = %22
%26 = load double, double* %11
%27 = load double, double* %9
%28 = fmul double %26, %27
%29 = load double*, double** %6
%30 = load i32, i32* %10
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = fmul double %33, %28
store double %34, double* %32
br label %35
35: ; preds = %25
%36 = load i32, i32* %10
%37 = add nsw i32 %36, 1
store i32 %37, i32* %10
br label %22
38: ; preds = %22
store i32 1, i32* %5
br label %52
39: ; preds = %4
store i32 0, i32* %10
br label %40
40: ; preds = %48, %39
%41 = load i32, i32* %10
%42 = icmp slt i32 %41, 2
br i1 %42, label %43, label %51
43: ; preds = %40
%44 = load double*, double** %6
%45 = load i32, i32* %10
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
store double 0.000000e+00, double* %47
br label %48
48: ; preds = %43
%49 = load i32, i32* %10
%50 = add nsw i32 %49, 1
store i32 %50, i32* %10
br label %40
51: ; preds = %40
store i32 0, i32* %5
br label %52
52: ; preds = %51, %38
%53 = load i32, i32* %5
ret i32 %53
}

LLVM IR (-O2):
%struct.odem_particle = type { i32 }
define i32 @odem_mforce_collision_spring(double* %0, %struct.odem_particle* %1, %struct.odem_particle* %2, double %3) {
%5 = tail call double @odem_delta(%struct.odem_particle* %1, %struct.odem_particle* %2)
%6 = fcmp olt double %5, 0.000000e+00
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = bitcast double* %0 to i8*
br label %18
9: ; preds = %4
%10 = tail call i32 @odem_me12(double* %0, %struct.odem_particle* %1, %struct.odem_particle* %2)
%11 = fmul double %5, %3
%12 = bitcast double* %0 to <2 x double>*
%13 = load <2 x double>, <2 x double>* %12
%14 = insertelement <2 x double> poison, double %11, i64 0
%15 = shufflevector <2 x double> %14, <2 x double> poison, <2 x i32> zeroinitializer
%16 = fmul <2 x double> %15, %13
%17 = bitcast double* %0 to <2 x double>*
store <2 x double> %16, <2 x double>* %17
br label %18
18: ; preds = %7, %9
%19 = phi i32 [ 1, %9 ], [ 0, %7 ]
ret i32 %19
}