#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 */
scalar_t__ is_prime_number(int);
double omp_get_wtime();
int count_prime_numbers_omp(int a, int b) {
  int nprimes = 0;
  if (a <= 2) {
    nprimes = 1;
    a = 2;
  }
  if (a % 2 == 0)
    a++;
#pragma omp parallel
  {
    double t = omp_get_wtime();
#pragma omp for schedule(dynamic, 100) reduction(+ : nprimes) nowait
    for (int i = a; i <= b; i += 2) {
      if (is_prime_number(i))
        nprimes++;
    }
    t = omp_get_wtime() - t;
  }
  return nprimes;
}


x86 assembly (clang, -O0):
<count_prime_numbers_omp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x2,-0x4(%rbp)
jg     114d <count_prime_numbers_omp+0x2d>
movl   $0x1,-0xc(%rbp)
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    116a <count_prime_numbers_omp+0x4a>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11b6 <count_prime_numbers_omp+0x96>
mov    -0x1c(%rbp),%edi
call   1040 <is_prime_number@plt>
cmp    $0x0,%rax
je     11a3 <count_prime_numbers_omp+0x83>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a8 <count_prime_numbers_omp+0x88>
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
jmp    117c <count_prime_numbers_omp+0x5c>
mov    $0x0,%al
call   1030 <omp_get_wtime@plt>
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_prime_numbers_omp>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
xor    %ebx,%ebx
cmp    $0x3,%edi
mov    $0x2,%eax
cmovge %edi,%eax
setl   %bl
mov    %eax,%ebp
not    %ebp
and    $0x1,%ebp
add    %eax,%ebp
xor    %eax,%eax
call   1030 <omp_get_wtime@plt>
cmp    %r14d,%ebp
jg     1166 <count_prime_numbers_omp+0x46>
nopl   0x0(%rax)
mov    %ebp,%edi
call   1040 <is_prime_number@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebx
add    $0x2,%ebp
cmp    %r14d,%ebp
jle    1150 <count_prime_numbers_omp+0x30>
xor    %eax,%eax
call   1030 <omp_get_wtime@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @count_prime_numbers_omp(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
%8 = load i32, i32* %3
%9 = icmp sle i32 %8, 2
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 1, i32* %5
store i32 2, i32* %3
br label %11
11: ; preds = %10, %2
%12 = load i32, i32* %3
%13 = srem i32 %12, 2
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %18
18: ; preds = %15, %11
%19 = call double (...) @omp_get_wtime()
store double %19, double* %6
%20 = load i32, i32* %3
store i32 %20, i32* %7
br label %21
21: ; preds = %33, %18
%22 = load i32, i32* %7
%23 = load i32, i32* %4
%24 = icmp sle i32 %22, %23
br i1 %24, label %25, label %36
25: ; preds = %21
%26 = load i32, i32* %7
%27 = call i64 @is_prime_number(i32 %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %32
32: ; preds = %29, %25
br label %33
33: ; preds = %32
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 2
store i32 %35, i32* %7
br label %21
36: ; preds = %21
%37 = call double (...) @omp_get_wtime()
%38 = load double, double* %6
%39 = fsub double %37, %38
store double %39, double* %6
%40 = load i32, i32* %5
ret i32 %40
}

LLVM IR (-O2):
define i32 @count_prime_numbers_omp(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, 3
%4 = select i1 %3, i32 2, i32 %0
%5 = zext i1 %3 to i32
%6 = and i32 %4, 1
%7 = xor i32 %6, 1
%8 = add nuw nsw i32 %7, %4
%9 = tail call double (...) @omp_get_wtime()
%10 = icmp sgt i32 %8, %1
br i1 %10, label %11, label %14
11: ; preds = %14, %2
%12 = phi i32 [ %5, %2 ], [ %20, %14 ]
%13 = tail call double (...) @omp_get_wtime()
ret i32 %12
14: ; preds = %2, %14
%15 = phi i32 [ %21, %14 ], [ %8, %2 ]
%16 = phi i32 [ %20, %14 ], [ %5, %2 ]
%17 = tail call i64 @is_prime_number(i32 %15)
%18 = icmp ne i64 %17, 0
%19 = zext i1 %18 to i32
%20 = add nuw nsw i32 %16, %19
%21 = add nsw i32 %15, 2
%22 = icmp sgt i32 %21, %1
br i1 %22, label %11, label %14
}