#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 */
typedef int /*<<< orphan*/ g;
typedef int /*<<< orphan*/ c;

/* Variables and functions */
double *alloca(unsigned int);
int /*<<< orphan*/ drcholapply(double *, double const *, double *,
                               unsigned int);
scalar_t__ drcholfactor(double const *, double *, unsigned int);
int /*<<< orphan*/ memset(double *, int /*<<< orphan*/, unsigned int);
int drchol(const double *a, const double *b, double *c, unsigned int d) {
  double *g;
  g = alloca(d * d * sizeof(g[0]));
  if (drcholfactor(a, g, d)) {
    memset(c, 0, d * sizeof(c[0]));
    return -1;
  }
  drcholapply(g, b, c, d);
  return 0;
}


x86 assembly (clang, -O0):
<drchol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x24(%rbp),%eax
imul   -0x24(%rbp),%eax
mov    %eax,%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <alloca@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <drcholfactor@plt>
cmp    $0x0,%rax
je     11a9 <drchol+0x69>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%eax
shl    $0x3,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1040 <memset@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c4 <drchol+0x84>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1060 <drcholapply@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drchol>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
lea    0x0(,%rbx,8),%r12d
mov    %r12d,%edi
imul   %ecx,%edi
call   1050 <alloca@plt>
mov    %rax,%rbp
mov    %r13,%rdi
mov    %rax,%rsi
mov    %ebx,%edx
call   1030 <drcholfactor@plt>
test   %rax,%rax
je     1192 <drchol+0x52>
mov    %r14,%rdi
xor    %esi,%esi
mov    %r12d,%edx
call   1040 <memset@plt>
mov    $0xffffffff,%eax
jmp    11a4 <drchol+0x64>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %ebx,%ecx
call   1060 <drcholapply@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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