#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 */
unsigned long long sqrt(unsigned long long);
void searchPrimesBasicOMP(unsigned long long max, unsigned long long *isPrime) {
  if (max == 0)
    return;
  (isPrime[(unsigned int)(0) / ((sizeof(unsigned long long)) * 8)] &=
   ~(1ULL << ((unsigned int)(0) % ((sizeof(unsigned long long)) * 8))));
  (isPrime[(unsigned int)(1) / ((sizeof(unsigned long long)) * 8)] &=
   ~(1ULL << ((unsigned int)(1) % ((sizeof(unsigned long long)) * 8))));
  if (max < 2)
    return;
  (isPrime[(unsigned int)(2) / ((sizeof(unsigned long long)) * 8)] |=
   (1ULL << ((unsigned int)(2) % ((sizeof(unsigned long long)) * 8))));
  (isPrime[(unsigned int)(3) / ((sizeof(unsigned long long)) * 8)] |=
   (1ULL << ((unsigned int)(3) % ((sizeof(unsigned long long)) * 8))));
  for (int i = 4; i <= max;
       ((i % 2 == 1) ? (isPrime[(unsigned int)(i) /
                                ((sizeof(unsigned long long)) * 8)] |=
                        (1ULL << ((unsigned int)(i) %
                                  ((sizeof(unsigned long long)) * 8))))
                     : (isPrime[(unsigned int)(i) /
                                ((sizeof(unsigned long long)) * 8)] &=
                        ~(1ULL << ((unsigned int)(i) %
                                   ((sizeof(unsigned long long)) * 8))))),
           i++)
    ;
#pragma omp parallel for
  for (unsigned long long i = 3; i <= max; i += 2) {
    for (unsigned long long j = 3;
         j <= sqrt(i) &&
         (isPrime[(unsigned int)(i) / ((sizeof(unsigned long long)) * 8)] >>
              ((unsigned int)(i) % ((sizeof(unsigned long long)) * 8)) &
          1ULL);
         j += 2) {
      if ((i % j) == 0) {
#pragma omp critical
        (isPrime[(unsigned int)(i) / ((sizeof(unsigned long long)) * 8)] &=
         ~(1ULL << ((unsigned int)(i) % ((sizeof(unsigned long long)) * 8))));
      }
    }
  }
}


