void rosenbrockgrad(double *x, int N, double *g) {
  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)
movsd  0xef1(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  -0x30(%rbp),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
divsd  -0x28(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe9e(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
movsd  0xe7c(%rip),%xmm1
mulsd  -0x28(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm3
movsd  -0x28(%rbp),%xmm4
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm4,%xmm3
movsd  0xe3f(%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  0xe00(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
divsd  -0x28(%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) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca double*
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double* %0, double** %4
store i32 %1, i32* %5
store double* %2, double** %6
store double 1.000000e+00, double* %8
%10 = load double, double* %8
%11 = load double, double* %8
%12 = fmul double %10, %11
store double %12, double* %9
%13 = load double*, double** %4
%14 = getelementptr inbounds double, double* %13, i64 0
%15 = load double, double* %14
%16 = load double*, double** %4
%17 = getelementptr inbounds double, double* %16, i64 0
%18 = load double, double* %17
%19 = fmul double %15, %18
%20 = load double, double* %9
%21 = load double*, double** %4
%22 = getelementptr inbounds double, double* %21, i64 1
%23 = load double, double* %22
%24 = load double, double* %8
%25 = fdiv double %23, %24
%26 = fneg double %25
%27 = call double @llvm.fmuladd.f64(double %19, double %20, double %26)
store double %27, double* %7
%28 = load double, double* %7
%29 = fmul double 4.000000e+02, %28
%30 = load double, double* %9
%31 = fmul double %29, %30
%32 = load double*, double** %4
%33 = getelementptr inbounds double, double* %32, i64 0
%34 = load double, double* %33
%35 = load double, double* %8
%36 = fmul double 2.000000e+00, %35
%37 = load double*, double** %4
%38 = getelementptr inbounds double, double* %37, i64 0
%39 = load double, double* %38
%40 = load double, double* %8
%41 = fneg double %39
%42 = call double @llvm.fmuladd.f64(double %41, double %40, double 1.000000e+00)
%43 = fmul double %36, %42
%44 = fneg double %43
%45 = call double @llvm.fmuladd.f64(double %31, double %34, double %44)
%46 = load double*, double** %6
%47 = getelementptr inbounds double, double* %46, i64 0
store double %45, double* %47
%48 = load double, double* %7
%49 = fmul double -2.000000e+02, %48
%50 = load double, double* %8
%51 = fdiv double %49, %50
%52 = load double*, double** %6
%53 = getelementptr inbounds double, double* %52, i64 1
store double %51, double* %53
ret void
}

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