#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 */
float *alloca(unsigned int);
int /*<<< orphan*/ frcholapply(float *, float const *, float *, unsigned int);
scalar_t__ frcholfactor(float const *, float *, unsigned int);
int /*<<< orphan*/ memset(float *, int /*<<< orphan*/, unsigned int);
int frchol(const float *a, const float *b, float *c, unsigned int d) {
  float *g;
  g = alloca(d * d * sizeof(g[0]));
  if (frcholfactor(a, g, d)) {
    memset(c, 0, d * sizeof(c[0]));
    return -1;
  }
  frcholapply(g, b, c, d);
  return 0;
}


x86 assembly (clang, -O0):
<frchol>:
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    $0x2,%rax
mov    %eax,%edi
call   1060 <alloca@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1040 <frcholfactor@plt>
cmp    $0x0,%rax
je     11a9 <frchol+0x69>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%eax
shl    $0x2,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1050 <memset@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c4 <frchol+0x84>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1030 <frcholapply@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<frchol>:
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,4),%r12d
mov    %r12d,%edi
imul   %ecx,%edi
call   1060 <alloca@plt>
mov    %rax,%rbp
mov    %r13,%rdi
mov    %rax,%rsi
mov    %ebx,%edx
call   1040 <frcholfactor@plt>
test   %rax,%rax
je     1192 <frchol+0x52>
mov    %r14,%rdi
xor    %esi,%esi
mov    %r12d,%edx
call   1050 <memset@plt>
mov    $0xffffffff,%eax
jmp    11a4 <frchol+0x64>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %ebx,%ecx
call   1030 <frcholapply@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 @frchol(float* %0, float* %1, float* %2, i32 %3) {
%5 = alloca i32
%6 = alloca float*
%7 = alloca float*
%8 = alloca float*
%9 = alloca i32
%10 = alloca float*
store float* %0, float** %6
store float* %1, float** %7
store float* %2, float** %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, 4
%16 = trunc i64 %15 to i32
%17 = call float* @alloca(i32 %16)
store float* %17, float** %10
%18 = load float*, float** %6
%19 = load float*, float** %10
%20 = load i32, i32* %9
%21 = call i64 @frcholfactor(float* %18, float* %19, i32 %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %30
23: ; preds = %4
%24 = load float*, float** %8
%25 = load i32, i32* %9
%26 = zext i32 %25 to i64
%27 = mul i64 %26, 4
%28 = trunc i64 %27 to i32
%29 = call i32 @memset(float* %24, i32 0, i32 %28)
store i32 -1, i32* %5
br label %36
30: ; preds = %4
%31 = load float*, float** %10
%32 = load float*, float** %7
%33 = load float*, float** %8
%34 = load i32, i32* %9
%35 = call i32 @frcholapply(float* %31, float* %32, float* %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 @frchol(float* %0, float* %1, float* %2, i32 %3) {
%5 = shl i32 %3, 2
%6 = mul i32 %5, %3
%7 = tail call float* @alloca(i32 %6)
%8 = tail call i64 @frcholfactor(float* %0, float* %7, i32 %3)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %4
%11 = tail call i32 @memset(float* %2, i32 0, i32 %5)
br label %14
12: ; preds = %4
%13 = tail call i32 @frcholapply(float* %7, float* %1, float* %2, i32 %3)
br label %14
14: ; preds = %12, %10
%15 = phi i32 [ -1, %10 ], [ 0, %12 ]
ret i32 %15
}