void rosenbrockgrad(double *x, int N, double *g, void *params) {
  double t, alpha, alpha2;
  alpha = 1;
  alpha2 = alpha * alpha;
  t = (x[0] * x[0] * alpha2 - x[1] / alpha);
  g[0] = 400 * t * alpha2 * x[0] - 2 * alpha * (1 - x[0] * alpha);
  g[1] = -200 * t / alpha;
}


x86 assembly (clang, -O0):
<rosenbrockgrad>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movsd  0xeed(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  -0x38(%rbp),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
divsd  -0x30(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe9a(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
movsd  0xe78(%rip),%xmm1
mulsd  -0x30(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm3
movsd  -0x30(%rbp),%xmm4
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm4,%xmm3
movsd  0xe3b(%rip),%xmm4
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xdfc(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<rosenbrockgrad>:
movsd  (%rdi),%xmm0
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
subsd  0x8(%rdi),%xmm1
movsd  0xee7(%rip),%xmm2
mulsd  %xmm1,%xmm2
movsd  0xee3(%rip),%xmm3
subsd  %xmm0,%xmm3
mulsd  %xmm0,%xmm2
addsd  %xmm3,%xmm3
subsd  %xmm3,%xmm2
movsd  %xmm2,(%rdx)
mulsd  0xecf(%rip),%xmm1
movsd  %xmm1,0x8(%rdx)
ret

LLVM IR (-O0):
define void @rosenbrockgrad(double* %0, i32 %1, double* %2, i8* %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca double*
%8 = alloca i8*
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double* %0, double** %5
store i32 %1, i32* %6
store double* %2, double** %7
store i8* %3, i8** %8
store double 1.000000e+00, double* %10
%12 = load double, double* %10
%13 = load double, double* %10
%14 = fmul double %12, %13
store double %14, double* %11
%15 = load double*, double** %5
%16 = getelementptr inbounds double, double* %15, i64 0
%17 = load double, double* %16
%18 = load double*, double** %5
%19 = getelementptr inbounds double, double* %18, i64 0
%20 = load double, double* %19
%21 = fmul double %17, %20
%22 = load double, double* %11
%23 = load double*, double** %5
%24 = getelementptr inbounds double, double* %23, i64 1
%25 = load double, double* %24
%26 = load double, double* %10
%27 = fdiv double %25, %26
%28 = fneg double %27
%29 = call double @llvm.fmuladd.f64(double %21, double %22, double %28)
store double %29, double* %9
%30 = load double, double* %9
%31 = fmul double 4.000000e+02, %30
%32 = load double, double* %11
%33 = fmul double %31, %32
%34 = load double*, double** %5
%35 = getelementptr inbounds double, double* %34, i64 0
%36 = load double, double* %35
%37 = load double, double* %10
%38 = fmul double 2.000000e+00, %37
%39 = load double*, double** %5
%40 = getelementptr inbounds double, double* %39, i64 0
%41 = load double, double* %40
%42 = load double, double* %10
%43 = fneg double %41
%44 = call double @llvm.fmuladd.f64(double %43, double %42, double 1.000000e+00)
%45 = fmul double %38, %44
%46 = fneg double %45
%47 = call double @llvm.fmuladd.f64(double %33, double %36, double %46)
%48 = load double*, double** %7
%49 = getelementptr inbounds double, double* %48, i64 0
store double %47, double* %49
%50 = load double, double* %9
%51 = fmul double -2.000000e+02, %50
%52 = load double, double* %10
%53 = fdiv double %51, %52
%54 = load double*, double** %7
%55 = getelementptr inbounds double, double* %54, i64 1
store double %53, double* %55
ret void
}

LLVM IR (-O2):
define void @rosenbrockgrad(double* nocapture %0, i32 %1, double* nocapture writeonly %2, i8* nocapture readnone %3) {
%5 = load double, double* %0
%6 = fmul double %5, %5
%7 = getelementptr inbounds double, double* %0, i64 1
%8 = load double, double* %7
%9 = fsub double %6, %8
%10 = fmul double %9, 4.000000e+02
%11 = fsub double 1.000000e+00, %5
%12 = fmul double %11, -2.000000e+00
%13 = tail call double @llvm.fmuladd.f64(double %10, double %5, double %12)
store double %13, double* %2
%14 = fmul double %9, -2.000000e+02
%15 = getelementptr inbounds double, double* %2, i64 1
store double %14, double* %15
ret void
}