#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(int a, int b) {
  int nprimes = 0;
  if (a <= 2) {
    nprimes = 1;
    a = 2;
  }
  if (a % 2 == 0)
    a++;
  for (int i = a; i <= b; i += 2) {
    if (is_prime_number(i))
      nprimes++;
  }
  return nprimes;
}


x86 assembly (clang, -O0):
<count_prime_numbers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x2,-0x4(%rbp)
jg     113d <count_prime_numbers+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+0x4a>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     119a <count_prime_numbers+0x8a>
mov    -0x10(%rbp),%edi
call   1030 <is_prime_number@plt>
cmp    $0x0,%rax
je     1187 <count_prime_numbers+0x77>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118c <count_prime_numbers+0x7c>
mov    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x10(%rbp)
jmp    1160 <count_prime_numbers+0x50>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_prime_numbers>:
push   %rbp
push   %r14
push   %rbx
xor    %ebx,%ebx
cmp    $0x3,%edi
setl   %bl
mov    $0x2,%eax
cmovge %edi,%eax
mov    %eax,%ebp
not    %ebp
and    $0x1,%ebp
add    %eax,%ebp
cmp    %esi,%ebp
jg     1156 <count_prime_numbers+0x46>
mov    %esi,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
call   1030 <is_prime_number@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebx
add    $0x2,%ebp
cmp    %r14d,%ebp
jle    1140 <count_prime_numbers+0x30>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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