#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 */
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int solution(int A[], int N) {
  unsigned char appeared[2000001 / 8 + 1];
  unsigned short int onesInByte[] = {
      0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4,
      2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
      2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4,
      2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
      2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6,
      4, 5, 5, 6, 5, 6, 6, 7, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
      2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5,
      3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
      2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6,
      4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
      4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8};
  int index = 0;
  int result = 0;
  memset(appeared, 0, 2000001 / 8 + 1);
  for (index = 0; index < N; ++index) {
    appeared[(A[index] + 1000000) / 8] |=
        (1 << (int)((A[index] + 1000000) % 8));
  }
  for (index = 0; index < 2000001 / 8 + 1; ++index) {
    result += onesInByte[appeared[index]];
  }
  return result;
}


x86 assembly (clang, -O0):
<solution>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3d2b0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x3d2a0(%rbp),%rdi
lea    0xec0(%rip),%rsi
mov    $0x200,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x3d2a4(%rbp)
movl   $0x0,-0x3d2a8(%rbp)
lea    -0x3d0a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x3d091,%edx
call   1030 <memset@plt>
movl   $0x0,-0x3d2a4(%rbp)
mov    -0x3d2a4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11fc <solution+0xdc>
mov    -0x8(%rbp),%rax
movslq -0x3d2a4(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    $0xf4240,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x3d2ac(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x3d2a4(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    $0xf4240,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0x3d2ac(%rbp),%edx
cltq
movzbl -0x3d0a0(%rbp,%rax,1),%ecx
ff
or     %edx,%ecx
mov    %cl,-0x3d0a0(%rbp,%rax,1)
mov    -0x3d2a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3d2a4(%rbp)
jmp    117b <solution+0x5b>
movl   $0x0,-0x3d2a4(%rbp)
cmpl   $0x3d091,-0x3d2a4(%rbp)
jge    124d <solution+0x12d>
movslq -0x3d2a4(%rbp),%rax
movzbl -0x3d0a0(%rbp,%rax,1),%eax
ff
movzwl -0x3d2a0(%rbp,%rax,2),%eax
ff
add    -0x3d2a8(%rbp),%eax
mov    %eax,-0x3d2a8(%rbp)
mov    -0x3d2a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3d2a4(%rbp)
jmp    1206 <solution+0xe6>
mov    -0x3d2a8(%rbp),%eax
add    $0x3d2b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solution>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x3d098,%rsp
mov    %esi,%r14d
mov    %rdi,%r15
mov    %rsp,%rdi
xor    %ebp,%ebp
xor    %esi,%esi
mov    $0x3d091,%edx
call   1030 <memset@plt>
test   %r14d,%r14d
jle    1173 <solution+0x63>
mov    %r14d,%eax
xor    %edx,%edx
xchg   %ax,%ax
mov    (%r15,%rdx,4),%esi
lea    0xf4240(%rsi),%edi
mov    %esi,%ecx
and    $0x7,%cl
mov    $0x1,%ebx
shl    %cl,%ebx
add    $0xf4247,%esi
test   %edi,%edi
cmovns %edi,%esi
sar    $0x3,%esi
movslq %esi,%rcx
or     %bl,(%rsp,%rcx,1)
add    $0x1,%rdx
cmp    %rdx,%rax
jne    1140 <solution+0x30>
mov    $0x3,%ecx
lea    0xe81(%rip),%rdx
nop
movzbl -0x3(%rsp,%rcx,1),%eax
movzwl (%rdx,%rax,2),%eax
add    %ebp,%eax
cmp    $0x3d093,%rcx
je     11ba <solution+0xaa>
movzbl -0x2(%rsp,%rcx,1),%esi
movzwl (%rdx,%rsi,2),%esi
add    %esi,%eax
movzbl -0x1(%rsp,%rcx,1),%esi
movzwl (%rdx,%rsi,2),%esi
add    %eax,%esi
movzbl (%rsp,%rcx,1),%eax
movzwl (%rdx,%rax,2),%ebp
add    %esi,%ebp
add    $0x4,%rcx
jmp    1180 <solution+0x70>
add    $0x3d098,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.solution.onesInByte = [256 x i16] [i16 0, i16 1, i16 1, i16 2, i16 1, i16 2, i16 2, i16 3, i16 1, i16 2, i16 2, i16 3, i16 2, i16 3, i16 3, i16 4, i16 1, i16 2, i16 2, i16 3, i16 2, i16 3, i16 3, i16 4, i16 2, i16 3, i16 3, i16 4, i16 3, i16 4, i16 4, i16 5, i16 1, i16 2, i16 2, i16 3, i16 2, i16 3, i16 3, i16 4, i16 2, i16 3, i16 3, i16 4, i16 3, i16 4, i16 4, i16 5, i16 2, i16 3, i16 3, i16 4, i16 3, i16 4, i16 4, i16 5, i16 3, i16 4, i16 4, i16 5, i16 4, i16 5, i16 5, i16 6, i16 1, i16 2, i16 2, i16 3, i16 2, i16 3, i16 3, i16 4, i16 2, i16 3, i16 3, i16 4, i16 3, i16 4, i16 4, i16 5, i16 2, i16 3, i16 3, i16 4, i16 3, i16 4, i16 4, i16 5, i16 3, i16 4, i16 4, i16 5, i16 4, i16 5, i16 5, i16 6, i16 2, i16 3, i16 3, i16 4, i16 3, i16 4, i16 4, i16 5, i16 3, i16 4, i16 4, i16 5, i16 4, i16 5, i16 5, i16 6, i16 3, i16 4, i16 4, i16 5, i16 4, i16 5, i16 5, i16 6, i16 4, i16 5, i16 5, i16 6, i16 5, i16 6, i16 6, i16 7, i16 1, i16 2, i16 2, i16 3, i16 2, i16 3, i16 3, i16 4, i16 2, i16 3, i16 3, i16 4, i16 3, i16 4, i16 4, i16 5, i16 2, i16 3, i16 3, i16 4, i16 3, i16 4, i16 4, i16 5, i16 3, i16 4, i16 4, i16 5, i16 4, i16 5, i16 5, i16 6, i16 2, i16 3, i16 3, i16 4, i16 3, i16 4, i16 4, i16 5, i16 3, i16 4, i16 4, i16 5, i16 4, i16 5, i16 5, i16 6, i16 3, i16 4, i16 4, i16 5, i16 4, i16 5, i16 5, i16 6, i16 4, i16 5, i16 5, i16 6, i16 5, i16 6, i16 6, i16 7, i16 2, i16 3, i16 3, i16 4, i16 3, i16 4, i16 4, i16 5, i16 3, i16 4, i16 4, i16 5, i16 4, i16 5, i16 5, i16 6, i16 3, i16 4, i16 4, i16 5, i16 4, i16 5, i16 5, i16 6, i16 4, i16 5, i16 5, i16 6, i16 5, i16 6, i16 6, i16 7, i16 3, i16 4, i16 4, i16 5, i16 4, i16 5, i16 5, i16 6, i16 4, i16 5, i16 5, i16 6, i16 5, i16 6, i16 6, i16 7, i16 4, i16 5, i16 5, i16 6, i16 5, i16 6, i16 6, i16 7, i16 5, i16 6, i16 6, i16 7, i16 6, i16 7, i16 7, i16 8]
define i32 @solution(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca [250001 x i8]
%6 = alloca [256 x i16]
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%9 = bitcast [256 x i16]* %6 to i8*
store i32 0, i32* %7
store i32 0, i32* %8
%10 = getelementptr inbounds [250001 x i8], [250001 x i8]* %5, i64 0, i64 0
%11 = call i32 @memset(i8* %10, i32 0, i32 250001)
store i32 0, i32* %7
br label %12
12: ; preds = %38, %2
%13 = load i32, i32* %7
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %41
16: ; preds = %12
%17 = load i32*, i32** %3
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 1000000
%23 = srem i32 %22, 8
%24 = shl i32 1, %23
%25 = load i32*, i32** %3
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = load i32, i32* %28
%30 = add nsw i32 %29, 1000000
%31 = sdiv i32 %30, 8
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [250001 x i8], [250001 x i8]* %5, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = or i32 %35, %24
%37 = trunc i32 %36 to i8
store i8 %37, i8* %33
br label %38
38: ; preds = %16
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
br label %12
41: ; preds = %12
store i32 0, i32* %7
br label %42
42: ; preds = %56, %41
%43 = load i32, i32* %7
%44 = icmp slt i32 %43, 250001
br i1 %44, label %45, label %59
45: ; preds = %42
%46 = load i32, i32* %7
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [250001 x i8], [250001 x i8]* %5, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = zext i8 %49 to i64
%51 = getelementptr inbounds [256 x i16], [256 x i16]* %6, i64 0, i64 %50
%52 = load i16, i16* %51
%53 = zext i16 %52 to i32
%54 = load i32, i32* %8
%55 = add nsw i32 %54, %53
store i32 %55, i32* %8
br label %56
56: ; preds = %45
%57 = load i32, i32* %7
%58 = add nsw i32 %57, 1
store i32 %58, i32* %7
br label %42
59: ; preds = %42
%60 = load i32, i32* %8
ret i32 %60
}

LLVM IR (-O2):
@__const.solution.onesInByte = [256 x i16] [i16 0, i16 1, i16 1, i16 2, i16 1, i16 2, i16 2, i16 3, i16 1, i16 2, i16 2, i16 3, i16 2, i16 3, i16 3, i16 4, i16 1, i16 2, i16 2, i16 3, i16 2, i16 3, i16 3, i16 4, i16 2, i16 3, i16 3, i16 4, i16 3, i16 4, i16 4, i16 5, i16 1, i16 2, i16 2, i16 3, i16 2, i16 3, i16 3, i16 4, i16 2, i16 3, i16 3, i16 4, i16 3, i16 4, i16 4, i16 5, i16 2, i16 3, i16 3, i16 4, i16 3, i16 4, i16 4, i16 5, i16 3, i16 4, i16 4, i16 5, i16 4, i16 5, i16 5, i16 6, i16 1, i16 2, i16 2, i16 3, i16 2, i16 3, i16 3, i16 4, i16 2, i16 3, i16 3, i16 4, i16 3, i16 4, i16 4, i16 5, i16 2, i16 3, i16 3, i16 4, i16 3, i16 4, i16 4, i16 5, i16 3, i16 4, i16 4, i16 5, i16 4, i16 5, i16 5, i16 6, i16 2, i16 3, i16 3, i16 4, i16 3, i16 4, i16 4, i16 5, i16 3, i16 4, i16 4, i16 5, i16 4, i16 5, i16 5, i16 6, i16 3, i16 4, i16 4, i16 5, i16 4, i16 5, i16 5, i16 6, i16 4, i16 5, i16 5, i16 6, i16 5, i16 6, i16 6, i16 7, i16 1, i16 2, i16 2, i16 3, i16 2, i16 3, i16 3, i16 4, i16 2, i16 3, i16 3, i16 4, i16 3, i16 4, i16 4, i16 5, i16 2, i16 3, i16 3, i16 4, i16 3, i16 4, i16 4, i16 5, i16 3, i16 4, i16 4, i16 5, i16 4, i16 5, i16 5, i16 6, i16 2, i16 3, i16 3, i16 4, i16 3, i16 4, i16 4, i16 5, i16 3, i16 4, i16 4, i16 5, i16 4, i16 5, i16 5, i16 6, i16 3, i16 4, i16 4, i16 5, i16 4, i16 5, i16 5, i16 6, i16 4, i16 5, i16 5, i16 6, i16 5, i16 6, i16 6, i16 7, i16 2, i16 3, i16 3, i16 4, i16 3, i16 4, i16 4, i16 5, i16 3, i16 4, i16 4, i16 5, i16 4, i16 5, i16 5, i16 6, i16 3, i16 4, i16 4, i16 5, i16 4, i16 5, i16 5, i16 6, i16 4, i16 5, i16 5, i16 6, i16 5, i16 6, i16 6, i16 7, i16 3, i16 4, i16 4, i16 5, i16 4, i16 5, i16 5, i16 6, i16 4, i16 5, i16 5, i16 6, i16 5, i16 6, i16 6, i16 7, i16 4, i16 5, i16 5, i16 6, i16 5, i16 6, i16 6, i16 7, i16 5, i16 6, i16 6, i16 7, i16 6, i16 7, i16 7, i16 8]
define i32 @solution(i32* nocapture %0, i32 %1) {
%3 = alloca [250001 x i8]
%4 = getelementptr inbounds [250001 x i8], [250001 x i8]* %3, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i32 0, i32 250001)
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %24
7: ; preds = %2
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %22, %9 ]
%11 = getelementptr inbounds i32, i32* %0, i64 %10
%12 = load i32, i32* %11
%13 = add nsw i32 %12, 1000000
%14 = and i32 %12, 7
%15 = shl nuw nsw i32 1, %14
%16 = sdiv i32 %13, 8
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [250001 x i8], [250001 x i8]* %3, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = trunc i32 %15 to i8
%21 = or i8 %19, %20
store i8 %21, i8* %18
%22 = add nuw nsw i64 %10, 1
%23 = icmp eq i64 %22, %8
br i1 %23, label %24, label %9
24: ; preds = %9, %2
br label %25
25: ; preds = %37, %24
%26 = phi i64 [ 0, %24 ], [ %61, %37 ]
%27 = phi i32 [ 0, %24 ], [ %60, %37 ]
%28 = getelementptr inbounds [250001 x i8], [250001 x i8]* %3, i64 0, i64 %26
%29 = load i8, i8* %28
%30 = zext i8 %29 to i64
%31 = getelementptr inbounds [256 x i16], [256 x i16]* @__const.solution.onesInByte, i64 0, i64 %30
%32 = load i16, i16* %31
%33 = zext i16 %32 to i32
%34 = add nuw nsw i32 %27, %33
%35 = or i64 %26, 1
%36 = icmp eq i64 %35, 250001
br i1 %36, label %62, label %37
37: ; preds = %25
%38 = getelementptr inbounds [250001 x i8], [250001 x i8]* %3, i64 0, i64 %35
%39 = load i8, i8* %38
%40 = zext i8 %39 to i64
%41 = getelementptr inbounds [256 x i16], [256 x i16]* @__const.solution.onesInByte, i64 0, i64 %40
%42 = load i16, i16* %41
%43 = zext i16 %42 to i32
%44 = add nuw nsw i32 %34, %43
%45 = or i64 %26, 2
%46 = getelementptr inbounds [250001 x i8], [250001 x i8]* %3, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = zext i8 %47 to i64
%49 = getelementptr inbounds [256 x i16], [256 x i16]* @__const.solution.onesInByte, i64 0, i64 %48
%50 = load i16, i16* %49
%51 = zext i16 %50 to i32
%52 = add nuw nsw i32 %44, %51
%53 = or i64 %26, 3
%54 = getelementptr inbounds [250001 x i8], [250001 x i8]* %3, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = zext i8 %55 to i64
%57 = getelementptr inbounds [256 x i16], [256 x i16]* @__const.solution.onesInByte, i64 0, i64 %56
%58 = load i16, i16* %57
%59 = zext i16 %58 to i32
%60 = add nuw nsw i32 %52, %59
%61 = add nuw nsw i64 %26, 4
br label %25
62: ; preds = %25
ret i32 %34
}