#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*/ crstrns(double *, double *);
int inverse(double *, double *, double const);
int /*<<< orphan*/ mv_mul(double *, double *, double *);
int cal_g(double *g, double *vx, double *b, double *ep, const int i,
          const int n, const double eps) {
  double t[2], s[4], u[4];
  t[0] = b[i] - ep[0];
  t[1] = b[n - 1 - i] - ep[1];
  crstrns(s, vx);
  if (inverse(u, s, eps) == -1)
    return (-1);
  mv_mul(g, u, t);
  return (0);
}


x86 assembly (clang, -O0):
<cal_g>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9d,-0x30(%rbp)
movsd  %xmm0,-0x38(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%ecx
sub    $0x1,%ecx
sub    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <crstrns@plt>
lea    -0x90(%rbp),%rdi
lea    -0x70(%rbp),%rsi
movsd  -0x38(%rbp),%xmm0
call   1050 <inverse@plt>
cmp    $0xffffffff,%eax
jne    11cc <cal_g+0x9c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e7 <cal_g+0xb7>
mov    -0x10(%rbp),%rdi
lea    -0x90(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1040 <mv_mul@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cal_g>:
push   %r14
push   %rbx
sub    $0x68,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %rdi,%r14
movslq %r8d,%rax
movsd  (%rdx,%rax,8),%xmm0
not    %eax
add    %r9d,%eax
cltq
movupd (%rcx),%xmm1
movhpd (%rdx,%rax,8),%xmm0
subpd  %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <crstrns@plt>
lea    0x20(%rsp),%rdi
mov    %rbx,%rsi
movsd  0x8(%rsp),%xmm0
call   1050 <inverse@plt>
cmp    $0xffffffff,%eax
je     119d <cal_g+0x6d>
lea    0x20(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %r14,%rdi
call   1040 <mv_mul@plt>
xor    %eax,%eax
jmp    11a2 <cal_g+0x72>
mov    $0xffffffff,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @cal_g(double* %0, double* %1, double* %2, double* %3, i32 %4, i32 %5, double %6) {
%8 = alloca i32
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca i32
%14 = alloca i32
%15 = alloca double
%16 = alloca [2 x double]
%17 = alloca [4 x double]
%18 = alloca [4 x double]
store double* %0, double** %9
store double* %1, double** %10
store double* %2, double** %11
store double* %3, double** %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store double %6, double* %15
%19 = load double*, double** %11
%20 = load i32, i32* %13
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
%23 = load double, double* %22
%24 = load double*, double** %12
%25 = getelementptr inbounds double, double* %24, i64 0
%26 = load double, double* %25
%27 = fsub double %23, %26
%28 = getelementptr inbounds [2 x double], [2 x double]* %16, i64 0, i64 0
store double %27, double* %28
%29 = load double*, double** %11
%30 = load i32, i32* %14
%31 = sub nsw i32 %30, 1
%32 = load i32, i32* %13
%33 = sub nsw i32 %31, %32
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %29, i64 %34
%36 = load double, double* %35
%37 = load double*, double** %12
%38 = getelementptr inbounds double, double* %37, i64 1
%39 = load double, double* %38
%40 = fsub double %36, %39
%41 = getelementptr inbounds [2 x double], [2 x double]* %16, i64 0, i64 1
store double %40, double* %41
%42 = getelementptr inbounds [4 x double], [4 x double]* %17, i64 0, i64 0
%43 = load double*, double** %10
%44 = call i32 @crstrns(double* %42, double* %43)
%45 = getelementptr inbounds [4 x double], [4 x double]* %18, i64 0, i64 0
%46 = getelementptr inbounds [4 x double], [4 x double]* %17, i64 0, i64 0
%47 = load double, double* %15
%48 = call i32 @inverse(double* %45, double* %46, double %47)
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %51
50: ; preds = %7
store i32 -1, i32* %8
br label %56
51: ; preds = %7
%52 = load double*, double** %9
%53 = getelementptr inbounds [4 x double], [4 x double]* %18, i64 0, i64 0
%54 = getelementptr inbounds [2 x double], [2 x double]* %16, i64 0, i64 0
%55 = call i32 @mv_mul(double* %52, double* %53, double* %54)
store i32 0, i32* %8
br label %56
56: ; preds = %51, %50
%57 = load i32, i32* %8
ret i32 %57
}

LLVM IR (-O2):
define i32 @cal_g(double* %0, double* %1, double* nocapture %2, double* nocapture %3, i32 %4, i32 %5, double %6) {
%8 = alloca <2 x double>
%9 = alloca [4 x double]
%10 = alloca [4 x double]
%11 = bitcast <2 x double>* %8 to i8*
%12 = bitcast [4 x double]* %9 to i8*
%13 = bitcast [4 x double]* %10 to i8*
%14 = sext i32 %4 to i64
%15 = getelementptr inbounds double, double* %2, i64 %14
%16 = load double, double* %15
%17 = xor i32 %4, -1
%18 = add i32 %17, %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %2, i64 %19
%21 = load double, double* %20
%22 = bitcast double* %3 to <2 x double>*
%23 = load <2 x double>, <2 x double>* %22
%24 = insertelement <2 x double> poison, double %16, i64 0
%25 = insertelement <2 x double> %24, double %21, i64 1
%26 = fsub <2 x double> %25, %23
store <2 x double> %26, <2 x double>* %8
%27 = getelementptr inbounds [4 x double], [4 x double]* %9, i64 0, i64 0
%28 = call i32 @crstrns(double* %27, double* %1)
%29 = getelementptr inbounds [4 x double], [4 x double]* %10, i64 0, i64 0
%30 = call i32 @inverse(double* %29, double* %27, double %6)
%31 = icmp eq i32 %30, -1
br i1 %31, label %35, label %32
32: ; preds = %7
%33 = getelementptr inbounds <2 x double>, <2 x double>* %8, i64 0, i64 0
%34 = call i32 @mv_mul(double* %0, double* %29, double* %33)
br label %35
35: ; preds = %7, %32
%36 = phi i32 [ 0, %32 ], [ -1, %7 ]
ret i32 %36
}