#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 /*<<< orphan*/ LinearSystem(double *, int, int, int, int, double *, int,
                                int, int, int, int, int, double *, int, int,
                                int, int, int, int, int /*<<< orphan*/,
                                double *, int);
scalar_t__ calloc(int, int);
int /*<<< orphan*/ ceil(double);
int /*<<< orphan*/ dpotrf_(char *, int *, double *, int *, int *);
int /*<<< orphan*/ dpotrs_(char *, int *, int *, double *, int *, double *,
                           int *, int *);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ memcpy(double *, double *, int);
int pow(int /*<<< orphan*/, int);
void ParallelLinearSystem(double *matrix1, int r1, int c1, int ro1, int co1,
                          double *matrix2, int r2, int c2, int ro2, int co2,
                          int n, int m, double *result, int rr, int cr, int ror,
                          int cor, int nCores) {
  if (n > nCores) {
    double *memaux =
        (double *)calloc(2 * pow(ceil(0.5 * n), 2), sizeof(double));
    int blockSize = pow(ceil(0.5 * n), 2) / nCores;
    int i;
#pragma omp parallel default(shared) private(i)
    {
#pragma omp for schedule(static)
      for (i = 0; i < nCores; i++) {
        LinearSystem(matrix1, r1, c1, ro1, co1, matrix2, r2, c2, ro2, co2, n, m,
                     result, rr, cr, ror, cor, nCores, i, 0, memaux, blockSize);
      }
    }
    free(memaux);
  } else {
    int info;
    char s = 'L';
    int cols = 1;
    dpotrf_(&s, &n, matrix1, &n, &info);
    memcpy(result, matrix2, n * sizeof(double));
    dpotrs_(&s, &n, &cols, matrix1, &n, result, &n, &info);
  }
}