x86 assembly (clang, -O0):
<searchPrimesBasicOMP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1130 <searchPrimesBasicOMP+0x20>
jmp    12f6 <searchPrimesBasicOMP+0x1e6>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
and    $0xfffffffffffffffe,%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
and    $0xfffffffffffffffd,%rcx
mov    %rcx,(%rax)
cmpq   $0x2,-0x8(%rbp)
jae    115c <searchPrimesBasicOMP+0x4c>
jmp    12f6 <searchPrimesBasicOMP+0x1e6>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
or     $0x4,%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
or     $0x8,%rcx
mov    %rcx,(%rax)
movl   $0x4,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x8(%rbp),%rax
ja     1205 <searchPrimesBasicOMP+0xf5>
jmp    1192 <searchPrimesBasicOMP+0x82>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    11cf <searchPrimesBasicOMP+0xbf>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
and    $0x3f,%rcx
mov    $0x1,%edx
shl    %cl,%rdx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shr    $0x6,%rcx
or     (%rax,%rcx,8),%rdx
mov    %rdx,(%rax,%rcx,8)
jmp    11f7 <searchPrimesBasicOMP+0xe7>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
and    $0x3f,%rcx
mov    $0x1,%edx
shl    %cl,%rdx
xor    $0xffffffffffffffff,%rdx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shr    $0x6,%rcx
and    (%rax,%rcx,8),%rdx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117f <searchPrimesBasicOMP+0x6f>
movq   $0x3,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
ja     12f6 <searchPrimesBasicOMP+0x1e6>
movq   $0x3,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <sqrt@plt>
mov    -0x38(%rbp),%rcx
mov    %rax,%rdx
xor    %eax,%eax
cmp    %rdx,%rcx
mov    %al,-0x29(%rbp)
ja     1276 <searchPrimesBasicOMP+0x166>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %ecx,%ecx
shr    $0x6,%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x20(%rbp),%rcx
mov    %ecx,%ecx
and    $0x3f,%rcx
shr    %cl,%rax
and    $0x1,%rax
cmp    $0x0,%rax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1286 <searchPrimesBasicOMP+0x176>
jmp    12e0 <searchPrimesBasicOMP+0x1d0>
mov    -0x20(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x28(%rbp)
cmp    $0x0,%rdx
jne    12ca <searchPrimesBasicOMP+0x1ba>
mov    -0x20(%rbp),%rax
mov    %eax,%eax
mov    %eax,%ecx
and    $0x3f,%rcx
mov    $0x1,%edx
shl    %cl,%rdx
xor    $0xffffffffffffffff,%rdx
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %ecx,%ecx
shr    $0x6,%rcx
and    (%rax,%rcx,8),%rdx
mov    %rdx,(%rax,%rcx,8)
jmp    12cf <searchPrimesBasicOMP+0x1bf>
mov    -0x28(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x28(%rbp)
jmp    1223 <searchPrimesBasicOMP+0x113>
jmp    12e5 <searchPrimesBasicOMP+0x1d5>
mov    -0x20(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x20(%rbp)
jmp    120d <searchPrimesBasicOMP+0xfd>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<searchPrimesBasicOMP>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,(%rsp)
test   %rdi,%rdi
je     114d <searchPrimesBasicOMP+0x3d>
mov    %rsi,%r15
mov    (%rsi),%rax
and    $0xfffffffffffffffc,%rax
mov    %rax,(%rsi)
cmpq   $0x1,(%rsp)
je     114d <searchPrimesBasicOMP+0x3d>
or     $0xc,%rax
mov    %rax,(%r15)
cmpq   $0x4,(%rsp)
jae    115c <searchPrimesBasicOMP+0x4c>
cmpq   $0x3,(%rsp)
jae    11aa <searchPrimesBasicOMP+0x9a>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x3,%eax
sub    (%rsp),%rax
mov    $0x4,%ecx
jmp    1190 <searchPrimesBasicOMP+0x80>
nopl   0x0(%rax)
not    %rdx
mov    %rcx,%rsi
shr    $0x6,%rsi
and    %rdx,(%r15,%rsi,8)
lea    (%rax,%rcx,1),%rdx
add    $0x1,%rdx
add    $0x1,%rcx
cmp    $0x4,%rdx
je     1146 <searchPrimesBasicOMP+0x36>
mov    $0x1,%edx
shl    %cl,%rdx
test   $0x1,%cl
je     1170 <searchPrimesBasicOMP+0x60>
mov    %rcx,%rsi
shr    $0x6,%rsi
or     %rdx,(%r15,%rsi,8)
jmp    117e <searchPrimesBasicOMP+0x6e>
mov    $0x3,%ebx
jmp    11ca <searchPrimesBasicOMP+0xba>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x2,%rbx
cmp    (%rsp),%rbx
ja     114d <searchPrimesBasicOMP+0x3d>
mov    %rbx,%rdi
call   1030 <sqrt@plt>
cmp    $0x3,%rax
jb     11c0 <searchPrimesBasicOMP+0xb0>
mov    %ebx,%r12d
shr    $0x6,%r12d
mov    $0x1,%r13d
mov    %ebx,%ecx
shl    %cl,%r13
mov    $0xfffffffffffffffe,%rbp
rol    %cl,%rbp
mov    $0x3,%r14d
jmp    1211 <searchPrimesBasicOMP+0x101>
nopl   0x0(%rax)
add    $0x2,%r14
mov    %rbx,%rdi
call   1030 <sqrt@plt>
cmp    %rax,%r14
ja     11c0 <searchPrimesBasicOMP+0xb0>
mov    (%r15,%r12,8),%rcx
test   %r13,%rcx
je     11c0 <searchPrimesBasicOMP+0xb0>
mov    %rbx,%rax
or     %r14,%rax
shr    $0x20,%rax
je     1240 <searchPrimesBasicOMP+0x130>
mov    %rbx,%rax
xor    %edx,%edx
div    %r14
test   %rdx,%rdx
jne    1200 <searchPrimesBasicOMP+0xf0>
jmp    124c <searchPrimesBasicOMP+0x13c>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebx,%eax
xor    %edx,%edx
div    %r14d
test   %rdx,%rdx
jne    1200 <searchPrimesBasicOMP+0xf0>
and    %rbp,%rcx
mov    %rcx,(%r15,%r12,8)
jmp    1200 <searchPrimesBasicOMP+0xf0>

LLVM IR (-O0):
define void @searchPrimesBasicOMP(i64 %0, i64* %1) {
%3 = alloca i64
%4 = alloca i64*
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
store i64 %0, i64* %3
store i64* %1, i64** %4
%8 = load i64, i64* %3
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
br label %127
11: ; preds = %2
%12 = load i64*, i64** %4
%13 = getelementptr inbounds i64, i64* %12, i64 0
%14 = load i64, i64* %13
%15 = and i64 %14, -2
store i64 %15, i64* %13
%16 = load i64*, i64** %4
%17 = getelementptr inbounds i64, i64* %16, i64 0
%18 = load i64, i64* %17
%19 = and i64 %18, -3
store i64 %19, i64* %17
%20 = load i64, i64* %3
%21 = icmp ult i64 %20, 2
br i1 %21, label %22, label %23
22: ; preds = %11
br label %127
23: ; preds = %11
%24 = load i64*, i64** %4
%25 = getelementptr inbounds i64, i64* %24, i64 0
%26 = load i64, i64* %25
%27 = or i64 %26, 4
store i64 %27, i64* %25
%28 = load i64*, i64** %4
%29 = getelementptr inbounds i64, i64* %28, i64 0
%30 = load i64, i64* %29
%31 = or i64 %30, 8
store i64 %31, i64* %29
store i32 4, i32* %5
br label %32
32: ; preds = %67, %23
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = load i64, i64* %3
%36 = icmp ule i64 %34, %35
br i1 %36, label %37, label %71
37: ; preds = %32
br label %38
38: ; preds = %37
%39 = load i32, i32* %5
%40 = srem i32 %39, 2
%41 = icmp eq i32 %40, 1
br i1 %41, label %42, label %54
42: ; preds = %38
%43 = load i32, i32* %5
%44 = zext i32 %43 to i64
%45 = urem i64 %44, 64
%46 = shl i64 1, %45
%47 = load i64*, i64** %4
%48 = load i32, i32* %5
%49 = zext i32 %48 to i64
%50 = udiv i64 %49, 64
%51 = getelementptr inbounds i64, i64* %47, i64 %50
%52 = load i64, i64* %51
%53 = or i64 %52, %46
store i64 %53, i64* %51
br label %67
54: ; preds = %38
%55 = load i32, i32* %5
%56 = zext i32 %55 to i64
%57 = urem i64 %56, 64
%58 = shl i64 1, %57
%59 = xor i64 %58, -1
%60 = load i64*, i64** %4
%61 = load i32, i32* %5
%62 = zext i32 %61 to i64
%63 = udiv i64 %62, 64
%64 = getelementptr inbounds i64, i64* %60, i64 %63
%65 = load i64, i64* %64
%66 = and i64 %65, %59
store i64 %66, i64* %64
br label %67
67: ; preds = %54, %42
%68 = phi i64 [ %53, %42 ], [ %66, %54 ]
%69 = load i32, i32* %5
%70 = add nsw i32 %69, 1
store i32 %70, i32* %5
br label %32
71: ; preds = %32
store i64 3, i64* %6
br label %72
72: ; preds = %124, %71
%73 = load i64, i64* %6
%74 = load i64, i64* %3
%75 = icmp ule i64 %73, %74
br i1 %75, label %76, label %127
76: ; preds = %72
store i64 3, i64* %7
br label %77
77: ; preds = %120, %76
%78 = load i64, i64* %7
%79 = load i64, i64* %6
%80 = call i64 @sqrt(i64 %79)
%81 = icmp ule i64 %78, %80
br i1 %81, label %82, label %97
82: ; preds = %77
%83 = load i64*, i64** %4
%84 = load i64, i64* %6
%85 = trunc i64 %84 to i32
%86 = zext i32 %85 to i64
%87 = udiv i64 %86, 64
%88 = getelementptr inbounds i64, i64* %83, i64 %87
%89 = load i64, i64* %88
%90 = load i64, i64* %6
%91 = trunc i64 %90 to i32
%92 = zext i32 %91 to i64
%93 = urem i64 %92, 64
%94 = lshr i64 %89, %93
%95 = and i64 %94, 1
%96 = icmp ne i64 %95, 0
br label %97
97: ; preds = %82, %77
%98 = phi i1 [ false, %77 ], [ %96, %82 ]
br i1 %98, label %99, label %123
99: ; preds = %97
%100 = load i64, i64* %6
%101 = load i64, i64* %7
%102 = urem i64 %100, %101
%103 = icmp eq i64 %102, 0
br i1 %103, label %104, label %119
104: ; preds = %99
%105 = load i64, i64* %6
%106 = trunc i64 %105 to i32
%107 = zext i32 %106 to i64
%108 = urem i64 %107, 64
%109 = shl i64 1, %108
%110 = xor i64 %109, -1
%111 = load i64*, i64** %4
%112 = load i64, i64* %6
%113 = trunc i64 %112 to i32
%114 = zext i32 %113 to i64
%115 = udiv i64 %114, 64
%116 = getelementptr inbounds i64, i64* %111, i64 %115
%117 = load i64, i64* %116
%118 = and i64 %117, %110
store i64 %118, i64* %116
br label %119
119: ; preds = %104, %99
br label %120
120: ; preds = %119
%121 = load i64, i64* %7
%122 = add i64 %121, 2
store i64 %122, i64* %7
br label %77
123: ; preds = %97
br label %124
124: ; preds = %123
%125 = load i64, i64* %6
%126 = add i64 %125, 2
store i64 %126, i64* %6
br label %72
127: ; preds = %10, %22, %72
ret void
}

LLVM IR (-O2):
define void @searchPrimesBasicOMP(i64 %0, i64* nocapture %1) {
%3 = icmp eq i64 %0, 0
br i1 %3, label %61, label %4
4: ; preds = %2
%5 = load i64, i64* %1
%6 = and i64 %5, -4
store i64 %6, i64* %1
%7 = icmp eq i64 %0, 1
br i1 %7, label %61, label %8
8: ; preds = %4
%9 = or i64 %6, 12
store i64 %9, i64* %1
%10 = icmp ult i64 %0, 4
br i1 %10, label %11, label %13
11: ; preds = %30, %8
%12 = icmp ult i64 %0, 3
br i1 %12, label %61, label %33
13: ; preds = %8, %30
%14 = phi i64 [ %31, %30 ], [ 4, %8 ]
%15 = and i64 %14, 1
%16 = icmp eq i64 %15, 0
%17 = and i64 %14, 63
%18 = shl nuw i64 1, %17
br i1 %16, label %24, label %19
19: ; preds = %13
%20 = lshr i64 %14, 6
%21 = getelementptr inbounds i64, i64* %1, i64 %20
%22 = load i64, i64* %21
%23 = or i64 %22, %18
store i64 %23, i64* %21
br label %30
24: ; preds = %13
%25 = xor i64 %18, -1
%26 = lshr i64 %14, 6
%27 = getelementptr inbounds i64, i64* %1, i64 %26
%28 = load i64, i64* %27
%29 = and i64 %28, %25
store i64 %29, i64* %27
br label %30
30: ; preds = %24, %19
%31 = add nuw nsw i64 %14, 1
%32 = icmp eq i64 %14, %0
br i1 %32, label %11, label %13
33: ; preds = %11, %49
%34 = phi i64 [ %50, %49 ], [ 3, %11 ]
%35 = lshr i64 %34, 6
%36 = and i64 %35, 67108863
%37 = getelementptr inbounds i64, i64* %1, i64 %36
%38 = tail call i64 @sqrt(i64 %34)
%39 = icmp ult i64 %38, 3
br i1 %39, label %49, label %40
40: ; preds = %33
%41 = and i64 %34, 63
%42 = shl nuw i64 1, %41
%43 = xor i64 %42, -1
br label %44
44: ; preds = %40, %57
%45 = phi i64 [ 3, %40 ], [ %58, %57 ]
%46 = load i64, i64* %37
%47 = and i64 %46, %42
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %44, %57, %33
%50 = add i64 %34, 2
%51 = icmp ugt i64 %50, %0
br i1 %51, label %61, label %33
52: ; preds = %44
%53 = urem i64 %34, %45
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %52
%56 = and i64 %46, %43
store i64 %56, i64* %37
br label %57
57: ; preds = %52, %55
%58 = add i64 %45, 2
%59 = tail call i64 @sqrt(i64 %34)
%60 = icmp ugt i64 %58, %59
br i1 %60, label %49, label %44
61: ; preds = %49, %11, %4, %2
ret void
}