#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 */
unsigned int max(unsigned int, unsigned int);
unsigned int min(unsigned int, unsigned int);
unsigned int vabsdiffu2(unsigned int a, unsigned int b) {
  unsigned int r, s;
  unsigned int t, u, v;
  s = a & 0x0000ffff;
  r = b & 0x0000ffff;
  u = max(r, s);
  v = min(r, s);
  s = a & 0xffff0000;
  r = b & 0xffff0000;
  t = max(r, s);
  s = min(r, s);
  r = u | t;
  s = v | s;
  r = r - s;
  return r;
}


x86 assembly (clang, -O0):
<vabsdiffu2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0xffff,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
and    $0xffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <max@plt>
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <min@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
and    $0xffff0000,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
and    $0xffff0000,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <max@plt>
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <min@plt>
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
or     -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x1c(%rbp),%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vabsdiffu2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r13d
mov    %edi,%ebp
movzwl %bp,%r14d
movzwl %r13w,%r15d
mov    %r15d,%edi
mov    %r14d,%esi
call   1040 <max@plt>
mov    %eax,%r12d
mov    %r15d,%edi
mov    %r14d,%esi
call   1030 <min@plt>
mov    %eax,%r14d
and    $0xffff0000,%ebp
and    $0xffff0000,%r13d
mov    %r13d,%edi
mov    %ebp,%esi
call   1040 <max@plt>
mov    %eax,%ebx
mov    %r13d,%edi
mov    %ebp,%esi
call   1030 <min@plt>
or     %r12d,%ebx
or     %r14d,%eax
sub    %eax,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @vabsdiffu2(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%10 = load i32, i32* %3
%11 = and i32 %10, 65535
store i32 %11, i32* %6
%12 = load i32, i32* %4
%13 = and i32 %12, 65535
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = call i32 @max(i32 %14, i32 %15)
store i32 %16, i32* %8
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = call i32 @min(i32 %17, i32 %18)
store i32 %19, i32* %9
%20 = load i32, i32* %3
%21 = and i32 %20, -65536
store i32 %21, i32* %6
%22 = load i32, i32* %4
%23 = and i32 %22, -65536
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = load i32, i32* %6
%26 = call i32 @max(i32 %24, i32 %25)
store i32 %26, i32* %7
%27 = load i32, i32* %5
%28 = load i32, i32* %6
%29 = call i32 @min(i32 %27, i32 %28)
store i32 %29, i32* %6
%30 = load i32, i32* %8
%31 = load i32, i32* %7
%32 = or i32 %30, %31
store i32 %32, i32* %5
%33 = load i32, i32* %9
%34 = load i32, i32* %6
%35 = or i32 %33, %34
store i32 %35, i32* %6
%36 = load i32, i32* %5
%37 = load i32, i32* %6
%38 = sub i32 %36, %37
store i32 %38, i32* %5
%39 = load i32, i32* %5
ret i32 %39
}

LLVM IR (-O2):
define i32 @vabsdiffu2(i32 %0, i32 %1) {
%3 = and i32 %0, 65535
%4 = and i32 %1, 65535
%5 = tail call i32 @max(i32 %4, i32 %3)
%6 = tail call i32 @min(i32 %4, i32 %3)
%7 = and i32 %0, -65536
%8 = and i32 %1, -65536
%9 = tail call i32 @max(i32 %8, i32 %7)
%10 = tail call i32 @min(i32 %8, i32 %7)
%11 = or i32 %9, %5
%12 = or i32 %10, %6
%13 = sub i32 %11, %12
ret i32 %13
}