#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 */
double get_dp(double const, double const);
int sin(double);
double get_dA(const double *xp, const double *xm, int dim) {
  double r = .5 * (xp[0] + xm[0]);
  if (dim == 0) {
    double dr = xp[0] - xm[0];
    double dth = xp[2] - xm[2];
    return r * dr * dth;
  } else if (dim == 1) {
    double sinth = sin(0.5 * (xp[2] + xm[2]));
    double sindth = 2 * sin(0.5 * (xp[2] - xm[2]));
    double dphi = get_dp(xp[1], xm[1]);
    return r * r * sinth * sindth * dphi;
  } else {
    double dr = xp[0] - xm[0];
    double sinth = sin(0.5 * (xp[2] + xm[2]));
    double dphi = get_dp(xp[1], xm[1]);
    return r * sinth * dr * dphi;
  }
}


x86 assembly (clang, -O0):
<get_dA>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x18(%rbp),%rax
addsd  (%rax),%xmm1
movsd  0xeb5(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    11a3 <get_dA+0x83>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
subsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12bd <get_dA+0x19d>
cmpl   $0x1,-0x1c(%rbp)
jne    1247 <get_dA+0x127>
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x18(%rbp),%rax
addsd  0x10(%rax),%xmm1
movsd  0xe39(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <sin@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x18(%rbp),%rax
subsd  0x10(%rax),%xmm1
movsd  0xe0d(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <sin@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm1
call   1040 <get_dp@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12bd <get_dA+0x19d>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x18(%rbp),%rax
addsd  0x10(%rax),%xmm1
movsd  0xd8a(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <sin@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm1
call   1040 <get_dp@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_dA>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
movsd  (%rsi),%xmm2
movapd %xmm0,%xmm1
addsd  %xmm2,%xmm1
mulsd  0xebb(%rip),%xmm1
cmp    $0x1,%edx
je     116e <get_dA+0x4e>
subsd  %xmm2,%xmm0
test   %edx,%edx
jne    11e6 <get_dA+0xc6>
movsd  0x10(%rbx),%xmm2
subsd  0x10(%r14),%xmm2
mulsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
jmp    123f <get_dA+0x11f>
movsd  0x10(%rbx),%xmm0
addsd  0x10(%r14),%xmm0
mulsd  0xe7f(%rip),%xmm0
movsd  %xmm1,0x10(%rsp)
call   1030 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rbx),%xmm0
subsd  0x10(%r14),%xmm0
mulsd  0xe54(%rip),%xmm0
call   1030 <sin@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rbx),%xmm0
movsd  0x8(%r14),%xmm1
call   1040 <get_dp@plt>
movsd  0x10(%rsp),%xmm2
mulsd  %xmm2,%xmm2
mulsd  0x8(%rsp),%xmm2
mulsd  (%rsp),%xmm2
jmp    1237 <get_dA+0x117>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rbx),%xmm0
addsd  0x10(%r14),%xmm0
mulsd  0xe01(%rip),%xmm0
movsd  %xmm1,0x10(%rsp)
call   1030 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rbx),%xmm0
movsd  0x8(%r14),%xmm1
call   1040 <get_dp@plt>
movsd  0x10(%rsp),%xmm2
mulsd  (%rsp),%xmm2
mulsd  0x8(%rsp),%xmm2
mulsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @get_dA(double* %0, double* %1, i32 %2) {
%4 = alloca double
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store i32 %2, i32* %7
%17 = load double*, double** %5
%18 = getelementptr inbounds double, double* %17, i64 0
%19 = load double, double* %18
%20 = load double*, double** %6
%21 = getelementptr inbounds double, double* %20, i64 0
%22 = load double, double* %21
%23 = fadd double %19, %22
%24 = fmul double 5.000000e-01, %23
store double %24, double* %8
%25 = load i32, i32* %7
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %47
27: ; preds = %3
%28 = load double*, double** %5
%29 = getelementptr inbounds double, double* %28, i64 0
%30 = load double, double* %29
%31 = load double*, double** %6
%32 = getelementptr inbounds double, double* %31, i64 0
%33 = load double, double* %32
%34 = fsub double %30, %33
store double %34, double* %9
%35 = load double*, double** %5
%36 = getelementptr inbounds double, double* %35, i64 2
%37 = load double, double* %36
%38 = load double*, double** %6
%39 = getelementptr inbounds double, double* %38, i64 2
%40 = load double, double* %39
%41 = fsub double %37, %40
store double %41, double* %10
%42 = load double, double* %8
%43 = load double, double* %9
%44 = fmul double %42, %43
%45 = load double, double* %10
%46 = fmul double %44, %45
store double %46, double* %4
br label %120
47: ; preds = %3
%48 = load i32, i32* %7
%49 = icmp eq i32 %48, 1
br i1 %49, label %50, label %88
50: ; preds = %47
%51 = load double*, double** %5
%52 = getelementptr inbounds double, double* %51, i64 2
%53 = load double, double* %52
%54 = load double*, double** %6
%55 = getelementptr inbounds double, double* %54, i64 2
%56 = load double, double* %55
%57 = fadd double %53, %56
%58 = fmul double 5.000000e-01, %57
%59 = call i32 @sin(double %58)
%60 = sitofp i32 %59 to double
store double %60, double* %11
%61 = load double*, double** %5
%62 = getelementptr inbounds double, double* %61, i64 2
%63 = load double, double* %62
%64 = load double*, double** %6
%65 = getelementptr inbounds double, double* %64, i64 2
%66 = load double, double* %65
%67 = fsub double %63, %66
%68 = fmul double 5.000000e-01, %67
%69 = call i32 @sin(double %68)
%70 = mul nsw i32 2, %69
%71 = sitofp i32 %70 to double
store double %71, double* %12
%72 = load double*, double** %5
%73 = getelementptr inbounds double, double* %72, i64 1
%74 = load double, double* %73
%75 = load double*, double** %6
%76 = getelementptr inbounds double, double* %75, i64 1
%77 = load double, double* %76
%78 = call double @get_dp(double %74, double %77)
store double %78, double* %13
%79 = load double, double* %8
%80 = load double, double* %8
%81 = fmul double %79, %80
%82 = load double, double* %11
%83 = fmul double %81, %82
%84 = load double, double* %12
%85 = fmul double %83, %84
%86 = load double, double* %13
%87 = fmul double %85, %86
store double %87, double* %4
br label %120
88: ; preds = %47
%89 = load double*, double** %5
%90 = getelementptr inbounds double, double* %89, i64 0
%91 = load double, double* %90
%92 = load double*, double** %6
%93 = getelementptr inbounds double, double* %92, i64 0
%94 = load double, double* %93
%95 = fsub double %91, %94
store double %95, double* %14
%96 = load double*, double** %5
%97 = getelementptr inbounds double, double* %96, i64 2
%98 = load double, double* %97
%99 = load double*, double** %6
%100 = getelementptr inbounds double, double* %99, i64 2
%101 = load double, double* %100
%102 = fadd double %98, %101
%103 = fmul double 5.000000e-01, %102
%104 = call i32 @sin(double %103)
%105 = sitofp i32 %104 to double
store double %105, double* %15
%106 = load double*, double** %5
%107 = getelementptr inbounds double, double* %106, i64 1
%108 = load double, double* %107
%109 = load double*, double** %6
%110 = getelementptr inbounds double, double* %109, i64 1
%111 = load double, double* %110
%112 = call double @get_dp(double %108, double %111)
store double %112, double* %16
%113 = load double, double* %8
%114 = load double, double* %15
%115 = fmul double %113, %114
%116 = load double, double* %14
%117 = fmul double %115, %116
%118 = load double, double* %16
%119 = fmul double %117, %118
store double %119, double* %4
br label %120
120: ; preds = %88, %50, %27
%121 = load double, double* %4
ret double %121
}

