#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 sin(double);
double geom_dA_sph_tpr(double xm[], double xp[], int dir) {
  double dA;
  if (dir == 0)
    dA = sin(xm[0]) * (xp[1] - xm[1]);
  else if (dir == 1)
    dA = xp[0] - xm[0];
  else
    dA = 0.0;
  return dA;
}


x86 assembly (clang, -O0):
<geom_dA_sph_tpr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    115a <geom_dA_sph_tpr+0x4a>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <sin@plt>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x8(%rbp),%rax
subsd  0x8(%rax),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    118b <geom_dA_sph_tpr+0x7b>
cmpl   $0x1,-0x14(%rbp)
jne    117e <geom_dA_sph_tpr+0x6e>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1186 <geom_dA_sph_tpr+0x76>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    118b <geom_dA_sph_tpr+0x7b>
movsd  -0x20(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geom_dA_sph_tpr>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
cmp    $0x1,%edx
je     1145 <geom_dA_sph_tpr+0x35>
xorpd  %xmm0,%xmm0
test   %edx,%edx
jne    114e <geom_dA_sph_tpr+0x3e>
movsd  (%rbx),%xmm0
call   1030 <sin@plt>
movapd %xmm0,%xmm1
movsd  0x8(%r14),%xmm0
subsd  0x8(%rbx),%xmm0
mulsd  %xmm1,%xmm0
jmp    114e <geom_dA_sph_tpr+0x3e>
movsd  (%r14),%xmm0
subsd  (%rbx),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @geom_dA_sph_tpr(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 %23
10: ; preds = %3
%11 = load double*, double** %4
%12 = getelementptr inbounds double, double* %11, i64 0
%13 = load double, double* %12
%14 = call double @sin(double %13)
%15 = load double*, double** %5
%16 = getelementptr inbounds double, double* %15, i64 1
%17 = load double, double* %16
%18 = load double*, double** %4
%19 = getelementptr inbounds double, double* %18, i64 1
%20 = load double, double* %19
%21 = fsub double %17, %20
%22 = fmul double %14, %21
store double %22, double* %7
br label %36
23: ; preds = %3
%24 = load i32, i32* %6
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %34
26: ; preds = %23
%27 = load double*, double** %5
%28 = getelementptr inbounds double, double* %27, i64 0
%29 = load double, double* %28
%30 = load double*, double** %4
%31 = getelementptr inbounds double, double* %30, i64 0
%32 = load double, double* %31
%33 = fsub double %29, %32
store double %33, double* %7
br label %35
34: ; preds = %23
store double 0.000000e+00, double* %7
br label %35
35: ; preds = %34, %26
br label %36
36: ; preds = %35, %10
%37 = load double, double* %7
ret double %37
}

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