double geom_dA_cyl_rpz_B(double xm[], double xp[], int dir) {
  double dA;
  if (dir == 0)
    dA = xm[0] * (xp[1] - xm[1]);
  else if (dir == 1)
    dA = 0.5 * (xp[0] + xm[0]) * (xp[0] - xm[0]);
  else
    dA = 0.0;
  return dA;
}


x86 assembly (clang, -O0):
<geom_dA_cyl_rpz_B>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1141 <geom_dA_cyl_rpz_B+0x41>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x8(%rbp),%rax
subsd  0x8(%rax),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1192 <geom_dA_cyl_rpz_B+0x92>
cmpl   $0x1,-0x14(%rbp)
jne    1185 <geom_dA_cyl_rpz_B+0x85>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
addsd  (%rax),%xmm1
movsd  0xe9d(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
subsd  (%rax),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    118d <geom_dA_cyl_rpz_B+0x8d>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1192 <geom_dA_cyl_rpz_B+0x92>
movsd  -0x20(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<geom_dA_cyl_rpz_B>:
cmp    $0x1,%edx
je     111c <geom_dA_cyl_rpz_B+0x1c>
xorpd  %xmm0,%xmm0
test   %edx,%edx
jne    113c <geom_dA_cyl_rpz_B+0x3c>
movsd  0x8(%rsi),%xmm0
subsd  0x8(%rdi),%xmm0
mulsd  (%rdi),%xmm0
ret
movsd  (%rsi),%xmm0
movsd  (%rdi),%xmm1
movapd %xmm0,%xmm2
addsd  %xmm1,%xmm2
mulsd  0xecc(%rip),%xmm2
subsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
ret

LLVM IR (-O0):
define double @geom_dA_cyl_rpz_B(double* %0, double* %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca double
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %22
10: ; preds = %3
%11 = load double*, double** %4
%12 = getelementptr inbounds double, double* %11, i64 0
%13 = load double, double* %12
%14 = load double*, double** %5
%15 = getelementptr inbounds double, double* %14, i64 1
%16 = load double, double* %15
%17 = load double*, double** %4
%18 = getelementptr inbounds double, double* %17, i64 1
%19 = load double, double* %18
%20 = fsub double %16, %19
%21 = fmul double %13, %20
store double %21, double* %7
br label %44
22: ; preds = %3
%23 = load i32, i32* %6
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %42
25: ; preds = %22
%26 = load double*, double** %5
%27 = getelementptr inbounds double, double* %26, i64 0
%28 = load double, double* %27
%29 = load double*, double** %4
%30 = getelementptr inbounds double, double* %29, i64 0
%31 = load double, double* %30
%32 = fadd double %28, %31
%33 = fmul double 5.000000e-01, %32
%34 = load double*, double** %5
%35 = getelementptr inbounds double, double* %34, i64 0
%36 = load double, double* %35
%37 = load double*, double** %4
%38 = getelementptr inbounds double, double* %37, i64 0
%39 = load double, double* %38
%40 = fsub double %36, %39
%41 = fmul double %33, %40
store double %41, double* %7
br label %43
42: ; preds = %22
store double 0.000000e+00, double* %7
br label %43
43: ; preds = %42, %25
br label %44
44: ; preds = %43, %10
%45 = load double, double* %7
ret double %45
}

LLVM IR (-O2):
define double @geom_dA_cyl_rpz_B(double* nocapture %0, double* nocapture %1, i32 %2) {
switch i32 %2, label %19 [
i32 0, label %4
i32 1, label %12
]
4: ; preds = %3
%5 = load double, double* %0
%6 = getelementptr inbounds double, double* %1, i64 1
%7 = load double, double* %6
%8 = getelementptr inbounds double, double* %0, i64 1
%9 = load double, double* %8
%10 = fsub double %7, %9
%11 = fmul double %5, %10
br label %19
12: ; preds = %3
%13 = load double, double* %1
%14 = load double, double* %0
%15 = fadd double %13, %14
%16 = fmul double %15, 5.000000e-01
%17 = fsub double %13, %14
%18 = fmul double %17, %16
br label %19
19: ; preds = %3, %12, %4
%20 = phi double [ %11, %4 ], [ %18, %12 ], [ 0.000000e+00, %3 ]
ret double %20
}