#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 /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ twobody_XG(int, double, double *);
void twobody_XG_far(int n, double l, double s, double *XG11, double *XG12) {
  if (n % 2 != 0)
    n--;
  double *f = (double *)malloc(sizeof(double) * (n + 1));
  if (f == NULL) {
    fprintf(stderr, "twobody_XG_far"
                    " : malloc error for "
                    "f"
                    "\n");
    exit(1);
  };
  twobody_XG(n, l, f);
  *XG11 = 0.0;
  *XG12 = 0.0;
  double s1l = s * (1.0 + l);
  double s11, s12;
  s11 = s1l;
  s12 = 1.0;
  double s2 = s1l * s1l;
  int i;
  for (i = 0; i < n / 2; i++) {
    *XG11 += f[i * 2 + 1] / s11;
    *XG12 += f[i * 2] / s12;
    s11 *= s2;
    s12 *= s2;
  }
  *XG12 *= -4.0 / (1.0 + l) / (1.0 + l);
  free(f);
}


x86 assembly (clang, -O0):
<twobody_XG_far>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     118a <twobody_XG_far+0x3a>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11cb <twobody_XG_far+0x7b>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x4(%rbp),%edi
movsd  -0x10(%rbp),%xmm0
mov    -0x30(%rbp),%rsi
call   1040 <twobody_XG@plt>
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
movsd  0xe01(%rip),%xmm1
addsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xde1(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x58(%rbp),%eax
cmp    %ecx,%eax
jge    12cd <twobody_XG_far+0x17d>
mov    -0x30(%rbp),%rax
mov    -0x54(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x40(%rbp),%xmm0
mov    -0x20(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
mov    -0x54(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x48(%rbp),%xmm0
mov    -0x28(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    123a <twobody_XG_far+0xea>
movsd  0xd2b(%rip),%xmm1
addsd  -0x10(%rbp),%xmm1
movsd  0xd26(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  0xd12(%rip),%xmm1
addsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<twobody_XG_far>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r12
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
mov    %edi,%ebx
lea    0x0(,%rbx,8),%edi
or     $0x8,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     1256 <twobody_XG_far+0x106>
mov    %rax,%r15
mov    %ebx,%ebp
and    $0xfffffffe,%ebp
mov    %ebp,%edi
movsd  (%rsp),%xmm0
mov    %rax,%rsi
call   1040 <twobody_XG@plt>
movq   $0x0,(%r12)
movq   $0x0,(%r14)
movsd  (%rsp),%xmm3
addsd  0xe46(%rip),%xmm3
xorpd  %xmm2,%xmm2
cmp    $0x2,%ebp
movsd  0x8(%rsp),%xmm4
jl     1229 <twobody_XG_far+0xd9>
mulsd  %xmm3,%xmm4
movapd %xmm4,%xmm0
mulsd  %xmm4,%xmm0
shr    %ebx
mov    %r15,%rax
add    $0x8,%rax
movsd  0xe1a(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
movsd  (%rax),%xmm2
divsd  %xmm4,%xmm2
addsd  (%r12),%xmm2
movsd  %xmm2,(%r12)
movsd  -0x8(%rax),%xmm2
divsd  %xmm1,%xmm2
addsd  (%r14),%xmm2
movsd  %xmm2,(%r14)
mulsd  %xmm0,%xmm4
mulsd  %xmm0,%xmm1
add    $0x10,%rax
add    $0xffffffffffffffff,%rbx
jne    11f0 <twobody_XG_far+0xa0>
movsd  0xdd7(%rip),%xmm0
divsd  %xmm3,%xmm0
divsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,(%r14)
mov    %r15,%rdi
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
lea    0xdaa(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [37 x i8] c"twobody_XG_far : malloc error for f\0A\00"
define void @twobody_XG_far(i32 %0, double %1, double %2, double* %3, double* %4) {
%6 = alloca i32
%7 = alloca double
%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 i32
store i32 %0, i32* %6
store double %1, double* %7
store double %2, double* %8
store double* %3, double** %9
store double* %4, double** %10
%17 = load i32, i32* %6
%18 = srem i32 %17, 2
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %5
%21 = load i32, i32* %6
%22 = add nsw i32 %21, -1
store i32 %22, i32* %6
br label %23
23: ; preds = %20, %5
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = mul i64 8, %26
%28 = trunc i64 %27 to i32
%29 = call i64 @malloc(i32 %28)
%30 = inttoptr i64 %29 to double*
store double* %30, double** %11
%31 = load double*, double** %11
%32 = icmp eq double* %31, null
br i1 %32, label %33, label %37
33: ; preds = %23
%34 = load i32, i32* @stderr
%35 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %23
%38 = load i32, i32* %6
%39 = load double, double* %7
%40 = load double*, double** %11
%41 = call i32 @twobody_XG(i32 %38, double %39, double* %40)
%42 = load double*, double** %9
store double 0.000000e+00, double* %42
%43 = load double*, double** %10
store double 0.000000e+00, double* %43
%44 = load double, double* %8
%45 = load double, double* %7
%46 = fadd double 1.000000e+00, %45
%47 = fmul double %44, %46
store double %47, double* %12
%48 = load double, double* %12
store double %48, double* %13
store double 1.000000e+00, double* %14
%49 = load double, double* %12
%50 = load double, double* %12
%51 = fmul double %49, %50
store double %51, double* %15
store i32 0, i32* %16
br label %52
52: ; preds = %87, %37
%53 = load i32, i32* %16
%54 = load i32, i32* %6
%55 = sdiv i32 %54, 2
%56 = icmp slt i32 %53, %55
br i1 %56, label %57, label %90
57: ; preds = %52
%58 = load double*, double** %11
%59 = load i32, i32* %16
%60 = mul nsw i32 %59, 2
%61 = add nsw i32 %60, 1
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %58, i64 %62
%64 = load double, double* %63
%65 = load double, double* %13
%66 = fdiv double %64, %65
%67 = load double*, double** %9
%68 = load double, double* %67
%69 = fadd double %68, %66
store double %69, double* %67
%70 = load double*, double** %11
%71 = load i32, i32* %16
%72 = mul nsw i32 %71, 2
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds double, double* %70, i64 %73
%75 = load double, double* %74
%76 = load double, double* %14
%77 = fdiv double %75, %76
%78 = load double*, double** %10
%79 = load double, double* %78
%80 = fadd double %79, %77
store double %80, double* %78
%81 = load double, double* %15
%82 = load double, double* %13
%83 = fmul double %82, %81
store double %83, double* %13
%84 = load double, double* %15
%85 = load double, double* %14
%86 = fmul double %85, %84
store double %86, double* %14
br label %87
87: ; preds = %57
%88 = load i32, i32* %16
%89 = add nsw i32 %88, 1
store i32 %89, i32* %16
br label %52
90: ; preds = %52
%91 = load double, double* %7
%92 = fadd double 1.000000e+00, %91
%93 = fdiv double -4.000000e+00, %92
%94 = load double, double* %7
%95 = fadd double 1.000000e+00, %94
%96 = fdiv double %93, %95
%97 = load double*, double** %10
%98 = load double, double* %97
%99 = fmul double %98, %96
store double %99, double* %97
%100 = load double*, double** %11
%101 = call i32 @free(double* %100)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [37 x i8] c"twobody_XG_far : malloc error for f\0A\00"
define void @twobody_XG_far(i32 %0, double %1, double %2, double* nocapture %3, double* nocapture %4) {
%6 = and i32 %0, -2
%7 = shl i32 %0, 3
%8 = or i32 %7, 8
%9 = tail call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to double*
%11 = icmp eq i64 %9, 0
br i1 %11, label %12, label %16
12: ; preds = %5
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %5
%17 = tail call i32 @twobody_XG(i32 %6, double %1, double* %10)
store double 0.000000e+00, double* %3
store double 0.000000e+00, double* %4
%18 = fadd double %1, 1.000000e+00
%19 = fmul double %18, %2
%20 = fmul double %19, %19
%21 = icmp sgt i32 %6, 1
br i1 %21, label %22, label %45
22: ; preds = %16
%23 = lshr i32 %0, 1
%24 = zext i32 %23 to i64
br label %25
25: ; preds = %22, %25
%26 = phi i64 [ 0, %22 ], [ %43, %25 ]
%27 = phi double [ 1.000000e+00, %22 ], [ %42, %25 ]
%28 = phi double [ %19, %22 ], [ %41, %25 ]
%29 = shl nuw nsw i64 %26, 1
%30 = or i64 %29, 1
%31 = getelementptr inbounds double, double* %10, i64 %30
%32 = load double, double* %31
%33 = fdiv double %32, %28
%34 = load double, double* %3
%35 = fadd double %34, %33
store double %35, double* %3
%36 = getelementptr inbounds double, double* %10, i64 %29
%37 = load double, double* %36
%38 = fdiv double %37, %27
%39 = load double, double* %4
%40 = fadd double %39, %38
store double %40, double* %4
%41 = fmul double %20, %28
%42 = fmul double %20, %27
%43 = add nuw nsw i64 %26, 1
%44 = icmp eq i64 %43, %24
br i1 %44, label %45, label %25
45: ; preds = %25, %16
%46 = phi double [ 0.000000e+00, %16 ], [ %40, %25 ]
%47 = fdiv double -4.000000e+00, %18
%48 = fdiv double %47, %18
%49 = fmul double %48, %46
store double %49, double* %4
%50 = tail call i32 @free(double* %10)
ret void
}