#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 */
typedef int uint32_t;
typedef int int32_t;

/* Variables and functions */
int32_t ColorComp(const void *pvA, const void *pvB) {
  int32_t ui32A, ui32B;
  ui32A = ((30 * ((*(uint32_t *)pvA >> 16) & 255)) +
           (59 * ((*(uint32_t *)pvA >> 8) & 255)) +
           (11 * (*(uint32_t *)pvA & 255)));
  ui32B = ((30 * ((*(uint32_t *)pvB >> 16) & 255)) +
           (59 * ((*(uint32_t *)pvB >> 8) & 255)) +
           (11 * (*(uint32_t *)pvB & 255)));
  return (ui32A - ui32B);
}


x86 assembly (clang, -O0):
<ColorComp>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
sar    $0x10,%eax
and    $0xff,%eax
imul   $0x1e,%eax,%eax
mov    -0x8(%rbp),%rcx
mov    (%rcx),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
imul   $0x3b,%ecx,%ecx
add    %ecx,%eax
mov    -0x8(%rbp),%rcx
mov    (%rcx),%ecx
and    $0xff,%ecx
imul   $0xb,%ecx,%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
sar    $0x10,%eax
and    $0xff,%eax
imul   $0x1e,%eax,%eax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
imul   $0x3b,%ecx,%ecx
add    %ecx,%eax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%ecx
and    $0xff,%ecx
imul   $0xb,%ecx,%ecx
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ColorComp>:
push   %rbx
mov    (%rdi),%ecx
movzbl %ch,%eax
movzbl %cl,%edx
shr    $0x10,%ecx
movzbl %cl,%edi
mov    (%rsi),%ecx
movzbl %ch,%ebx
movzbl %cl,%esi
shr    $0x10,%ecx
movzbl %cl,%ecx
sub    %ecx,%edi
sub    %esi,%edx
mov    %edi,%ecx
shl    $0x5,%ecx
sub    %edi,%ecx
sub    %edi,%ecx
sub    %ebx,%eax
imul   $0x3b,%eax,%esi
lea    (%rdx,%rdx,4),%eax
lea    (%rdx,%rax,2),%eax
add    %ecx,%eax
add    %esi,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @ColorComp(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = bitcast i8* %7 to i32*
%9 = load i32, i32* %8
%10 = ashr i32 %9, 16
%11 = and i32 %10, 255
%12 = mul nsw i32 30, %11
%13 = load i8*, i8** %3
%14 = bitcast i8* %13 to i32*
%15 = load i32, i32* %14
%16 = ashr i32 %15, 8
%17 = and i32 %16, 255
%18 = mul nsw i32 59, %17
%19 = add nsw i32 %12, %18
%20 = load i8*, i8** %3
%21 = bitcast i8* %20 to i32*
%22 = load i32, i32* %21
%23 = and i32 %22, 255
%24 = mul nsw i32 11, %23
%25 = add nsw i32 %19, %24
store i32 %25, i32* %5
%26 = load i8*, i8** %4
%27 = bitcast i8* %26 to i32*
%28 = load i32, i32* %27
%29 = ashr i32 %28, 16
%30 = and i32 %29, 255
%31 = mul nsw i32 30, %30
%32 = load i8*, i8** %4
%33 = bitcast i8* %32 to i32*
%34 = load i32, i32* %33
%35 = ashr i32 %34, 8
%36 = and i32 %35, 255
%37 = mul nsw i32 59, %36
%38 = add nsw i32 %31, %37
%39 = load i8*, i8** %4
%40 = bitcast i8* %39 to i32*
%41 = load i32, i32* %40
%42 = and i32 %41, 255
%43 = mul nsw i32 11, %42
%44 = add nsw i32 %38, %43
store i32 %44, i32* %6
%45 = load i32, i32* %5
%46 = load i32, i32* %6
%47 = sub nsw i32 %45, %46
ret i32 %47
}

LLVM IR (-O2):
define i32 @ColorComp(i8* nocapture %0, i8* nocapture %1) {
%3 = bitcast i8* %0 to i32*
%4 = load i32, i32* %3
%5 = lshr i32 %4, 16
%6 = and i32 %5, 255
%7 = lshr i32 %4, 8
%8 = and i32 %7, 255
%9 = and i32 %4, 255
%10 = bitcast i8* %1 to i32*
%11 = load i32, i32* %10
%12 = lshr i32 %11, 16
%13 = and i32 %12, 255
%14 = lshr i32 %11, 8
%15 = and i32 %14, 255
%16 = and i32 %11, 255
%17 = sub nsw i32 %6, %13
%18 = mul nsw i32 %17, 30
%19 = sub nsw i32 %8, %15
%20 = mul nsw i32 %19, 59
%21 = sub nsw i32 %9, %16
%22 = mul nsw i32 %21, 11
%23 = add nsw i32 %18, %22
%24 = add nsw i32 %23, %20
ret i32 %24
}