#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__ get_hamming_distance(int, int);
int get_total_hamming_distance_for_all_number_pairs_v1(int *array, int len) {
  int index, inner_index, total_hamming_distance;
  if (!array || (len <= 1)) {
    return (0);
  }
  total_hamming_distance = 0;
  for (index = 0; index < (len - 1); ++index) {
    for (inner_index = index + 1; inner_index < len; ++inner_index) {
      total_hamming_distance +=
          get_hamming_distance(array[index], array[inner_index]);
    }
  }
  return (total_hamming_distance);
}


x86 assembly (clang, -O0):
<get_total_hamming_distance_for_all_number_pairs_v1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1134 <get_total_hamming_distance_for_all_number_pairs_v1+0x24>
cmpl   $0x1,-0x14(%rbp)
jg     1140 <get_total_hamming_distance_for_all_number_pairs_v1+0x30>
movl   $0x0,-0x4(%rbp)
jmp    11c3 <get_total_hamming_distance_for_all_number_pairs_v1+0xb3>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11bd <get_total_hamming_distance_for_all_number_pairs_v1+0xad>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11aa <get_total_hamming_distance_for_all_number_pairs_v1+0x9a>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1030 <get_hamming_distance@plt>
mov    %rax,%rcx
movslq -0x20(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1168 <get_total_hamming_distance_for_all_number_pairs_v1+0x58>
jmp    11af <get_total_hamming_distance_for_all_number_pairs_v1+0x9f>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114e <get_total_hamming_distance_for_all_number_pairs_v1+0x3e>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_total_hamming_distance_for_all_number_pairs_v1>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %ebp,%ebp
test   %rdi,%rdi
je     119a <get_total_hamming_distance_for_all_number_pairs_v1+0x8a>
cmp    $0x2,%esi
jl     119a <get_total_hamming_distance_for_all_number_pairs_v1+0x8a>
mov    %rdi,%r12
mov    %esi,%r13d
add    $0xffffffff,%esi
mov    %rsi,0x8(%rsp)
xor    %r15d,%r15d
mov    %r13,(%rsp)
mov    %rdi,%rbx
xor    %ebp,%ebp
jmp    1164 <get_total_hamming_distance_for_all_number_pairs_v1+0x54>
cs nopw 0x0(%rax,%rax,1)
add    $0x4,%rbx
add    $0xffffffffffffffff,%r13
mov    0x10(%rsp),%r15
cmp    0x8(%rsp),%r15
je     119a <get_total_hamming_distance_for_all_number_pairs_v1+0x8a>
lea    0x1(%r15),%rax
cmp    (%rsp),%rax
mov    %rax,0x10(%rsp)
jae    1150 <get_total_hamming_distance_for_all_number_pairs_v1+0x40>
mov    $0x1,%r14d
nopl   0x0(%rax)
mov    (%r12,%r15,4),%edi
mov    (%rbx,%r14,4),%esi
call   1030 <get_hamming_distance@plt>
add    %eax,%ebp
add    $0x1,%r14
cmp    %r14,%r13
jne    1180 <get_total_hamming_distance_for_all_number_pairs_v1+0x70>
jmp    1150 <get_total_hamming_distance_for_all_number_pairs_v1+0x40>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @get_total_hamming_distance_for_all_number_pairs_v1(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%9 = load i32*, i32** %4
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* %5
%13 = icmp sle i32 %12, 1
br i1 %13, label %14, label %15
14: ; preds = %11, %2
store i32 0, i32* %3
br label %53
15: ; preds = %11
store i32 0, i32* %8
store i32 0, i32* %6
br label %16
16: ; preds = %48, %15
%17 = load i32, i32* %6
%18 = load i32, i32* %5
%19 = sub nsw i32 %18, 1
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %51
21: ; preds = %16
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %7
br label %24
24: ; preds = %44, %21
%25 = load i32, i32* %7
%26 = load i32, i32* %5
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %47
28: ; preds = %24
%29 = load i32*, i32** %4
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
%33 = load i32, i32* %32
%34 = load i32*, i32** %4
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
%38 = load i32, i32* %37
%39 = call i64 @get_hamming_distance(i32 %33, i32 %38)
%40 = load i32, i32* %8
%41 = sext i32 %40 to i64
%42 = add nsw i64 %41, %39
%43 = trunc i64 %42 to i32
store i32 %43, i32* %8
br label %44
44: ; preds = %28
%45 = load i32, i32* %7
%46 = add nsw i32 %45, 1
store i32 %46, i32* %7
br label %24
47: ; preds = %24
br label %48
48: ; preds = %47
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %16
51: ; preds = %16
%52 = load i32, i32* %8
store i32 %52, i32* %3
br label %53
53: ; preds = %51, %14
%54 = load i32, i32* %3
ret i32 %54
}

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