#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);
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
  {
    int nloc = 0;
#pragma omp for
    for (int i = a; i <= b; i += 2) {
      if (is_prime_number(i))
        nloc++;
    }
#pragma omp atomic
    nprimes += nloc;
  }
  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     113d <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    115a <count_prime_numbers_omp+0x4a>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11a1 <count_prime_numbers_omp+0x91>
mov    -0x14(%rbp),%edi
call   1030 <is_prime_number@plt>
cmp    $0x0,%rax
je     118e <count_prime_numbers_omp+0x7e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1193 <count_prime_numbers_omp+0x83>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    1167 <count_prime_numbers_omp+0x57>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%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    %eax,%ebx
not    %ebx
and    $0x1,%ebx
add    %eax,%ebx
xor    %ebp,%ebp
cmp    %esi,%ebx
jg     1156 <count_prime_numbers_omp+0x46>
mov    %esi,%r15d
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %ebx,%edi
call   1030 <is_prime_number@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
add    $0x2,%ebx
cmp    %r15d,%ebx
jle    1140 <count_prime_numbers_omp+0x30>
xor    %eax,%eax
cmp    $0x3,%r14d
setl   %al
add    %ebp,%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 i32
%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
store i32 0, i32* %6
%19 = load i32, i32* %3
store i32 %19, i32* %7
br label %20
20: ; preds = %32, %18
%21 = load i32, i32* %7
%22 = load i32, i32* %4
%23 = icmp sle i32 %21, %22
br i1 %23, label %24, label %35
24: ; preds = %20
%25 = load i32, i32* %7
%26 = call i64 @is_prime_number(i32 %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %31
31: ; preds = %28, %24
br label %32
32: ; preds = %31
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 2
store i32 %34, i32* %7
br label %20
35: ; preds = %20
%36 = load i32, i32* %6
%37 = load i32, i32* %5
%38 = add nsw i32 %37, %36
store i32 %38, i32* %5
%39 = load i32, i32* %5
ret i32 %39
}

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