#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 */
float glmDotProduct2d(double const *, double const *);
int /*<<< orphan*/ glmMakeVector2d(double *, double const *, double const *);
double glmComputeImpulse2d(const double v1[2], const double v2[2], float invM1,
                           float invM2, const double normal[2], double e) {
  double d;
  double v[2];
  d = glmDotProduct2d(normal, normal);
  d *= invM1 + invM2;
  glmMakeVector2d(v, v1, v2);
  return -((1.0f + e) * glmDotProduct2d(v, normal)) / d;
}


x86 assembly (clang, -O0):
<glmComputeImpulse2d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
movss  %xmm1,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <glmDotProduct2d@plt>
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movss  -0x14(%rbp),%xmm0
addss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1030 <glmMakeVector2d@plt>
movsd  0xe76(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <glmDotProduct2d@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x30(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glmComputeImpulse2d>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
movaps %xmm2,0x10(%rsp)
mov    %rdx,%rbx
movss  %xmm1,(%rsp)
movss  %xmm0,0xc(%rsp)
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rdx,%rdi
mov    %rdx,%rsi
call   1040 <glmDotProduct2d@plt>
cvtss2sd %xmm0,%xmm0
movss  0xc(%rsp),%xmm1
addss  (%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
lea    0x20(%rsp),%r12
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <glmMakeVector2d@plt>
movapd 0x10(%rsp),%xmm0
addsd  0xe74(%rip),%xmm0
movapd %xmm0,0x10(%rsp)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <glmDotProduct2d@plt>
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movapd 0x10(%rsp),%xmm0
xorpd  0xe5e(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  (%rsp),%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @glmComputeImpulse2d(double* %0, double* %1, float %2, float %3, double* %4, double %5) {
%7 = alloca double*
%8 = alloca double*
%9 = alloca float
%10 = alloca float
%11 = alloca double*
%12 = alloca double
%13 = alloca double
%14 = alloca [2 x double]
store double* %0, double** %7
store double* %1, double** %8
store float %2, float* %9
store float %3, float* %10
store double* %4, double** %11
store double %5, double* %12
%15 = load double*, double** %11
%16 = load double*, double** %11
%17 = call float @glmDotProduct2d(double* %15, double* %16)
%18 = fpext float %17 to double
store double %18, double* %13
%19 = load float, float* %9
%20 = load float, float* %10
%21 = fadd float %19, %20
%22 = fpext float %21 to double
%23 = load double, double* %13
%24 = fmul double %23, %22
store double %24, double* %13
%25 = getelementptr inbounds [2 x double], [2 x double]* %14, i64 0, i64 0
%26 = load double*, double** %7
%27 = load double*, double** %8
%28 = call i32 @glmMakeVector2d(double* %25, double* %26, double* %27)
%29 = load double, double* %12
%30 = fadd double 1.000000e+00, %29
%31 = getelementptr inbounds [2 x double], [2 x double]* %14, i64 0, i64 0
%32 = load double*, double** %11
%33 = call float @glmDotProduct2d(double* %31, double* %32)
%34 = fpext float %33 to double
%35 = fmul double %30, %34
%36 = fneg double %35
%37 = load double, double* %13
%38 = fdiv double %36, %37
ret double %38
}

LLVM IR (-O2):
define double @glmComputeImpulse2d(double* %0, double* %1, float %2, float %3, double* %4, double %5) {
%7 = alloca [2 x double]
%8 = bitcast [2 x double]* %7 to i8*
%9 = tail call float @glmDotProduct2d(double* %4, double* %4)
%10 = fpext float %9 to double
%11 = fadd float %2, %3
%12 = fpext float %11 to double
%13 = fmul double %12, %10
%14 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 0
%15 = call i32 @glmMakeVector2d(double* %14, double* %0, double* %1)
%16 = fadd double %5, 1.000000e+00
%17 = call float @glmDotProduct2d(double* %14, double* %4)
%18 = fpext float %17 to double
%19 = fneg double %16
%20 = fmul double %19, %18
%21 = fdiv double %20, %13
ret double %21
}