#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 */
size_t edit_distance_c(unsigned char c1, unsigned char c2) {
  size_t i, dist = 0;
  unsigned char d = c1 ^ c2;
  for (i = 0; i < 8; ++i)
    dist += ((d & (1 << i)) != 0);
  return dist;
}


x86 assembly (clang, -O0):
<edit_distance_c>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
movq   $0x0,-0x18(%rbp)
movzbl -0x1(%rbp),%eax
movzbl -0x2(%rbp),%ecx
xor    %ecx,%eax
mov    %al,-0x19(%rbp)
movq   $0x0,-0x10(%rbp)
cmpq   $0x8,-0x10(%rbp)
jae    1171 <edit_distance_c+0x71>
movzbl -0x19(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
cltq
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112d <edit_distance_c+0x2d>
mov    -0x18(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<edit_distance_c>:
xor    %esi,%edi
mov    %edi,%eax
and    $0x1,%eax
mov    %edi,%ecx
shr    %ecx
and    $0x1,%ecx
add    %eax,%ecx
mov    %edi,%eax
shr    $0x2,%eax
and    $0x1,%eax
add    %ecx,%eax
mov    %edi,%ecx
shr    $0x3,%ecx
and    $0x1,%ecx
add    %eax,%ecx
mov    %edi,%eax
shr    $0x4,%eax
and    $0x1,%eax
add    %ecx,%eax
mov    %edi,%ecx
shr    $0x5,%ecx
and    $0x1,%ecx
add    %eax,%ecx
mov    %edi,%eax
shr    $0x6,%eax
and    $0x1,%eax
add    %ecx,%eax
shr    $0x7,%rdi
add    %rdi,%rax
ret

LLVM IR (-O0):
define i64 @edit_distance_c(i8 zeroext %0, i8 zeroext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i64
%6 = alloca i64
%7 = alloca i8
store i8 %0, i8* %3
store i8 %1, i8* %4
store i64 0, i64* %6
%8 = load i8, i8* %3
%9 = zext i8 %8 to i32
%10 = load i8, i8* %4
%11 = zext i8 %10 to i32
%12 = xor i32 %9, %11
%13 = trunc i32 %12 to i8
store i8 %13, i8* %7
store i64 0, i64* %5
br label %14
14: ; preds = %29, %2
%15 = load i64, i64* %5
%16 = icmp ult i64 %15, 8
br i1 %16, label %17, label %32
17: ; preds = %14
%18 = load i8, i8* %7
%19 = zext i8 %18 to i32
%20 = load i64, i64* %5
%21 = trunc i64 %20 to i32
%22 = shl i32 1, %21
%23 = and i32 %19, %22
%24 = icmp ne i32 %23, 0
%25 = zext i1 %24 to i32
%26 = sext i32 %25 to i64
%27 = load i64, i64* %6
%28 = add i64 %27, %26
store i64 %28, i64* %6
br label %29
29: ; preds = %17
%30 = load i64, i64* %5
%31 = add i64 %30, 1
store i64 %31, i64* %5
br label %14
32: ; preds = %14
%33 = load i64, i64* %6
ret i64 %33
}

LLVM IR (-O2):
define i64 @edit_distance_c(i8 zeroext %0, i8 zeroext %1) {
%3 = xor i8 %1, %0
%4 = zext i8 %3 to i32
%5 = and i32 %4, 1
%6 = lshr i32 %4, 1
%7 = and i32 %6, 1
%8 = add nuw nsw i32 %5, %7
%9 = lshr i32 %4, 2
%10 = and i32 %9, 1
%11 = add nuw nsw i32 %8, %10
%12 = lshr i32 %4, 3
%13 = and i32 %12, 1
%14 = add nuw nsw i32 %11, %13
%15 = lshr i32 %4, 4
%16 = and i32 %15, 1
%17 = add nuw nsw i32 %14, %16
%18 = lshr i32 %4, 5
%19 = and i32 %18, 1
%20 = add nuw nsw i32 %17, %19
%21 = lshr i32 %4, 6
%22 = and i32 %21, 1
%23 = add nuw nsw i32 %20, %22
%24 = zext i32 %23 to i64
%25 = lshr i32 %4, 7
%26 = zext i32 %25 to i64
%27 = add nuw nsw i64 %24, %26
ret i64 %27
}