#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_J2_sph_rtp(double x[], int dir) {
  double r = x[0];
  double st = sin(x[1]);
  if (dir == 0)
    return r * r * st;
  else if (dir == 1)
    return r * st;
  return 0.0;
}


x86 assembly (clang, -O0):
<geom_J2_sph_rtp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x28(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1162 <geom_J2_sph_rtp+0x52>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    118d <geom_J2_sph_rtp+0x7d>
cmpl   $0x1,-0x14(%rbp)
jne    1180 <geom_J2_sph_rtp+0x70>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    118d <geom_J2_sph_rtp+0x7d>
jmp    1185 <geom_J2_sph_rtp+0x75>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geom_J2_sph_rtp>:
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
movsd  (%rdi),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rdi),%xmm0
call   1030 <sin@plt>
cmp    $0x1,%ebx
je     1148 <geom_J2_sph_rtp+0x38>
movsd  0x8(%rsp),%xmm2
xorpd  %xmm1,%xmm1
test   %ebx,%ebx
jne    1152 <geom_J2_sph_rtp+0x42>
movapd %xmm2,%xmm1
mulsd  %xmm2,%xmm1
jmp    114e <geom_J2_sph_rtp+0x3e>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @geom_J2_sph_rtp(double* %0, i32 %1) {
%3 = alloca double
%4 = alloca double*
%5 = alloca i32
%6 = alloca double
%7 = alloca double
store double* %0, double** %4
store i32 %1, i32* %5
%8 = load double*, double** %4
%9 = getelementptr inbounds double, double* %8, i64 0
%10 = load double, double* %9
store double %10, double* %6
%11 = load double*, double** %4
%12 = getelementptr inbounds double, double* %11, i64 1
%13 = load double, double* %12
%14 = call double @sin(double %13)
store double %14, double* %7
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %2
%18 = load double, double* %6
%19 = load double, double* %6
%20 = fmul double %18, %19
%21 = load double, double* %7
%22 = fmul double %20, %21
store double %22, double* %3
br label %32
23: ; preds = %2
%24 = load i32, i32* %5
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load double, double* %6
%28 = load double, double* %7
%29 = fmul double %27, %28
store double %29, double* %3
br label %32
30: ; preds = %23
br label %31
31: ; preds = %30
store double 0.000000e+00, double* %3
br label %32
32: ; preds = %31, %26, %17
%33 = load double, double* %3
ret double %33
}

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