void jacobian(int neqn, int nvar, const double *x, double *jac) {
  jac[((neqn) * (0) + (0))] = 2.0 * x[0];
  jac[((neqn) * (1) + (0))] = 2.0 * x[1];
  jac[((neqn) * (0) + (1))] = 2.0 * x[0];
  jac[((neqn) * (1) + (1))] = -4.0 * x[1];
}


x86 assembly (clang, -O0):
<jacobian>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  0xeea(%rip),%xmm0
mulsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
imul   $0x0,-0x4(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movsd  0xec7(%rip),%xmm0
mulsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x4(%rbp),%ecx
shl    $0x0,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movsd  0xea1(%rip),%xmm0
mulsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
imul   $0x0,-0x4(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movsd  0xe76(%rip),%xmm0
mulsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x4(%rbp),%ecx
shl    $0x0,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
pop    %rbp
ret

x86 assembly (clang, -O2):
<jacobian>:
movsd  (%rdx),%xmm0
addsd  %xmm0,%xmm0
movsd  %xmm0,(%rcx)
movsd  0x8(%rdx),%xmm0
addsd  %xmm0,%xmm0
movslq %edi,%rax
movsd  %xmm0,(%rcx,%rax,8)
movsd  (%rdx),%xmm0
addsd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rcx)
movsd  0x8(%rdx),%xmm0
mulsd  0xec9(%rip),%xmm0
movsd  %xmm0,0x8(%rcx,%rax,8)
ret

LLVM IR (-O0):
define void @jacobian(i32 %0, i32 %1, double* %2, double* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
store i32 %0, i32* %5
store i32 %1, i32* %6
store double* %2, double** %7
store double* %3, double** %8
%9 = load double*, double** %7
%10 = getelementptr inbounds double, double* %9, i64 0
%11 = load double, double* %10
%12 = fmul double 2.000000e+00, %11
%13 = load double*, double** %8
%14 = load i32, i32* %5
%15 = mul nsw i32 %14, 0
%16 = add nsw i32 %15, 0
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds double, double* %13, i64 %17
store double %12, double* %18
%19 = load double*, double** %7
%20 = getelementptr inbounds double, double* %19, i64 1
%21 = load double, double* %20
%22 = fmul double 2.000000e+00, %21
%23 = load double*, double** %8
%24 = load i32, i32* %5
%25 = mul nsw i32 %24, 1
%26 = add nsw i32 %25, 0
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %23, i64 %27
store double %22, double* %28
%29 = load double*, double** %7
%30 = getelementptr inbounds double, double* %29, i64 0
%31 = load double, double* %30
%32 = fmul double 2.000000e+00, %31
%33 = load double*, double** %8
%34 = load i32, i32* %5
%35 = mul nsw i32 %34, 0
%36 = add nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %33, i64 %37
store double %32, double* %38
%39 = load double*, double** %7
%40 = getelementptr inbounds double, double* %39, i64 1
%41 = load double, double* %40
%42 = fmul double -4.000000e+00, %41
%43 = load double*, double** %8
%44 = load i32, i32* %5
%45 = mul nsw i32 %44, 1
%46 = add nsw i32 %45, 1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %43, i64 %47
store double %42, double* %48
ret void
}

LLVM IR (-O2):
define void @jacobian(i32 %0, i32 %1, double* nocapture %2, double* nocapture writeonly %3) {
%5 = load double, double* %2
%6 = fmul double %5, 2.000000e+00
store double %6, double* %3
%7 = getelementptr inbounds double, double* %2, i64 1
%8 = load double, double* %7
%9 = fmul double %8, 2.000000e+00
%10 = sext i32 %0 to i64
%11 = getelementptr inbounds double, double* %3, i64 %10
store double %9, double* %11
%12 = load double, double* %2
%13 = fmul double %12, 2.000000e+00
%14 = getelementptr inbounds double, double* %3, i64 1
store double %13, double* %14
%15 = load double, double* %7
%16 = fmul double %15, -4.000000e+00
%17 = add nsw i32 %0, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %3, i64 %18
store double %16, double* %19
ret void
}