#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 __isdom_kernel_parallel(double *, int, int);
int __isdom_kernel_sequential(double *, int);
int omp_get_max_threads();
int isdom(double *A, int n) {
  int p, chunk, minsize, dom;
  p = omp_get_max_threads();
  minsize = 16;
  chunk = n / p;
  if (chunk < minsize) {
    dom = __isdom_kernel_sequential(A, n);
  } else {
    dom = __isdom_kernel_parallel(A, n, p);
  }
  return dom;
}


x86 assembly (clang, -O0):
<isdom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x0,%al
call   1040 <omp_get_max_threads@plt>
mov    %eax,-0x10(%rbp)
movl   $0x10,-0x18(%rbp)
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    117a <isdom+0x4a>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <__isdom_kernel_sequential@plt>
mov    %eax,-0x1c(%rbp)
jmp    118c <isdom+0x5c>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <__isdom_kernel_parallel@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isdom>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
xor    %eax,%eax
call   1040 <omp_get_max_threads@plt>
mov    %eax,%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
mov    %r14,%rdi
mov    %ebx,%esi
cmp    $0xf,%eax
jg     115d <isdom+0x2d>
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <__isdom_kernel_sequential@plt>
mov    %ecx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <__isdom_kernel_parallel@plt>

LLVM IR (-O0):
define i32 @isdom(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
%9 = call i32 (...) @omp_get_max_threads()
store i32 %9, i32* %5
store i32 16, i32* %7
%10 = load i32, i32* %4
%11 = load i32, i32* %5
%12 = sdiv i32 %10, %11
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = load i32, i32* %7
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = load double*, double** %3
%18 = load i32, i32* %4
%19 = call i32 @__isdom_kernel_sequential(double* %17, i32 %18)
store i32 %19, i32* %8
br label %25
20: ; preds = %2
%21 = load double*, double** %3
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = call i32 @__isdom_kernel_parallel(double* %21, i32 %22, i32 %23)
store i32 %24, i32* %8
br label %25
25: ; preds = %20, %16
%26 = load i32, i32* %8
ret i32 %26
}

LLVM IR (-O2):
define i32 @isdom(double* %0, i32 %1) {
%3 = tail call i32 (...) @omp_get_max_threads()
%4 = sdiv i32 %1, %3
%5 = icmp slt i32 %4, 16
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @__isdom_kernel_sequential(double* %0, i32 %1)
br label %10
8: ; preds = %2
%9 = tail call i32 @__isdom_kernel_parallel(double* %0, i32 %1, i32 %3)
br label %10
10: ; preds = %8, %6
%11 = phi i32 [ %7, %6 ], [ %9, %8 ]
ret i32 %11
}