#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int sin(double);
double geom_dA_sph_rtp_B(double xm[], double xp[], int dir) {
  double dA;
  double r1 = xm[0];
  double r2 = xp[0];
  double th1 = xm[1];
  double th2 = xp[1];
  double st1 = sin(th1);
  double dcost = 2 * sin(0.5 * (th1 + th2)) * sin(0.5 * (th2 - th1));
  if (dir == 0)
    dA = r1 * r1 * dcost;
  else if (dir == 1)
    dA = (r1 * r1 + r1 * r2 + r2 * r2) * (r2 - r1) * st1 / 3.0;
  else
    dA = 0.0;
  return dA;
}


x86 assembly (clang, -O0):
<geom_dA_sph_rtp_B>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <sin@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm1
addsd  -0x40(%rbp),%xmm1
movsd  0xe82(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <sin@plt>
shl    $0x1,%eax
mov    %eax,-0x54(%rbp)
movsd  -0x40(%rbp),%xmm1
subsd  -0x38(%rbp),%xmm1
movsd  0xe61(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <sin@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x50(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11dc <geom_dA_sph_rtp_B+0xcc>
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    124a <geom_dA_sph_rtp_B+0x13a>
cmpl   $0x1,-0x14(%rbp)
jne    123d <geom_dA_sph_rtp_B+0x12d>
movsd  -0x28(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm1
subsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  0xdd9(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1245 <geom_dA_sph_rtp_B+0x135>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    124a <geom_dA_sph_rtp_B+0x13a>
movsd  -0x20(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geom_dA_sph_rtp_B>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %edx,%ebx
movsd  (%rdi),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rdi),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  (%rsi),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsi),%xmm0
movsd  %xmm0,0x10(%rsp)
movaps %xmm1,%xmm0
call   1030 <sin@plt>
mov    %eax,%r14d
movsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
mulsd  0xe9e(%rip),%xmm0
call   1030 <sin@plt>
mov    %eax,%ebp
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
mulsd  0xe83(%rip),%xmm0
call   1030 <sin@plt>
cmp    $0x1,%ebx
je     11ae <geom_dA_sph_rtp_B+0x9e>
movsd  (%rsp),%xmm1
xorpd  %xmm0,%xmm0
test   %ebx,%ebx
jne    11f2 <geom_dA_sph_rtp_B+0xe2>
imul   %eax,%ebp
add    %ebp,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
jmp    11f2 <geom_dA_sph_rtp_B+0xe2>
cvtsi2sd %r14d,%xmm3
movsd  (%rsp),%xmm4
movapd %xmm4,%xmm1
movsd  0x18(%rsp),%xmm0
mulsd  %xmm0,%xmm1
movapd %xmm4,%xmm2
mulsd  %xmm4,%xmm2
addsd  %xmm1,%xmm2
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
subsd  %xmm4,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm3,%xmm0
divsd  0xe16(%rip),%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @geom_dA_sph_rtp_B(double* %0, double* %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
%14 = load double*, double** %4
%15 = getelementptr inbounds double, double* %14, i64 0
%16 = load double, double* %15
store double %16, double* %8
%17 = load double*, double** %5
%18 = getelementptr inbounds double, double* %17, i64 0
%19 = load double, double* %18
store double %19, double* %9
%20 = load double*, double** %4
%21 = getelementptr inbounds double, double* %20, i64 1
%22 = load double, double* %21
store double %22, double* %10
%23 = load double*, double** %5
%24 = getelementptr inbounds double, double* %23, i64 1
%25 = load double, double* %24
store double %25, double* %11
%26 = load double, double* %10
%27 = call i32 @sin(double %26)
%28 = sitofp i32 %27 to double
store double %28, double* %12
%29 = load double, double* %10
%30 = load double, double* %11
%31 = fadd double %29, %30
%32 = fmul double 5.000000e-01, %31
%33 = call i32 @sin(double %32)
%34 = mul nsw i32 2, %33
%35 = load double, double* %11
%36 = load double, double* %10
%37 = fsub double %35, %36
%38 = fmul double 5.000000e-01, %37
%39 = call i32 @sin(double %38)
%40 = mul nsw i32 %34, %39
%41 = sitofp i32 %40 to double
store double %41, double* %13
%42 = load i32, i32* %6
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %50
44: ; preds = %3
%45 = load double, double* %8
%46 = load double, double* %8
%47 = fmul double %45, %46
%48 = load double, double* %13
%49 = fmul double %47, %48
store double %49, double* %7
br label %72
50: ; preds = %3
%51 = load i32, i32* %6
%52 = icmp eq i32 %51, 1
br i1 %52, label %53, label %70
53: ; preds = %50
%54 = load double, double* %8
%55 = load double, double* %8
%56 = load double, double* %8
%57 = load double, double* %9
%58 = fmul double %56, %57
%59 = call double @llvm.fmuladd.f64(double %54, double %55, double %58)
%60 = load double, double* %9
%61 = load double, double* %9
%62 = call double @llvm.fmuladd.f64(double %60, double %61, double %59)
%63 = load double, double* %9
%64 = load double, double* %8
%65 = fsub double %63, %64
%66 = fmul double %62, %65
%67 = load double, double* %12
%68 = fmul double %66, %67
%69 = fdiv double %68, 3.000000e+00
store double %69, double* %7
br label %71
70: ; preds = %50
store double 0.000000e+00, double* %7
br label %71
71: ; preds = %70, %53
br label %72
72: ; preds = %71, %44
%73 = load double, double* %7
ret double %73
}

LLVM IR (-O2):
define double @geom_dA_sph_rtp_B(double* nocapture %0, double* nocapture %1, i32 %2) {
%4 = load double, double* %0
%5 = load double, double* %1
%6 = getelementptr inbounds double, double* %0, i64 1
%7 = load double, double* %6
%8 = getelementptr inbounds double, double* %1, i64 1
%9 = load double, double* %8
%10 = tail call i32 @sin(double %7)
%11 = fadd double %7, %9
%12 = fmul double %11, 5.000000e-01
%13 = tail call i32 @sin(double %12)
%14 = fsub double %9, %7
%15 = fmul double %14, 5.000000e-01
%16 = tail call i32 @sin(double %15)
switch i32 %2, label %32 [
i32 0, label %17
i32 1, label %23
]
17: ; preds = %3
%18 = shl nsw i32 %13, 1
%19 = mul nsw i32 %18, %16
%20 = sitofp i32 %19 to double
%21 = fmul double %4, %4
%22 = fmul double %21, %20
br label %32
23: ; preds = %3
%24 = sitofp i32 %10 to double
%25 = fmul double %4, %5
%26 = tail call double @llvm.fmuladd.f64(double %4, double %4, double %25)
%27 = tail call double @llvm.fmuladd.f64(double %5, double %5, double %26)
%28 = fsub double %5, %4
%29 = fmul double %28, %27
%30 = fmul double %29, %24
%31 = fdiv double %30, 3.000000e+00
br label %32
32: ; preds = %3, %23, %17
%33 = phi double [ %22, %17 ], [ %31, %23 ], [ 0.000000e+00, %3 ]
ret double %33
}