#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 */
struct bitfield {
  int dummy;
};

/* Variables and functions */
scalar_t__ _bfxor(int /*<<< orphan*/, struct bitfield const *,
                  struct bitfield const *);
int /*<<< orphan*/ bfdel(struct bitfield *);
unsigned int bfpopcount(struct bitfield *);
int /*<<< orphan*/ count_arguments(char *);
unsigned int bfhamming(const struct bitfield *input1,
                       const struct bitfield *input2) {
  struct bitfield *input_xored = (struct bitfield *)_bfxor(
      count_arguments("input1, input2"), input1, input2);
  unsigned int hamming = bfpopcount(input_xored);
  bfdel(input_xored);
  return hamming;
}


x86 assembly (clang, -O0):
<bfhamming>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea9(%rip),%rdi
call   1030 <count_arguments@plt>
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1050 <_bfxor@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <bfpopcount@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <bfdel@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bfhamming>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xeaf(%rip),%rdi
call   1030 <count_arguments@plt>
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <_bfxor@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <bfpopcount@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <bfdel@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.bitfield = type { i32 }
@.str = [15 x i8] c"input1, input2\00"
define i32 @bfhamming(%struct.bitfield* %0, %struct.bitfield* %1) {
%3 = alloca %struct.bitfield*
%4 = alloca %struct.bitfield*
%5 = alloca %struct.bitfield*
%6 = alloca i32
store %struct.bitfield* %0, %struct.bitfield** %3
store %struct.bitfield* %1, %struct.bitfield** %4
%7 = call i32 @count_arguments(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%8 = load %struct.bitfield*, %struct.bitfield** %3
%9 = load %struct.bitfield*, %struct.bitfield** %4
%10 = call i64 @_bfxor(i32 %7, %struct.bitfield* %8, %struct.bitfield* %9)
%11 = inttoptr i64 %10 to %struct.bitfield*
store %struct.bitfield* %11, %struct.bitfield** %5
%12 = load %struct.bitfield*, %struct.bitfield** %5
%13 = call i32 @bfpopcount(%struct.bitfield* %12)
store i32 %13, i32* %6
%14 = load %struct.bitfield*, %struct.bitfield** %5
%15 = call i32 @bfdel(%struct.bitfield* %14)
%16 = load i32, i32* %6
ret i32 %16
}

LLVM IR (-O2):
%struct.bitfield = type { i32 }
@.str = [15 x i8] c"input1, input2\00"
define i32 @bfhamming(%struct.bitfield* %0, %struct.bitfield* %1) {
%3 = tail call i32 @count_arguments(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%4 = tail call i64 @_bfxor(i32 %3, %struct.bitfield* %0, %struct.bitfield* %1)
%5 = inttoptr i64 %4 to %struct.bitfield*
%6 = tail call i32 @bfpopcount(%struct.bitfield* %5)
%7 = tail call i32 @bfdel(%struct.bitfield* %5)
ret i32 %6
}