void browngrad(double *x, int N, double *g) {
  double t1, t2, t3;
  t1 = x[0] - 1e06;
  t2 = x[1] - 2 * 1e-06;
  t3 = x[0] * x[1] - 2;
  g[0] = 2 * t1 + 2 * t3 * x[1];
  g[1] = 2 * t2 + 2 * t3 * x[0];
}


x86 assembly (clang, -O0):
<browngrad>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xef9(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  0xed7(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xea9(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe8b(%rip),%xmm1
mulsd  -0x30(%rbp),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
movsd  0xe60(%rip),%xmm1
mulsd  -0x30(%rbp),%xmm1
mov    -0x8(%rbp),%rax
mulsd  (%rax),%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<browngrad>:
movsd  (%rdi),%xmm0
movsd  0x8(%rdi),%xmm1
movsd  0xeef(%rip),%xmm2
addsd  %xmm0,%xmm2
movsd  0xeeb(%rip),%xmm3
mulsd  %xmm1,%xmm0
addsd  0xee7(%rip),%xmm0
addsd  %xmm1,%xmm3
addsd  %xmm0,%xmm0
mulsd  %xmm0,%xmm1
addsd  %xmm2,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,(%rdx)
mulsd  (%rdi),%xmm0
addsd  %xmm3,%xmm3
addsd  %xmm0,%xmm3
movsd  %xmm3,0x8(%rdx)
ret

LLVM IR (-O0):
define void @browngrad(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
%10 = load double*, double** %4
%11 = getelementptr inbounds double, double* %10, i64 0
%12 = load double, double* %11
%13 = fsub double %12, 1.000000e+06
store double %13, double* %7
%14 = load double*, double** %4
%15 = getelementptr inbounds double, double* %14, i64 1
%16 = load double, double* %15
%17 = fsub double %16, 2.000000e-06
store double %17, double* %8
%18 = load double*, double** %4
%19 = getelementptr inbounds double, double* %18, i64 0
%20 = load double, double* %19
%21 = load double*, double** %4
%22 = getelementptr inbounds double, double* %21, i64 1
%23 = load double, double* %22
%24 = call double @llvm.fmuladd.f64(double %20, double %23, double -2.000000e+00)
store double %24, double* %9
%25 = load double, double* %7
%26 = load double, double* %9
%27 = fmul double 2.000000e+00, %26
%28 = load double*, double** %4
%29 = getelementptr inbounds double, double* %28, i64 1
%30 = load double, double* %29
%31 = fmul double %27, %30
%32 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %25, double %31)
%33 = load double*, double** %6
%34 = getelementptr inbounds double, double* %33, i64 0
store double %32, double* %34
%35 = load double, double* %8
%36 = load double, double* %9
%37 = fmul double 2.000000e+00, %36
%38 = load double*, double** %4
%39 = getelementptr inbounds double, double* %38, i64 0
%40 = load double, double* %39
%41 = fmul double %37, %40
%42 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %35, double %41)
%43 = load double*, double** %6
%44 = getelementptr inbounds double, double* %43, i64 1
store double %42, double* %44
ret void
}

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