#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 bols(int, int /*<<< orphan*/, double *, double *, double *);
int /*<<< orphan*/ free(double *);
double *malloc(int);
int fcoef(int k, int l, double *cf, double *B) {
  double *b = malloc(sizeof(double) * (k + 1) * (k + 1));
  int p;
  do {
    p = bols(k, l++, cf, b, B);
  } while (p);
  free(b);
  return l - 1;
}


x86 assembly (clang, -O0):
<fcoef>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%r8
call   1040 <bols@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    116a <fcoef+0x3a>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fcoef>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%ebx
mov    %edi,%r12d
lea    0x1(%r12),%edi
imul   %edi,%edi
shl    $0x3,%edi
call   1050 <malloc@plt>
mov    %rax,%r13
nopw   0x0(%rax,%rax,1)
mov    %ebx,%esi
lea    0x1(%rsi),%ebx
mov    %r12d,%edi
mov    %r15,%rdx
mov    %r13,%rcx
mov    %r14,%r8
call   1040 <bols@plt>
test   %eax,%eax
jne    1160 <fcoef+0x30>
mov    %r13,%rdi
call   1030 <free@plt>
add    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @fcoef(i32 %0, i32 %1, double* %2, double* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store double* %2, double** %7
store double* %3, double** %8
%11 = load i32, i32* %5
%12 = add nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = mul i64 8, %13
%15 = load i32, i32* %5
%16 = add nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = mul i64 %14, %17
%19 = trunc i64 %18 to i32
%20 = call double* @malloc(i32 %19)
store double* %20, double** %9
br label %21
21: ; preds = %29, %4
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
%25 = load double*, double** %7
%26 = load double*, double** %9
%27 = load double*, double** %8
%28 = call i32 @bols(i32 %22, i32 %23, double* %25, double* %26, double* %27)
store i32 %28, i32* %10
br label %29
29: ; preds = %21
%30 = load i32, i32* %10
%31 = icmp ne i32 %30, 0
br i1 %31, label %21, label %32
32: ; preds = %29
%33 = load double*, double** %9
%34 = call i32 @free(double* %33)
%35 = load i32, i32* %6
%36 = sub nsw i32 %35, 1
ret i32 %36
}

LLVM IR (-O2):
define i32 @fcoef(i32 %0, i32 %1, double* %2, double* %3) {
%5 = add nsw i32 %0, 1
%6 = shl i32 %5, 3
%7 = mul i32 %6, %5
%8 = tail call double* @malloc(i32 %7)
br label %9
9: ; preds = %9, %4
%10 = phi i32 [ %1, %4 ], [ %11, %9 ]
%11 = add nsw i32 %10, 1
%12 = tail call i32 @bols(i32 %0, i32 %10, double* %2, double* %8, double* %3)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %9
14: ; preds = %9
%15 = tail call i32 @free(double* %8)
ret i32 %10
}