#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 fabs(double);
int bwd_subs_d3(int n, double *a, double *b, double *y, double tol) {
  int k;
  y[n - 1] = y[n - 1] / b[n - 1];
  for (k = n - 2; k >= 0; k--) {
    if (fabs(b[k]) < tol)
      return 1;
    y[k] = (y[k] - a[k] * y[k - 1]) / b[k];
  }
  return 0;
}


x86 assembly (clang, -O0):
<bwd_subs_d3>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
divsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jl     1207 <bwd_subs_d3+0x107>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movaps 0xe8b(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1194 <bwd_subs_d3+0x94>
movl   $0x1,-0x4(%rbp)
jmp    120e <bwd_subs_d3+0x10e>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
jmp    1157 <bwd_subs_d3+0x57>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<bwd_subs_d3>:
movslq %edi,%r8
movsd  -0x8(%rcx,%r8,8),%xmm1
divsd  -0x8(%rdx,%r8,8),%xmm1
movsd  %xmm1,-0x8(%rcx,%r8,8)
xor    %eax,%eax
cmp    $0x2,%r8d
jl     116a <bwd_subs_d3+0x6a>
add    $0xfffffffe,%edi
add    $0x1,%rdi
movapd 0xed1(%rip),%xmm1
nop
movsd  -0x8(%rdx,%rdi,8),%xmm2
movapd %xmm2,%xmm3
andpd  %xmm1,%xmm3
ucomisd %xmm3,%xmm0
ja     116b <bwd_subs_d3+0x6b>
movsd  -0x8(%rcx,%rdi,8),%xmm3
movsd  -0x8(%rsi,%rdi,8),%xmm4
mulsd  -0x10(%rcx,%rdi,8),%xmm4
subsd  %xmm4,%xmm3
divsd  %xmm2,%xmm3
movsd  %xmm3,-0x8(%rcx,%rdi,8)
add    $0xffffffffffffffff,%rdi
jg     1130 <bwd_subs_d3+0x30>
ret
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @bwd_subs_d3(i32 %0, double* %1, double* %2, double* %3, double %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca double
%12 = alloca i32
store i32 %0, i32* %7
store double* %1, double** %8
store double* %2, double** %9
store double* %3, double** %10
store double %4, double* %11
%13 = load double*, double** %10
%14 = load i32, i32* %7
%15 = sub nsw i32 %14, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %13, i64 %16
%18 = load double, double* %17
%19 = load double*, double** %9
%20 = load i32, i32* %7
%21 = sub nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %19, i64 %22
%24 = load double, double* %23
%25 = fdiv double %18, %24
%26 = load double*, double** %10
%27 = load i32, i32* %7
%28 = sub nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %26, i64 %29
store double %25, double* %30
%31 = load i32, i32* %7
%32 = sub nsw i32 %31, 2
store i32 %32, i32* %12
br label %33
33: ; preds = %75, %5
%34 = load i32, i32* %12
%35 = icmp sge i32 %34, 0
br i1 %35, label %36, label %78
36: ; preds = %33
%37 = load double*, double** %9
%38 = load i32, i32* %12
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
%41 = load double, double* %40
%42 = call double @llvm.fabs.f64(double %41)
%43 = load double, double* %11
%44 = fcmp olt double %42, %43
br i1 %44, label %45, label %46
45: ; preds = %36
store i32 1, i32* %6
br label %79
46: ; preds = %36
%47 = load double*, double** %10
%48 = load i32, i32* %12
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %47, i64 %49
%51 = load double, double* %50
%52 = load double*, double** %8
%53 = load i32, i32* %12
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %52, i64 %54
%56 = load double, double* %55
%57 = load double*, double** %10
%58 = load i32, i32* %12
%59 = sub nsw i32 %58, 1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %57, i64 %60
%62 = load double, double* %61
%63 = fneg double %56
%64 = call double @llvm.fmuladd.f64(double %63, double %62, double %51)
%65 = load double*, double** %9
%66 = load i32, i32* %12
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double, double* %65, i64 %67
%69 = load double, double* %68
%70 = fdiv double %64, %69
%71 = load double*, double** %10
%72 = load i32, i32* %12
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds double, double* %71, i64 %73
store double %70, double* %74
br label %75
75: ; preds = %46
%76 = load i32, i32* %12
%77 = add nsw i32 %76, -1
store i32 %77, i32* %12
br label %33
78: ; preds = %33
store i32 0, i32* %6
br label %79
79: ; preds = %78, %45
%80 = load i32, i32* %6
ret i32 %80
}

LLVM IR (-O2):
define i32 @bwd_subs_d3(i32 %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, double %4) {
%6 = add nsw i32 %0, -1
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds double, double* %3, i64 %7
%9 = load double, double* %8
%10 = getelementptr inbounds double, double* %2, i64 %7
%11 = load double, double* %10
%12 = fdiv double %9, %11
store double %12, double* %8
%13 = icmp sgt i32 %0, 1
br i1 %13, label %14, label %35
14: ; preds = %5
%15 = add nsw i32 %0, -2
%16 = zext i32 %15 to i64
br label %17
17: ; preds = %14, %23
%18 = phi i64 [ %16, %14 ], [ %28, %23 ]
%19 = getelementptr inbounds double, double* %2, i64 %18
%20 = load double, double* %19
%21 = tail call double @llvm.fabs.f64(double %20)
%22 = fcmp olt double %21, %4
br i1 %22, label %35, label %23
23: ; preds = %17
%24 = getelementptr inbounds double, double* %3, i64 %18
%25 = load double, double* %24
%26 = getelementptr inbounds double, double* %1, i64 %18
%27 = load double, double* %26
%28 = add nsw i64 %18, -1
%29 = getelementptr inbounds double, double* %3, i64 %28
%30 = load double, double* %29
%31 = fneg double %27
%32 = tail call double @llvm.fmuladd.f64(double %31, double %30, double %25)
%33 = fdiv double %32, %20
store double %33, double* %24
%34 = icmp sgt i64 %18, 0
br i1 %34, label %17, label %35
35: ; preds = %17, %23, %5
%36 = phi i32 [ 0, %5 ], [ 0, %23 ], [ 1, %17 ]
ret i32 %36
}