#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*/ __getrd_kernel_parallel(double *, double *, double *,
                                           double *, double *, int, int, int);
int /*<<< orphan*/ __getrd_kernel_sequential(double *, double *, double *,
                                             double *, double *, int, int);
int omp_get_max_threads();
void getrd(double *Dinv, double *R, double *A, double *b, double *C, int n,
           int m) {
  int p, minsize, chunk;
  p = omp_get_max_threads();
  minsize = 16;
  chunk = n / p;
  if (chunk < minsize) {
    __getrd_kernel_sequential(Dinv, R, A, b, C, n, m);
  } else {
    __getrd_kernel_parallel(Dinv, R, A, b, C, n, m, p);
  }
}


x86 assembly (clang, -O0):
<getrd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    $0x0,%al
call   1040 <omp_get_max_threads@plt>
mov    %eax,-0x30(%rbp)
movl   $0x10,-0x34(%rbp)
mov    -0x2c(%rbp),%eax
cltd
idivl  -0x30(%rbp)
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    11a2 <getrd+0x72>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x2c(%rbp),%r9d
mov    0x10(%rbp),%eax
mov    %eax,(%rsp)
call   1030 <__getrd_kernel_sequential@plt>
jmp    11ce <getrd+0x9e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x2c(%rbp),%r9d
mov    0x10(%rbp),%r10d
mov    -0x30(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1050 <__getrd_kernel_parallel@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getrd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%ebx
mov    %r8,0x8(%rsp)
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%r14
mov    0x50(%rsp),%eax
mov    %rax,0x10(%rsp)
xor    %eax,%eax
call   1040 <omp_get_max_threads@plt>
mov    %eax,%ebp
mov    %ebx,%eax
cltd
idiv   %ebp
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
cmp    $0xf,%eax
jg     1195 <getrd+0x65>
mov    0x8(%rsp),%r8
mov    %ebx,%r9d
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <__getrd_kernel_sequential@plt>
mov    0x8(%rsp),%r8
mov    %ebx,%r9d
push   %rbp
push   0x18(%rsp)
call   1050 <__getrd_kernel_parallel@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @getrd(double* %0, double* %1, double* %2, double* %3, double* %4, i32 %5, i32 %6) {
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store double* %0, double** %8
store double* %1, double** %9
store double* %2, double** %10
store double* %3, double** %11
store double* %4, double** %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%18 = call i32 (...) @omp_get_max_threads()
store i32 %18, i32* %15
store i32 16, i32* %16
%19 = load i32, i32* %13
%20 = load i32, i32* %15
%21 = sdiv i32 %19, %20
store i32 %21, i32* %17
%22 = load i32, i32* %17
%23 = load i32, i32* %16
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %34
25: ; preds = %7
%26 = load double*, double** %8
%27 = load double*, double** %9
%28 = load double*, double** %10
%29 = load double*, double** %11
%30 = load double*, double** %12
%31 = load i32, i32* %13
%32 = load i32, i32* %14
%33 = call i32 @__getrd_kernel_sequential(double* %26, double* %27, double* %28, double* %29, double* %30, i32 %31, i32 %32)
br label %44
34: ; preds = %7
%35 = load double*, double** %8
%36 = load double*, double** %9
%37 = load double*, double** %10
%38 = load double*, double** %11
%39 = load double*, double** %12
%40 = load i32, i32* %13
%41 = load i32, i32* %14
%42 = load i32, i32* %15
%43 = call i32 @__getrd_kernel_parallel(double* %35, double* %36, double* %37, double* %38, double* %39, i32 %40, i32 %41, i32 %42)
br label %44
44: ; preds = %34, %25
ret void
}

LLVM IR (-O2):
define void @getrd(double* %0, double* %1, double* %2, double* %3, double* %4, i32 %5, i32 %6) {
%8 = tail call i32 (...) @omp_get_max_threads()
%9 = sdiv i32 %5, %8
%10 = icmp slt i32 %9, 16
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 @__getrd_kernel_sequential(double* %0, double* %1, double* %2, double* %3, double* %4, i32 %5, i32 %6)
br label %15
13: ; preds = %7
%14 = tail call i32 @__getrd_kernel_parallel(double* %0, double* %1, double* %2, double* %3, double* %4, i32 %5, i32 %6, i32 %8)
br label %15
15: ; preds = %13, %11
ret void
}