#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 labs(long);
int Color_distance2(long c1, long c2) {
  return (labs((c1 & 0x0000ff) - (c2 & 0x0000ff)) >= 0x000060) +
         (labs((c1 & 0x00ff00) - (c2 & 0x00ff00)) >= 0x006000) +
         (labs((c1 & 0xff0000) - (c2 & 0xff0000)) >= 0x600000);
}


x86 assembly (clang, -O0):
<Color_distance2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
and    $0xff,%rdi
mov    -0x10(%rbp),%rax
and    $0xff,%rax
sub    %rax,%rdi
call   1030 <labs@plt>
cmp    $0x60,%eax
setge  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
and    $0xff00,%rdi
mov    -0x10(%rbp),%rax
and    $0xff00,%rax
sub    %rax,%rdi
call   1030 <labs@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    $0x6000,%ecx
setge  %cl
and    $0x1,%cl
movzbl %cl,%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
and    $0xff0000,%rdi
mov    -0x10(%rbp),%rax
and    $0xff0000,%rax
sub    %rax,%rdi
call   1030 <labs@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    $0x600000,%ecx
setge  %cl
and    $0x1,%cl
movzbl %cl,%ecx
add    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Color_distance2>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movzbl %bl,%edi
movzbl %r14b,%eax
sub    %rax,%rdi
call   1030 <labs@plt>
xor    %r15d,%r15d
cmp    $0x60,%eax
setge  %r15b
mov    %ebx,%edi
and    $0xff00,%edi
mov    %r14d,%eax
and    $0xff00,%eax
sub    %rax,%rdi
call   1030 <labs@plt>
xor    %ebp,%ebp
cmp    $0x6000,%eax
setge  %bpl
add    %r15d,%ebp
and    $0xff0000,%ebx
and    $0xff0000,%r14d
sub    %r14,%rbx
mov    %rbx,%rdi
call   1030 <labs@plt>
xor    %ecx,%ecx
cmp    $0x600000,%eax
setge  %cl
add    %ebp,%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @Color_distance2(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%5 = load i64, i64* %3
%6 = and i64 %5, 255
%7 = load i64, i64* %4
%8 = and i64 %7, 255
%9 = sub nsw i64 %6, %8
%10 = call i32 @labs(i64 %9)
%11 = icmp sge i32 %10, 96
%12 = zext i1 %11 to i32
%13 = load i64, i64* %3
%14 = and i64 %13, 65280
%15 = load i64, i64* %4
%16 = and i64 %15, 65280
%17 = sub nsw i64 %14, %16
%18 = call i32 @labs(i64 %17)
%19 = icmp sge i32 %18, 24576
%20 = zext i1 %19 to i32
%21 = add nsw i32 %12, %20
%22 = load i64, i64* %3
%23 = and i64 %22, 16711680
%24 = load i64, i64* %4
%25 = and i64 %24, 16711680
%26 = sub nsw i64 %23, %25
%27 = call i32 @labs(i64 %26)
%28 = icmp sge i32 %27, 6291456
%29 = zext i1 %28 to i32
%30 = add nsw i32 %21, %29
ret i32 %30
}

LLVM IR (-O2):
define i32 @Color_distance2(i64 %0, i64 %1) {
%3 = and i64 %0, 255
%4 = and i64 %1, 255
%5 = sub nsw i64 %3, %4
%6 = tail call i32 @labs(i64 %5)
%7 = icmp sgt i32 %6, 95
%8 = zext i1 %7 to i32
%9 = and i64 %0, 65280
%10 = and i64 %1, 65280
%11 = sub nsw i64 %9, %10
%12 = tail call i32 @labs(i64 %11)
%13 = icmp sgt i32 %12, 24575
%14 = zext i1 %13 to i32
%15 = add nuw nsw i32 %14, %8
%16 = and i64 %0, 16711680
%17 = and i64 %1, 16711680
%18 = sub nsw i64 %16, %17
%19 = tail call i32 @labs(i64 %18)
%20 = icmp sgt i32 %19, 6291455
%21 = zext i1 %20 to i32
%22 = add nuw nsw i32 %15, %21
ret i32 %22
}