LLVM IR (-O2):
define double @get_dA(double* nocapture %0, double* nocapture %1, i32 %2) {
%4 = load double, double* %0
%5 = load double, double* %1
%6 = fadd double %4, %5
%7 = fmul double %6, 5.000000e-01
switch i32 %2, label %42 [
i32 0, label %8
i32 1, label %17
]
8: ; preds = %3
%9 = fsub double %4, %5
%10 = getelementptr inbounds double, double* %0, i64 2
%11 = load double, double* %10
%12 = getelementptr inbounds double, double* %1, i64 2
%13 = load double, double* %12
%14 = fsub double %11, %13
%15 = fmul double %9, %7
%16 = fmul double %15, %14
br label %60
17: ; preds = %3
%18 = getelementptr inbounds double, double* %0, i64 2
%19 = load double, double* %18
%20 = getelementptr inbounds double, double* %1, i64 2
%21 = load double, double* %20
%22 = fadd double %19, %21
%23 = fmul double %22, 5.000000e-01
%24 = tail call i32 @sin(double %23)
%25 = sitofp i32 %24 to double
%26 = load double, double* %18
%27 = load double, double* %20
%28 = fsub double %26, %27
%29 = fmul double %28, 5.000000e-01
%30 = tail call i32 @sin(double %29)
%31 = shl nsw i32 %30, 1
%32 = sitofp i32 %31 to double
%33 = getelementptr inbounds double, double* %0, i64 1
%34 = load double, double* %33
%35 = getelementptr inbounds double, double* %1, i64 1
%36 = load double, double* %35
%37 = tail call double @get_dp(double %34, double %36)
%38 = fmul double %7, %7
%39 = fmul double %38, %25
%40 = fmul double %39, %32
%41 = fmul double %40, %37
br label %60
42: ; preds = %3
%43 = fsub double %4, %5
%44 = getelementptr inbounds double, double* %0, i64 2
%45 = load double, double* %44
%46 = getelementptr inbounds double, double* %1, i64 2
%47 = load double, double* %46
%48 = fadd double %45, %47
%49 = fmul double %48, 5.000000e-01
%50 = tail call i32 @sin(double %49)
%51 = sitofp i32 %50 to double
%52 = getelementptr inbounds double, double* %0, i64 1
%53 = load double, double* %52
%54 = getelementptr inbounds double, double* %1, i64 1
%55 = load double, double* %54
%56 = tail call double @get_dp(double %53, double %55)
%57 = fmul double %7, %51
%58 = fmul double %43, %57
%59 = fmul double %58, %56
br label %60
60: ; preds = %42, %17, %8
%61 = phi double [ %16, %8 ], [ %41, %17 ], [ %59, %42 ]
ret double %61
}