#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;

/* Variables and functions */
int abs(int);
int yuv_diff(uint32_t yuv1, uint32_t yuv2) {
  return (
      (abs((int)((yuv1 & 0x00FF0000) - (yuv2 & 0x00FF0000))) > 0x00300000) ||
      (abs((int)((yuv1 & 0x0000FF00) - (yuv2 & 0x0000FF00))) > 0x00000700) ||
      (abs((int)((yuv1 & 0x000000FF) - (yuv2 & 0x000000FF))) > 0x00000006));
}


x86 assembly (clang, -O0):
<yuv_diff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
and    $0xff0000,%edi
mov    -0x8(%rbp),%eax
and    $0xff0000,%eax
sub    %eax,%edi
call   1030 <abs@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x300000,%ecx
mov    %al,-0x9(%rbp)
jg     1195 <yuv_diff+0x85>
mov    -0x4(%rbp),%edi
and    $0xff00,%edi
mov    -0x8(%rbp),%eax
and    $0xff00,%eax
sub    %eax,%edi
call   1030 <abs@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x700,%ecx
mov    %al,-0x9(%rbp)
jg     1195 <yuv_diff+0x85>
mov    -0x4(%rbp),%edi
and    $0xff,%edi
mov    -0x8(%rbp),%eax
and    $0xff,%eax
sub    %eax,%edi
call   1030 <abs@plt>
cmp    $0x6,%eax
setg   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yuv_diff>:
mov    %edi,%eax
and    $0xff0000,%eax
mov    %esi,%ecx
and    $0xff0000,%ecx
sub    %ecx,%eax
mov    %eax,%ecx
neg    %ecx
cmovs  %eax,%ecx
mov    $0x1,%eax
cmp    $0x300000,%ecx
ja     115f <yuv_diff+0x5f>
mov    %edi,%ecx
and    $0xff00,%ecx
mov    %esi,%edx
and    $0xff00,%edx
sub    %edx,%ecx
mov    %ecx,%edx
neg    %edx
cmovs  %ecx,%edx
cmp    $0x700,%edx
ja     115f <yuv_diff+0x5f>
movzbl %dil,%eax
movzbl %sil,%ecx
sub    %ecx,%eax
mov    %eax,%ecx
neg    %ecx
cmovs  %eax,%ecx
xor    %eax,%eax
cmp    $0x7,%ecx
setae  %al
ret

LLVM IR (-O0):
define i32 @yuv_diff(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = and i32 %5, 16711680
%7 = load i32, i32* %4
%8 = and i32 %7, 16711680
%9 = sub nsw i32 %6, %8
%10 = call i32 @abs(i32 %9)
%11 = icmp sgt i32 %10, 3145728
br i1 %11, label %28, label %12
12: ; preds = %2
%13 = load i32, i32* %3
%14 = and i32 %13, 65280
%15 = load i32, i32* %4
%16 = and i32 %15, 65280
%17 = sub nsw i32 %14, %16
%18 = call i32 @abs(i32 %17)
%19 = icmp sgt i32 %18, 1792
br i1 %19, label %28, label %20
20: ; preds = %12
%21 = load i32, i32* %3
%22 = and i32 %21, 255
%23 = load i32, i32* %4
%24 = and i32 %23, 255
%25 = sub nsw i32 %22, %24
%26 = call i32 @abs(i32 %25)
%27 = icmp sgt i32 %26, 6
br label %28
28: ; preds = %20, %12, %2
%29 = phi i1 [ true, %12 ], [ true, %2 ], [ %27, %20 ]
%30 = zext i1 %29 to i32
ret i32 %30
}

LLVM IR (-O2):
define i32 @yuv_diff(i32 %0, i32 %1) {
%3 = and i32 %0, 16711680
%4 = and i32 %1, 16711680
%5 = sub nsw i32 %3, %4
%6 = tail call i32 @llvm.abs.i32(i32 %5, i1 true)
%7 = icmp ugt i32 %6, 3145728
br i1 %7, label %21, label %8
8: ; preds = %2
%9 = and i32 %0, 65280
%10 = and i32 %1, 65280
%11 = sub nsw i32 %9, %10
%12 = tail call i32 @llvm.abs.i32(i32 %11, i1 true)
%13 = icmp ugt i32 %12, 1792
br i1 %13, label %21, label %14
14: ; preds = %8
%15 = and i32 %0, 255
%16 = and i32 %1, 255
%17 = sub nsw i32 %15, %16
%18 = tail call i32 @llvm.abs.i32(i32 %17, i1 true)
%19 = icmp ugt i32 %18, 6
%20 = zext i1 %19 to i32
br label %21
21: ; preds = %14, %8, %2
%22 = phi i32 [ 1, %8 ], [ 1, %2 ], [ %20, %14 ]
ret i32 %22
}