#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();
    int nloc = 0;
#pragma omp for schedule(dynamic, 100) nowait
    for (int i = a; i <= b; i += 2) {
      if (is_prime_number(i))
        nloc++;
    }
#pragma omp atomic
    nprimes += nloc;
    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)
movl   $0x0,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11bd <count_prime_numbers_omp+0x9d>
mov    -0x20(%rbp),%edi
call   1040 <is_prime_number@plt>
cmp    $0x0,%rax
je     11aa <count_prime_numbers_omp+0x8a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11af <count_prime_numbers_omp+0x8f>
mov    -0x20(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x20(%rbp)
jmp    1183 <count_prime_numbers_omp+0x63>
mov    -0x1c(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
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   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r14d
cmp    $0x3,%edi
mov    $0x2,%eax
cmovge %edi,%eax
mov    %esi,%r15d
mov    %eax,%ebx
not    %ebx
and    $0x1,%ebx
add    %eax,%ebx
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <omp_get_wtime@plt>
cmp    %r15d,%ebx
jg     1176 <count_prime_numbers_omp+0x56>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1040 <is_prime_number@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
add    $0x2,%ebx
cmp    %r15d,%ebx
jle    1160 <count_prime_numbers_omp+0x40>
xor    %ebx,%ebx
cmp    $0x3,%r14d
setl   %bl
add    %ebp,%ebx
xor    %eax,%eax
call   1030 <omp_get_wtime@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
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
%8 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
%9 = load i32, i32* %3
%10 = icmp sle i32 %9, 2
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 1, i32* %5
store i32 2, i32* %3
br label %12
12: ; preds = %11, %2
%13 = load i32, i32* %3
%14 = srem i32 %13, 2
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %19
19: ; preds = %16, %12
%20 = call double (...) @omp_get_wtime()
store double %20, double* %6
store i32 0, i32* %7
%21 = load i32, i32* %3
store i32 %21, i32* %8
br label %22
22: ; preds = %34, %19
%23 = load i32, i32* %8
%24 = load i32, i32* %4
%25 = icmp sle i32 %23, %24
br i1 %25, label %26, label %37
26: ; preds = %22
%27 = load i32, i32* %8
%28 = call i64 @is_prime_number(i32 %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %33
33: ; preds = %30, %26
br label %34
34: ; preds = %33
%35 = load i32, i32* %8
%36 = add nsw i32 %35, 2
store i32 %36, i32* %8
br label %22
37: ; preds = %22
%38 = load i32, i32* %7
%39 = load i32, i32* %5
%40 = add nsw i32 %39, %38
store i32 %40, i32* %5
%41 = call double (...) @omp_get_wtime()
%42 = load double, double* %6
%43 = fsub double %41, %42
store double %43, double* %6
%44 = load i32, i32* %5
ret i32 %44
}

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 = and i32 %4, 1
%6 = xor i32 %5, 1
%7 = add nuw nsw i32 %6, %4
%8 = tail call double (...) @omp_get_wtime()
%9 = icmp sgt i32 %7, %1
br i1 %9, label %10, label %15
10: ; preds = %15, %2
%11 = phi i32 [ 0, %2 ], [ %21, %15 ]
%12 = zext i1 %3 to i32
%13 = add nuw nsw i32 %11, %12
%14 = tail call double (...) @omp_get_wtime()
ret i32 %13
15: ; preds = %2, %15
%16 = phi i32 [ %22, %15 ], [ %7, %2 ]
%17 = phi i32 [ %21, %15 ], [ 0, %2 ]
%18 = tail call i64 @is_prime_number(i32 %16)
%19 = icmp ne i64 %18, 0
%20 = zext i1 %19 to i32
%21 = add nuw nsw i32 %17, %20
%22 = add nsw i32 %16, 2
%23 = icmp sgt i32 %22, %1
br i1 %23, label %10, label %15
}