#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 asum(double *, int);
double asum2(double *, int);
double sqrt(double);
int /*<<< orphan*/ vsp(double *, double *, double, int);
int /*<<< orphan*/ vst(double *, double *, double, int);
void bal(double *a, double *b, int n) {
  double t;
  t = asum(b, n) / (double)n;
  vsp(a, b, -t, n);
  t = asum2(a, n) / (double)n;
  vst(a, a, 1.0 / sqrt(t), n);
}


x86 assembly (clang, -O0):
<bal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <asum@plt>
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x14(%rbp),%edx
call   1040 <vsp@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <asum2@plt>
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1060 <sqrt@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movaps %xmm0,%xmm1
movsd  0xe10(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    -0x14(%rbp),%edx
call   1030 <vst@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bal>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
mov    %edx,%esi
call   1050 <asum@plt>
cvtsi2sd %ebx,%xmm1
movsd  %xmm1,0x8(%rsp)
xorpd  0xe83(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1040 <vsp@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1070 <asum2@plt>
divsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11ae <bal+0x5e>
sqrtsd %xmm0,%xmm0
jmp    11b3 <bal+0x63>
call   1060 <sqrt@plt>
movsd  0xe55(%rip),%xmm1
divsd  %xmm0,%xmm1
mov    %r14,%rdi
mov    %r14,%rsi
movapd %xmm1,%xmm0
mov    %ebx,%edx
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <vst@plt>

LLVM IR (-O0):
define void @bal(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 double*, double** %5
%9 = load i32, i32* %6
%10 = call double @asum(double* %8, i32 %9)
%11 = load i32, i32* %6
%12 = sitofp i32 %11 to double
%13 = fdiv double %10, %12
store double %13, double* %7
%14 = load double*, double** %4
%15 = load double*, double** %5
%16 = load double, double* %7
%17 = fneg double %16
%18 = load i32, i32* %6
%19 = call i32 @vsp(double* %14, double* %15, double %17, i32 %18)
%20 = load double*, double** %4
%21 = load i32, i32* %6
%22 = call double @asum2(double* %20, i32 %21)
%23 = load i32, i32* %6
%24 = sitofp i32 %23 to double
%25 = fdiv double %22, %24
store double %25, double* %7
%26 = load double*, double** %4
%27 = load double*, double** %4
%28 = load double, double* %7
%29 = call double @sqrt(double %28)
%30 = fdiv double 1.000000e+00, %29
%31 = load i32, i32* %6
%32 = call i32 @vst(double* %26, double* %27, double %30, i32 %31)
ret void
}

LLVM IR (-O2):
define void @bal(double* %0, double* %1, i32 %2) {
%4 = tail call double @asum(double* %1, i32 %2)
%5 = sitofp i32 %2 to double
%6 = fneg double %4
%7 = fdiv double %6, %5
%8 = tail call i32 @vsp(double* %0, double* %1, double %7, i32 %2)
%9 = tail call double @asum2(double* %0, i32 %2)
%10 = fdiv double %9, %5
%11 = tail call double @sqrt(double %10)
%12 = fdiv double 1.000000e+00, %11
%13 = tail call i32 @vst(double* %0, double* %0, double %12, i32 %2)
ret void
}