void jachs28(double *p, double *jac, int m, int n, void *data) {
  register int i, j;
  double t1, t2;
  t1 = p[0] + p[1];
  t2 = p[1] + p[2];
  for (i = j = 0; i < n; ++i) {
    jac[j++] = 2.0 * t1;
    jac[j++] = 2.0 * (t1 + t2);
    jac[j++] = 2.0 * t2;
  }
}


x86 assembly (clang, -O0):
<jachs28>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11e0 <jachs28+0xe0>
movsd  0xe9b(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x28(%rbp)
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x30(%rbp),%xmm1
addsd  -0x38(%rbp),%xmm1
movsd  0xe6d(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x28(%rbp)
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  0xe4a(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x28(%rbp)
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1151 <jachs28+0x51>
pop    %rbp
ret

x86 assembly (clang, -O2):
<jachs28>:
test   %ecx,%ecx
jle    11e2 <jachs28+0xe2>
movsd  0x8(%rdi),%xmm0
movsd  (%rdi),%xmm1
addsd  %xmm0,%xmm1
addsd  0x10(%rdi),%xmm0
movapd %xmm1,%xmm2
addsd  %xmm0,%xmm2
unpcklpd %xmm2,%xmm1
addpd  %xmm1,%xmm1
addsd  %xmm0,%xmm0
lea    -0x1(%rcx),%edi
cmp    $0x3,%edi
jae    1141 <jachs28+0x41>
xor    %r8d,%r8d
xor    %r9d,%r9d
jmp    11bc <jachs28+0xbc>
add    $0x1,%rdi
mov    %rdi,%r9
and    $0xfffffffffffffffc,%r9
lea    (%r9,%r9,2),%r8
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
movapd %xmm1,%xmm3
unpcklpd %xmm2,%xmm3
movapd %xmm0,%xmm4
unpcklpd %xmm1,%xmm4
movapd %xmm2,%xmm5
unpcklpd %xmm0,%xmm5
movapd %xmm0,%xmm6
unpcklpd %xmm1,%xmm6
movapd %xmm1,%xmm7
unpcklpd %xmm2,%xmm7
unpcklpd %xmm0,%xmm2
mov    %rsi,%rdx
mov    %r9,%rax
nopw   0x0(%rax,%rax,1)
movupd %xmm3,(%rdx)
movupd %xmm4,0x10(%rdx)
movupd %xmm5,0x20(%rdx)
movupd %xmm7,0x30(%rdx)
movupd %xmm6,0x40(%rdx)
movupd %xmm2,0x50(%rdx)
add    $0x60,%rdx
add    $0xfffffffffffffffc,%rax
jne    1190 <jachs28+0x90>
cmp    %r9,%rdi
je     11e2 <jachs28+0xe2>
lea    (%rsi,%r8,8),%rax
add    $0x10,%rax
sub    %r9d,%ecx
nopw   0x0(%rax,%rax,1)
movupd %xmm1,-0x10(%rax)
movsd  %xmm0,(%rax)
add    $0x18,%rax
add    $0xffffffff,%ecx
jne    11d0 <jachs28+0xd0>
ret

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

LLVM IR (-O2):
define void @jachs28(double* nocapture %0, double* nocapture writeonly %1, i32 %2, i32 %3, i8* nocapture readnone %4) {
%6 = load double, double* %0
%7 = getelementptr inbounds double, double* %0, i64 1
%8 = load double, double* %7
%9 = fadd double %6, %8
%10 = getelementptr inbounds double, double* %0, i64 2
%11 = load double, double* %10
%12 = fadd double %8, %11
%13 = icmp sgt i32 %3, 0
br i1 %13, label %14, label %65
14: ; preds = %5
%15 = fadd double %9, %12
%16 = insertelement <2 x double> poison, double %9, i64 0
%17 = insertelement <2 x double> %16, double %15, i64 1
%18 = fmul <2 x double> %17, <double 2.000000e+00, double 2.000000e+00>
%19 = fmul double %12, 2.000000e+00
%20 = add i32 %3, -1
%21 = zext i32 %20 to i64
%22 = add nuw nsw i64 %21, 1
%23 = icmp ult i32 %20, 3
br i1 %23, label %52, label %24
24: ; preds = %14
%25 = and i64 %22, 8589934588
%26 = mul nuw nsw i64 %25, 3
%27 = trunc i64 %25 to i32
%28 = shufflevector <2 x double> %18, <2 x double> poison, <2 x i32> zeroinitializer
%29 = shufflevector <2 x double> %18, <2 x double> undef, <2 x i32> <i32 1, i32 1>
%30 = insertelement <2 x double> poison, double %19, i64 0
%31 = getelementptr inbounds double, double* %1, i64 -2
%32 = getelementptr inbounds double, double* %1, i64 -2
%33 = shufflevector <2 x double> %28, <2 x double> %29, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
%34 = shufflevector <2 x double> %30, <2 x double> poison, <4 x i32> <i32 0, i32 0, i32 undef, i32 undef>
%35 = shufflevector <4 x double> %33, <4 x double> %34, <6 x i32> <i32 0, i32 2, i32 4, i32 1, i32 3, i32 5>
%36 = shufflevector <2 x double> %28, <2 x double> %29, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
%37 = shufflevector <2 x double> %30, <2 x double> poison, <4 x i32> <i32 0, i32 0, i32 undef, i32 undef>
%38 = shufflevector <4 x double> %36, <4 x double> %37, <6 x i32> <i32 0, i32 2, i32 4, i32 1, i32 3, i32 5>
br label %39
39: ; preds = %39, %24
%40 = phi i64 [ 0, %24 ], [ %48, %39 ]
%41 = mul i64 %40, 3
%42 = or i64 %41, 2
%43 = add i64 %41, 8
%44 = getelementptr inbounds double, double* %31, i64 %42
%45 = bitcast double* %44 to <6 x double>*
%46 = getelementptr inbounds double, double* %32, i64 %43
%47 = bitcast double* %46 to <6 x double>*
store <6 x double> %35, <6 x double>* %45
store <6 x double> %38, <6 x double>* %47
%48 = add nuw i64 %40, 4
%49 = icmp eq i64 %48, %25
br i1 %49, label %50, label %39
50: ; preds = %39
%51 = icmp eq i64 %22, %25
br i1 %51, label %65, label %52
52: ; preds = %14, %50
%53 = phi i64 [ 0, %14 ], [ %26, %50 ]
%54 = phi i32 [ 0, %14 ], [ %27, %50 ]
br label %55
55: ; preds = %52, %55
%56 = phi i64 [ %61, %55 ], [ %53, %52 ]
%57 = phi i32 [ %63, %55 ], [ %54, %52 ]
%58 = getelementptr inbounds double, double* %1, i64 %56
%59 = add nuw nsw i64 %56, 2
%60 = bitcast double* %58 to <2 x double>*
store <2 x double> %18, <2 x double>* %60
%61 = add nuw nsw i64 %56, 3
%62 = getelementptr inbounds double, double* %1, i64 %59
store double %19, double* %62
%63 = add nuw nsw i32 %57, 1
%64 = icmp eq i32 %63, %3
br i1 %64, label %65, label %55
65: ; preds = %55, %50, %5
ret void
}