#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 */
typedef int uint64_t;

/* Variables and functions */
int scalar_hamming_weight(int);
void scalar_jaccard_index(const uint64_t *dataA, const uint64_t *dataB,
                          size_t length, uint64_t *j_union, uint64_t *j_inter) {
  *j_union = 0;
  *j_inter = 0;
  for (size_t k = 0; k < length; k++) {
    uint64_t A = dataA[k];
    uint64_t B = dataB[k];
    *j_union += scalar_hamming_weight(A | B);
    *j_inter += scalar_hamming_weight(A & B);
  }
}


x86 assembly (clang, -O0):
<scalar_jaccard_index>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11ad <scalar_jaccard_index+0x9d>
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%edi
or     -0x38(%rbp),%edi
call   1030 <scalar_hamming_weight@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x34(%rbp),%edi
and    -0x38(%rbp),%edi
call   1030 <scalar_hamming_weight@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1148 <scalar_jaccard_index+0x38>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scalar_jaccard_index>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,0x10(%rsp)
movl   $0x0,(%rcx)
movl   $0x0,(%r8)
test   %rdx,%rdx
je     1185 <scalar_jaccard_index+0x75>
mov    %r8,%r15
mov    %rdx,%rbx
mov    %rsi,%r13
xor    %r14d,%r14d
mov    %rdi,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
mov    (%rdi,%r14,4),%r12d
mov    0x0(%r13,%r14,4),%ebp
mov    %ebp,%edi
or     %r12d,%edi
call   1030 <scalar_hamming_weight@plt>
mov    0x10(%rsp),%rcx
add    %eax,(%rcx)
and    %r12d,%ebp
mov    %ebp,%edi
call   1030 <scalar_hamming_weight@plt>
mov    0x8(%rsp),%rdi
add    %eax,(%r15)
add    $0x1,%r14
cmp    %r14,%rbx
jne    1150 <scalar_jaccard_index+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @scalar_jaccard_index(i32* %0, i32* %1, i64 %2, i32* %3, i32* %4) {
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i64
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
store i32* %0, i32** %6
store i32* %1, i32** %7
store i64 %2, i64* %8
store i32* %3, i32** %9
store i32* %4, i32** %10
%14 = load i32*, i32** %9
store i32 0, i32* %14
%15 = load i32*, i32** %10
store i32 0, i32* %15
store i64 0, i64* %11
br label %16
16: ; preds = %43, %5
%17 = load i64, i64* %11
%18 = load i64, i64* %8
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %46
20: ; preds = %16
%21 = load i32*, i32** %6
%22 = load i64, i64* %11
%23 = getelementptr inbounds i32, i32* %21, i64 %22
%24 = load i32, i32* %23
store i32 %24, i32* %12
%25 = load i32*, i32** %7
%26 = load i64, i64* %11
%27 = getelementptr inbounds i32, i32* %25, i64 %26
%28 = load i32, i32* %27
store i32 %28, i32* %13
%29 = load i32, i32* %12
%30 = load i32, i32* %13
%31 = or i32 %29, %30
%32 = call i32 @scalar_hamming_weight(i32 %31)
%33 = load i32*, i32** %9
%34 = load i32, i32* %33
%35 = add nsw i32 %34, %32
store i32 %35, i32* %33
%36 = load i32, i32* %12
%37 = load i32, i32* %13
%38 = and i32 %36, %37
%39 = call i32 @scalar_hamming_weight(i32 %38)
%40 = load i32*, i32** %10
%41 = load i32, i32* %40
%42 = add nsw i32 %41, %39
store i32 %42, i32* %40
br label %43
43: ; preds = %20
%44 = load i64, i64* %11
%45 = add i64 %44, 1
store i64 %45, i64* %11
br label %16
46: ; preds = %16
ret void
}

LLVM IR (-O2):
define void @scalar_jaccard_index(i32* nocapture %0, i32* nocapture %1, i64 %2, i32* nocapture %3, i32* nocapture %4) {
store i32 0, i32* %3
store i32 0, i32* %4
%6 = icmp eq i64 %2, 0
br i1 %6, label %7, label %8
7: ; preds = %8, %5
ret void
8: ; preds = %5, %8
%9 = phi i64 [ %22, %8 ], [ 0, %5 ]
%10 = getelementptr inbounds i32, i32* %0, i64 %9
%11 = load i32, i32* %10
%12 = getelementptr inbounds i32, i32* %1, i64 %9
%13 = load i32, i32* %12
%14 = or i32 %13, %11
%15 = tail call i32 @scalar_hamming_weight(i32 %14)
%16 = load i32, i32* %3
%17 = add nsw i32 %16, %15
store i32 %17, i32* %3
%18 = and i32 %13, %11
%19 = tail call i32 @scalar_hamming_weight(i32 %18)
%20 = load i32, i32* %4
%21 = add nsw i32 %20, %19
store i32 %21, i32* %4
%22 = add nuw i64 %9, 1
%23 = icmp eq i64 %22, %2
br i1 %23, label %7, label %8
}