x86 assembly (clang, -O0):
<ParallelLinearSystem>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    0x68(%rbp),%eax
mov    0x60(%rbp),%eax
mov    0x58(%rbp),%eax
mov    0x50(%rbp),%eax
mov    0x48(%rbp),%eax
mov    0x40(%rbp),%rax
mov    0x38(%rbp),%eax
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x30(%rbp)
mov    %esi,-0x34(%rbp)
mov    %edx,-0x38(%rbp)
mov    %ecx,-0x3c(%rbp)
mov    %r8d,-0x40(%rbp)
mov    %r9,-0x48(%rbp)
mov    0x30(%rbp),%eax
cmp    0x68(%rbp),%eax
jle    133f <ParallelLinearSystem+0x1bf>
cvtsi2sdl 0x30(%rbp),%xmm1
movsd  0xe19(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1060 <ceil@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   10a0 <pow@plt>
mov    %eax,%edi
shl    $0x1,%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,-0x50(%rbp)
cvtsi2sdl 0x30(%rbp),%xmm1
movsd  0xde4(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1060 <ceil@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   10a0 <pow@plt>
cltd
idivl  0x68(%rbp)
mov    %eax,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    0x68(%rbp),%eax
jge    1331 <ParallelLinearSystem+0x1b1>
mov    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
mov    -0x3c(%rbp),%ecx
mov    -0x40(%rbp),%r8d
mov    -0x48(%rbp),%r9
mov    0x10(%rbp),%eax
mov    %eax,-0x88(%rbp)
mov    0x18(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    0x20(%rbp),%eax
mov    %eax,-0x80(%rbp)
mov    0x28(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    0x30(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    0x38(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    0x40(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    0x48(%rbp),%r13d
mov    0x50(%rbp),%r12d
mov    0x58(%rbp),%r15d
mov    0x60(%rbp),%r14d
mov    0x68(%rbp),%ebx
mov    -0x58(%rbp),%r11d
mov    -0x50(%rbp),%r10
mov    -0x54(%rbp),%eax
mov    %eax,-0x68(%rbp)
xor    %eax,%eax
mov    -0x88(%rbp),%eax
mov    %eax,(%rsp)
mov    -0x84(%rbp),%eax
mov    %eax,0x8(%rsp)
mov    -0x80(%rbp),%eax
mov    %eax,0x10(%rsp)
mov    -0x7c(%rbp),%eax
mov    %eax,0x18(%rsp)
mov    -0x78(%rbp),%eax
mov    %eax,0x20(%rsp)
mov    -0x74(%rbp),%eax
mov    %eax,0x28(%rsp)
mov    -0x70(%rbp),%rax
mov    %rax,0x30(%rsp)
mov    -0x68(%rbp),%eax
mov    %r13d,0x38(%rsp)
mov    %r12d,0x40(%rsp)
mov    %r15d,0x48(%rsp)
mov    %r14d,0x50(%rsp)
mov    %ebx,0x58(%rsp)
mov    %r11d,0x60(%rsp)
movl   $0x0,0x68(%rsp)
mov    %r10,0x70(%rsp)
mov    %eax,0x78(%rsp)
call   1050 <LinearSystem@plt>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    123f <ParallelLinearSystem+0xbf>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
jmp    13a5 <ParallelLinearSystem+0x225>
movb   $0x4c,-0x5d(%rbp)
movl   $0x1,-0x64(%rbp)
mov    -0x30(%rbp),%rdx
lea    -0x5d(%rbp),%rdi
lea    0x30(%rbp),%rcx
lea    -0x5c(%rbp),%r8
mov    %rcx,%rsi
call   1040 <dpotrf_@plt>
mov    0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
movslq 0x30(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1090 <memcpy@plt>
mov    -0x30(%rbp),%rcx
mov    0x40(%rbp),%r9
lea    -0x5d(%rbp),%rdi
lea    0x30(%rbp),%r10
lea    -0x64(%rbp),%rdx
lea    -0x5c(%rbp),%rax
mov    %r10,%rsi
mov    %r10,%r8
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1080 <dpotrs_@plt>
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<ParallelLinearSystem>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rdi,%r15
mov    0x118(%rsp),%r13d
mov    0xf0(%rsp),%r12
mov    0xe0(%rsp),%eax
cmp    %r13d,%eax
jle    1338 <ParallelLinearSystem+0x1b8>
mov    0x110(%rsp),%edi
mov    %rdi,0x78(%rsp)
mov    0x108(%rsp),%edi
mov    %rdi,0x70(%rsp)
mov    0x100(%rsp),%edi
mov    %rdi,0x68(%rsp)
mov    0xf8(%rsp),%edi
mov    %rdi,0x60(%rsp)
mov    0xe8(%rsp),%edi
mov    %rdi,0x58(%rsp)
mov    0xd8(%rsp),%edi
mov    %rdi,0x50(%rsp)
mov    0xd0(%rsp),%edi
mov    %rdi,0x48(%rsp)
mov    0xc8(%rsp),%edi
mov    %rdi,0x40(%rsp)
mov    0xc0(%rsp),%edi
mov    %rdi,0x38(%rsp)
cvtsi2sd %eax,%xmm0
mulsd  0xdd4(%rip),%xmm0
movsd  %xmm0,0x20(%rsp)
mov    %r9,0x30(%rsp)
mov    %r8d,0x18(%rsp)
mov    %ecx,0x14(%rsp)
mov    %edx,0x10(%rsp)
mov    %esi,0xc(%rsp)
mov    %rax,0x28(%rsp)
call   1060 <ceil@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   10a0 <pow@plt>
lea    (%rax,%rax,1),%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,%r14
movsd  0x20(%rsp),%xmm0
call   1060 <ceil@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   10a0 <pow@plt>
cltd
idiv   %r13d
test   %r13d,%r13d
jle    131f <ParallelLinearSystem+0x19f>
mov    %r12,%rbx
mov    %eax,%r12d
mov    %r15,%rbp
xor    %r15d,%r15d
xchg   %ax,%ax
mov    %rbp,%rdi
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0x14(%rsp),%ecx
mov    0x18(%rsp),%r8d
mov    0x30(%rsp),%r9
push   %r12
push   %r14
push   $0x0
push   %r15
push   %r13
push   0xa0(%rsp)
push   0xa0(%rsp)
push   0xa0(%rsp)
push   0xa0(%rsp)
push   %rbx
push   0xa8(%rsp)
push   0x80(%rsp)
push   0xb0(%rsp)
push   0xb0(%rsp)
push   0xb0(%rsp)
push   0xb0(%rsp)
call   1050 <LinearSystem@plt>
add    $0x80,%rsp
add    $0x1,%r15d
cmp    %r15d,%r13d
jne    12a0 <ParallelLinearSystem+0x120>
mov    %r14,%rdi
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
movb   $0x4c,0xb(%rsp)
movl   $0x1,0x1c(%rsp)
lea    0xb(%rsp),%r13
lea    0xe0(%rsp),%rbp
lea    0x84(%rsp),%r14
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
mov    %rbp,%rcx
mov    %r14,%r8
mov    %r9,%rbx
call   1040 <dpotrf_@plt>
mov    0xe0(%rsp),%edx
shl    $0x3,%edx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1090 <memcpy@plt>
lea    0x1c(%rsp),%rdx
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %r15,%rcx
mov    %rbp,%r8
mov    %r12,%r9
push   %r14
push   %rbp
call   1080 <dpotrs_@plt>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ParallelLinearSystem(double* %0, i32 %1, i32 %2, i32 %3, i32 %4, double* %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i32 %11, double* %12, i32 %13, i32 %14, i32 %15, i32 %16, i32 %17) {
%19 = alloca double*
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca double*
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca i32
%31 = alloca double*
%32 = alloca i32
%33 = alloca i32
%34 = alloca i32
%35 = alloca i32
%36 = alloca i32
%37 = alloca double*
%38 = alloca i32
%39 = alloca i32
%40 = alloca i32
%41 = alloca i8
%42 = alloca i32
store double* %0, double** %19
store i32 %1, i32* %20
store i32 %2, i32* %21
store i32 %3, i32* %22
store i32 %4, i32* %23
store double* %5, double** %24
store i32 %6, i32* %25
store i32 %7, i32* %26
store i32 %8, i32* %27
store i32 %9, i32* %28
store i32 %10, i32* %29
store i32 %11, i32* %30
store double* %12, double** %31
store i32 %13, i32* %32
store i32 %14, i32* %33
store i32 %15, i32* %34
store i32 %16, i32* %35
store i32 %17, i32* %36
%43 = load i32, i32* %29
%44 = load i32, i32* %36
%45 = icmp sgt i32 %43, %44
br i1 %45, label %46, label %95
46: ; preds = %18
%47 = load i32, i32* %29
%48 = sitofp i32 %47 to double
%49 = fmul double 5.000000e-01, %48
%50 = call i32 @ceil(double %49)
%51 = call i32 @pow(i32 %50, i32 2)
%52 = mul nsw i32 2, %51
%53 = call i64 @calloc(i32 %52, i32 8)
%54 = inttoptr i64 %53 to double*
store double* %54, double** %37
%55 = load i32, i32* %29
%56 = sitofp i32 %55 to double
%57 = fmul double 5.000000e-01, %56
%58 = call i32 @ceil(double %57)
%59 = call i32 @pow(i32 %58, i32 2)
%60 = load i32, i32* %36
%61 = sdiv i32 %59, %60
store i32 %61, i32* %38
store i32 0, i32* %39
br label %62
62: ; preds = %89, %46
%63 = load i32, i32* %39
%64 = load i32, i32* %36
%65 = icmp slt i32 %63, %64
br i1 %65, label %66, label %92
66: ; preds = %62
%67 = load double*, double** %19
%68 = load i32, i32* %20
%69 = load i32, i32* %21
%70 = load i32, i32* %22
%71 = load i32, i32* %23
%72 = load double*, double** %24
%73 = load i32, i32* %25
%74 = load i32, i32* %26
%75 = load i32, i32* %27
%76 = load i32, i32* %28
%77 = load i32, i32* %29
%78 = load i32, i32* %30
%79 = load double*, double** %31
%80 = load i32, i32* %32
%81 = load i32, i32* %33
%82 = load i32, i32* %34
%83 = load i32, i32* %35
%84 = load i32, i32* %36
%85 = load i32, i32* %39
%86 = load double*, double** %37
%87 = load i32, i32* %38
%88 = call i32 @LinearSystem(double* %67, i32 %68, i32 %69, i32 %70, i32 %71, double* %72, i32 %73, i32 %74, i32 %75, i32 %76, i32 %77, i32 %78, double* %79, i32 %80, i32 %81, i32 %82, i32 %83, i32 %84, i32 %85, i32 0, double* %86, i32 %87)
br label %89
89: ; preds = %66
%90 = load i32, i32* %39
%91 = add nsw i32 %90, 1
store i32 %91, i32* %39
br label %62
92: ; preds = %62
%93 = load double*, double** %37
%94 = call i32 @free(double* %93)
br label %108
95: ; preds = %18
store i8 76, i8* %41
store i32 1, i32* %42
%96 = load double*, double** %19
%97 = call i32 @dpotrf_(i8* %41, i32* %29, double* %96, i32* %29, i32* %40)
%98 = load double*, double** %31
%99 = load double*, double** %24
%100 = load i32, i32* %29
%101 = sext i32 %100 to i64
%102 = mul i64 %101, 8
%103 = trunc i64 %102 to i32
%104 = call i32 @memcpy(double* %98, double* %99, i32 %103)
%105 = load double*, double** %19
%106 = load double*, double** %31
%107 = call i32 @dpotrs_(i8* %41, i32* %29, i32* %42, double* %105, i32* %29, double* %106, i32* %29, i32* %40)
br label %108
108: ; preds = %95, %92
ret void
}

LLVM IR (-O2):
define void @ParallelLinearSystem(double* %0, i32 %1, i32 %2, i32 %3, i32 %4, double* %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i32 %11, double* %12, i32 %13, i32 %14, i32 %15, i32 %16, i32 %17) {
%19 = alloca i32
%20 = alloca i32
%21 = alloca i8
%22 = alloca i32
store i32 %10, i32* %19
%23 = icmp sgt i32 %10, %17
br i1 %23, label %24, label %43
24: ; preds = %18
%25 = sitofp i32 %10 to double
%26 = fmul double %25, 5.000000e-01
%27 = tail call i32 @ceil(double %26)
%28 = tail call i32 @pow(i32 %27, i32 2)
%29 = shl nsw i32 %28, 1
%30 = tail call i64 @calloc(i32 %29, i32 8)
%31 = inttoptr i64 %30 to double*
%32 = tail call i32 @ceil(double %26)
%33 = tail call i32 @pow(i32 %32, i32 2)
%34 = sdiv i32 %33, %17
%35 = icmp sgt i32 %17, 0
br i1 %35, label %36, label %41
36: ; preds = %24, %36
%37 = phi i32 [ %39, %36 ], [ 0, %24 ]
%38 = tail call i32 @LinearSystem(double* %0, i32 %1, i32 %2, i32 %3, i32 %4, double* %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i32 %11, double* %12, i32 %13, i32 %14, i32 %15, i32 %16, i32 %17, i32 %37, i32 0, double* %31, i32 %34)
%39 = add nuw nsw i32 %37, 1
%40 = icmp eq i32 %39, %17
br i1 %40, label %41, label %36
41: ; preds = %36, %24
%42 = tail call i32 @free(double* %31)
br label %51
43: ; preds = %18
%44 = bitcast i32* %20 to i8*
store i8 76, i8* %21
%45 = bitcast i32* %22 to i8*
store i32 1, i32* %22
%46 = call i32 @dpotrf_(i8* %21, i32* %19, double* %0, i32* %19, i32* %20)
%47 = load i32, i32* %19
%48 = shl i32 %47, 3
%49 = call i32 @memcpy(double* %12, double* %5, i32 %48)
%50 = call i32 @dpotrs_(i8* %21, i32* %19, i32* %22, double* %0, i32* %19, double* %12, i32* %19, i32* %20)
br label %51
51: ; preds = %43, %41
ret void
}