void browngrad(double *x, int N, double *g, void *params) {
  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    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xef5(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  0xed3(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xea5(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe87(%rip),%xmm1
mulsd  -0x38(%rbp),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x30(%rbp),%xmm0
movsd  0xe5c(%rip),%xmm1
mulsd  -0x38(%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, 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
%12 = load double*, double** %5
%13 = getelementptr inbounds double, double* %12, i64 0
%14 = load double, double* %13
%15 = fsub double %14, 1.000000e+06
store double %15, double* %9
%16 = load double*, double** %5
%17 = getelementptr inbounds double, double* %16, i64 1
%18 = load double, double* %17
%19 = fsub double %18, 2.000000e-06
store double %19, double* %10
%20 = load double*, double** %5
%21 = getelementptr inbounds double, double* %20, i64 0
%22 = load double, double* %21
%23 = load double*, double** %5
%24 = getelementptr inbounds double, double* %23, i64 1
%25 = load double, double* %24
%26 = call double @llvm.fmuladd.f64(double %22, double %25, double -2.000000e+00)
store double %26, double* %11
%27 = load double, double* %9
%28 = load double, double* %11
%29 = fmul double 2.000000e+00, %28
%30 = load double*, double** %5
%31 = getelementptr inbounds double, double* %30, i64 1
%32 = load double, double* %31
%33 = fmul double %29, %32
%34 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %27, double %33)
%35 = load double*, double** %7
%36 = getelementptr inbounds double, double* %35, i64 0
store double %34, double* %36
%37 = load double, double* %10
%38 = load double, double* %11
%39 = fmul double 2.000000e+00, %38
%40 = load double*, double** %5
%41 = getelementptr inbounds double, double* %40, i64 0
%42 = load double, double* %41
%43 = fmul double %39, %42
%44 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %37, double %43)
%45 = load double*, double** %7
%46 = getelementptr inbounds double, double* %45, i64 1
store double %44, double* %46
ret void
}

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