#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 */
double __jaciter_kernel_parallel(double *, double *, double *, double *,
                                 double *, double *, double *, double *, int,
                                 int);
double __jaciter_kernel_sequential(double *, double *, double *, double *,
                                   double *, double *, double *, double *, int);
int omp_get_max_threads();
double jaciter(double *A, double *b, double *R, double *C, double *Dinv,
               double *xk, double *xkp1, double *xconv, int n) {
  int p, chunk, minsize;
  double e;
  p = omp_get_max_threads();
  minsize = 16;
  chunk = n / p;
  if (chunk < minsize) {
    e = __jaciter_kernel_sequential(A, b, R, C, Dinv, xk, xkp1, xconv, n);
  } else {
    e = __jaciter_kernel_parallel(A, b, R, C, Dinv, xk, xkp1, xconv, n, p);
  }
  return e;
}


x86 assembly (clang, -O0):
<jaciter>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x68,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    $0x0,%al
call   1050 <omp_get_max_threads@plt>
mov    %eax,-0x3c(%rbp)
movl   $0x10,-0x44(%rbp)
mov    0x20(%rbp),%eax
cltd
idivl  -0x3c(%rbp)
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    11c2 <jaciter+0x92>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
mov    0x10(%rbp),%r11
mov    0x18(%rbp),%r10
mov    0x20(%rbp),%eax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1040 <__jaciter_kernel_sequential@plt>
movsd  %xmm0,-0x50(%rbp)
jmp    1205 <jaciter+0xd5>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
mov    0x10(%rbp),%rbx
mov    0x18(%rbp),%r11
mov    0x20(%rbp),%r10d
mov    -0x3c(%rbp),%eax
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1030 <__jaciter_kernel_parallel@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
add    $0x68,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<jaciter>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,0x10(%rsp)
mov    %r8,0x8(%rsp)
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%r15
mov    %rdi,%r14
mov    0x70(%rsp),%ebx
mov    0x68(%rsp),%rax
mov    %rax,0x18(%rsp)
mov    0x60(%rsp),%rax
mov    %rax,0x20(%rsp)
xor    %eax,%eax
call   1050 <omp_get_max_threads@plt>
mov    %eax,%ebp
mov    %ebx,%eax
cltd
idiv   %ebp
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
mov    %r12,%rcx
cmp    $0xf,%eax
jg     11a8 <jaciter+0x78>
mov    0x8(%rsp),%r8
mov    0x10(%rsp),%r9
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <__jaciter_kernel_sequential@plt>
mov    0x8(%rsp),%r8
mov    0x10(%rsp),%r9
push   %rbp
push   %rbx
push   0x28(%rsp)
push   0x38(%rsp)
call   1030 <__jaciter_kernel_parallel@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define double @jaciter(double* %0, double* %1, double* %2, double* %3, double* %4, double* %5, double* %6, double* %7, i32 %8) {
%10 = tail call i32 (...) @omp_get_max_threads()
%11 = sdiv i32 %8, %10
%12 = icmp slt i32 %11, 16
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call double @__jaciter_kernel_sequential(double* %0, double* %1, double* %2, double* %3, double* %4, double* %5, double* %6, double* %7, i32 %8)
br label %17
15: ; preds = %9
%16 = tail call double @__jaciter_kernel_parallel(double* %0, double* %1, double* %2, double* %3, double* %4, double* %5, double* %6, double* %7, i32 %8, i32 %10)
br label %17
17: ; preds = %15, %13
%18 = phi double [ %14, %13 ], [ %16, %15 ]
ret double %18
}