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


x86 assembly (clang, -O0):
<palu_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)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11f9 <palu_d3+0xf9>
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
movaps 0xeb7(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1168 <palu_d3+0x68>
movl   $0x1,-0x4(%rbp)
jmp    1200 <palu_d3+0x100>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
divsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
movq   %xmm0,%rdx
movabs $0x8000000000000000,%rsi
xor    %rsi,%rdx
movq   %rdx,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    111f <palu_d3+0x1f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<palu_d3>:
xor    %eax,%eax
cmp    $0x2,%edi
jl     1166 <palu_d3+0x66>
add    $0xffffffff,%edi
xor    %eax,%eax
movapd 0xeec(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  0x8(%rcx,%rax,8),%xmm2
movapd %xmm2,%xmm3
andpd  %xmm1,%xmm3
ucomisd %xmm3,%xmm0
ja     1167 <palu_d3+0x67>
movsd  (%rdx,%rax,8),%xmm3
divsd  %xmm2,%xmm3
movsd  %xmm3,0x8(%rcx,%rax,8)
movsd  0x8(%rdx,%rax,8),%xmm2
mulsd  (%rsi,%rax,8),%xmm3
subsd  %xmm3,%xmm2
movsd  %xmm2,0x8(%rdx,%rax,8)
lea    0x1(%rax),%r8
mov    %r8,%rax
cmp    %r8,%rdi
jne    1120 <palu_d3+0x20>
xor    %eax,%eax
ret
mov    $0x1,%eax
ret

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

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