#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(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 = 0.5 * (r1 + r2) * (r2 - r1) * st1;
  else
    dA = 0.0;
  return dA;
}


x86 assembly (clang, -O0):
<geom_dA_sph_rtp>:
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+0xcc>
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1226 <geom_dA_sph_rtp+0x116>
cmpl   $0x1,-0x14(%rbp)
jne    1219 <geom_dA_sph_rtp+0x109>
movsd  -0x28(%rbp),%xmm1
addsd  -0x30(%rbp),%xmm1
movsd  0xe08(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm1
subsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1221 <geom_dA_sph_rtp+0x111>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1226 <geom_dA_sph_rtp+0x116>
movsd  -0x20(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geom_dA_sph_rtp>:
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+0x9e>
movsd  (%rsp),%xmm1
xorpd  %xmm0,%xmm0
test   %ebx,%ebx
jne    11da <geom_dA_sph_rtp+0xca>
imul   %eax,%ebp
add    %ebp,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
jmp    11da <geom_dA_sph_rtp+0xca>
cvtsi2sd %r14d,%xmm2
movsd  (%rsp),%xmm3
movapd %xmm3,%xmm1
movsd  0x18(%rsp),%xmm0
addsd  %xmm0,%xmm1
mulsd  0xe32(%rip),%xmm1
subsd  %xmm3,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @geom_dA_sph_rtp(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 %66
50: ; preds = %3
%51 = load i32, i32* %6
%52 = icmp eq i32 %51, 1
br i1 %52, label %53, label %64
53: ; preds = %50
%54 = load double, double* %8
%55 = load double, double* %9
%56 = fadd double %54, %55
%57 = fmul double 5.000000e-01, %56
%58 = load double, double* %9
%59 = load double, double* %8
%60 = fsub double %58, %59
%61 = fmul double %57, %60
%62 = load double, double* %12
%63 = fmul double %61, %62
store double %63, double* %7
br label %65
64: ; preds = %50
store double 0.000000e+00, double* %7
br label %65
65: ; preds = %64, %53
br label %66
66: ; preds = %65, %44
%67 = load double, double* %7
ret double %67
}

LLVM IR (-O2):
define double @geom_dA_sph_rtp(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 %30 [
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 %30
23: ; preds = %3
%24 = sitofp i32 %10 to double
%25 = fadd double %4, %5
%26 = fmul double %25, 5.000000e-01
%27 = fsub double %5, %4
%28 = fmul double %27, %26
%29 = fmul double %28, %24
br label %30
30: ; preds = %3, %23, %17
%31 = phi double [ %22, %17 ], [ %29, %23 ], [ 0.000000e+00, %3 ]
ret double %31
}