#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 popcount12(unsigned int);
void gen_double_weight_polynomial(unsigned int *all_codes,
                                  int *hamming_weight_polynomial) {
  for (int i = 0; i < 64; ++i) {
    for (int j = 0; j < 64; ++j) {
      int weight1 = popcount12(all_codes[i]);
      int weight2 = popcount12(all_codes[j]);
      int koeff =
          12 * popcount12(all_codes[i] & all_codes[j]) - weight1 * weight2;
      int index = 2 * 12 - 2 - weight1 - weight2;
      if (index >= 0) {
        hamming_weight_polynomial[index] += koeff;
      }
    }
  }
}


x86 assembly (clang, -O0):
<gen_double_weight_polynomial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x40,-0x14(%rbp)
jge    11e1 <gen_double_weight_polynomial+0xd1>
movl   $0x0,-0x18(%rbp)
cmpl   $0x40,-0x18(%rbp)
jge    11ce <gen_double_weight_polynomial+0xbe>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1030 <popcount12@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1030 <popcount12@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
and    (%rax,%rcx,4),%edi
call   1030 <popcount12@plt>
imul   $0xc,%eax,%eax
mov    -0x1c(%rbp),%ecx
imul   -0x20(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    $0x16,%eax
sub    -0x1c(%rbp),%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jl     11bb <gen_double_weight_polynomial+0xab>
mov    -0x24(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
add    (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
jmp    11c0 <gen_double_weight_polynomial+0xb0>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1138 <gen_double_weight_polynomial+0x28>
jmp    11d3 <gen_double_weight_polynomial+0xc3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <gen_double_weight_polynomial+0x17>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_double_weight_polynomial>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %r13d,%r13d
jmp    113a <gen_double_weight_polynomial+0x2a>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r13
cmp    $0x40,%r13
je     118f <gen_double_weight_polynomial+0x7f>
xor    %ebp,%ebp
jmp    114a <gen_double_weight_polynomial+0x3a>
xchg   %ax,%ax
add    $0x1,%rbp
cmp    $0x40,%rbp
je     1130 <gen_double_weight_polynomial+0x20>
mov    (%r15,%r13,4),%edi
call   1030 <popcount12@plt>
mov    %eax,%r12d
mov    (%r15,%rbp,4),%edi
call   1030 <popcount12@plt>
mov    %eax,%ebx
mov    (%r15,%rbp,4),%edi
and    (%r15,%r13,4),%edi
call   1030 <popcount12@plt>
lea    (%r12,%rbx,1),%edx
mov    $0x16,%ecx
sub    %edx,%ecx
js     1140 <gen_double_weight_polynomial+0x30>
shl    $0x2,%eax
lea    (%rax,%rax,2),%eax
imul   %r12d,%ebx
sub    %ebx,%eax
mov    %ecx,%ecx
add    %eax,(%r14,%rcx,4)
jmp    1140 <gen_double_weight_polynomial+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @gen_double_weight_polynomial(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %5
br label %11
11: ; preds = %67, %2
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 64
br i1 %13, label %14, label %70
14: ; preds = %11
store i32 0, i32* %6
br label %15
15: ; preds = %63, %14
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 64
br i1 %17, label %18, label %66
18: ; preds = %15
%19 = load i32*, i32** %3
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
%24 = call i32 @popcount12(i32 %23)
store i32 %24, i32* %7
%25 = load i32*, i32** %3
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = load i32, i32* %28
%30 = call i32 @popcount12(i32 %29)
store i32 %30, i32* %8
%31 = load i32*, i32** %3
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = load i32, i32* %34
%36 = load i32*, i32** %3
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
%40 = load i32, i32* %39
%41 = and i32 %35, %40
%42 = call i32 @popcount12(i32 %41)
%43 = mul nsw i32 12, %42
%44 = load i32, i32* %7
%45 = load i32, i32* %8
%46 = mul nsw i32 %44, %45
%47 = sub nsw i32 %43, %46
store i32 %47, i32* %9
%48 = load i32, i32* %7
%49 = sub nsw i32 22, %48
%50 = load i32, i32* %8
%51 = sub nsw i32 %49, %50
store i32 %51, i32* %10
%52 = load i32, i32* %10
%53 = icmp sge i32 %52, 0
br i1 %53, label %54, label %62
54: ; preds = %18
%55 = load i32, i32* %9
%56 = load i32*, i32** %4
%57 = load i32, i32* %10
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i32, i32* %56, i64 %58
%60 = load i32, i32* %59
%61 = add nsw i32 %60, %55
store i32 %61, i32* %59
br label %62
62: ; preds = %54, %18
br label %63
63: ; preds = %62
%64 = load i32, i32* %6
%65 = add nsw i32 %64, 1
store i32 %65, i32* %6
br label %15
66: ; preds = %15
br label %67
67: ; preds = %66
%68 = load i32, i32* %5
%69 = add nsw i32 %68, 1
store i32 %69, i32* %5
br label %11
70: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @gen_double_weight_polynomial(i32* nocapture %0, i32* nocapture %1) {
br label %3
3: ; preds = %2, %7
%4 = phi i64 [ 0, %2 ], [ %8, %7 ]
%5 = getelementptr inbounds i32, i32* %0, i64 %4
br label %10
6: ; preds = %7
ret void
7: ; preds = %32
%8 = add nuw nsw i64 %4, 1
%9 = icmp eq i64 %8, 64
br i1 %9, label %6, label %3
10: ; preds = %3, %32
%11 = phi i64 [ 0, %3 ], [ %33, %32 ]
%12 = load i32, i32* %5
%13 = tail call i32 @popcount12(i32 %12)
%14 = getelementptr inbounds i32, i32* %0, i64 %11
%15 = load i32, i32* %14
%16 = tail call i32 @popcount12(i32 %15)
%17 = load i32, i32* %5
%18 = load i32, i32* %14
%19 = and i32 %18, %17
%20 = tail call i32 @popcount12(i32 %19)
%21 = add i32 %13, %16
%22 = sub i32 22, %21
%23 = icmp sgt i32 %22, -1
br i1 %23, label %24, label %32
24: ; preds = %10
%25 = mul nsw i32 %20, 12
%26 = mul nsw i32 %16, %13
%27 = sub i32 %25, %26
%28 = zext i32 %22 to i64
%29 = getelementptr inbounds i32, i32* %1, i64 %28
%30 = load i32, i32* %29
%31 = add nsw i32 %27, %30
store i32 %31, i32* %29
br label %32
32: ; preds = %24, %10
%33 = add nuw nsw i64 %11, 1
%34 = icmp eq i64 %33, 64
br i1 %34, label %7, label %10
}