#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 */
double cos(double const);
void modele_gravite(const double q[2], double G[2]) {
  double c1, c12;
  c1 = cos(q[0]);
  c12 = cos(q[0] + q[1]);
  G[0] = 5 * 1 * 9.81 * c12 + (10 + 5) * 1 * 9.81 * c1;
  G[1] = 5 * 1 * 9.81 * c12;
}


x86 assembly (clang, -O0):
<modele_gravite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <cos@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x8(%rax),%xmm0
call   1030 <cos@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xeae(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
movsd  0xe99(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xe81(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<modele_gravite>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
call   1030 <cos@plt>
movsd  %xmm0,(%rsp)
movsd  (%rbx),%xmm0
addsd  0x8(%rbx),%xmm0
call   1030 <cos@plt>
movsd  (%rsp),%xmm1
mulsd  0xebd(%rip),%xmm1
mulsd  0xebd(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
movsd  %xmm0,0x8(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @modele_gravite(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca double
%6 = alloca double
store double* %0, double** %3
store double* %1, double** %4
%7 = load double*, double** %3
%8 = getelementptr inbounds double, double* %7, i64 0
%9 = load double, double* %8
%10 = call double @cos(double %9)
store double %10, double* %5
%11 = load double*, double** %3
%12 = getelementptr inbounds double, double* %11, i64 0
%13 = load double, double* %12
%14 = load double*, double** %3
%15 = getelementptr inbounds double, double* %14, i64 1
%16 = load double, double* %15
%17 = fadd double %13, %16
%18 = call double @cos(double %17)
store double %18, double* %6
%19 = load double, double* %6
%20 = load double, double* %5
%21 = fmul double 1.471500e+02, %20
%22 = call double @llvm.fmuladd.f64(double 0x4048866666666667, double %19, double %21)
%23 = load double*, double** %4
%24 = getelementptr inbounds double, double* %23, i64 0
store double %22, double* %24
%25 = load double, double* %6
%26 = fmul double 0x4048866666666667, %25
%27 = load double*, double** %4
%28 = getelementptr inbounds double, double* %27, i64 1
store double %26, double* %28
ret void
}

LLVM IR (-O2):
define void @modele_gravite(double* nocapture %0, double* nocapture writeonly %1) {
%3 = load double, double* %0
%4 = tail call double @cos(double %3)
%5 = load double, double* %0
%6 = getelementptr inbounds double, double* %0, i64 1
%7 = load double, double* %6
%8 = fadd double %5, %7
%9 = tail call double @cos(double %8)
%10 = fmul double %4, 1.471500e+02
%11 = tail call double @llvm.fmuladd.f64(double %9, double 0x4048866666666667, double %10)
store double %11, double* %1
%12 = fmul double %9, 0x4048866666666667
%13 = getelementptr inbounds double, double* %1, i64 1
store double %12, double* %13
ret void
}