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

/* Variables and functions */
int __SSAT(int, int);
__attribute__((always_)) uint32_t __QSUB8(uint32_t x, uint32_t y) {
  int32_t r, s, t, u;
  r = __SSAT(((((int32_t)x << 24) >> 24) - (((int32_t)y << 24) >> 24)), 8) &
      (int32_t)0x000000FF;
  s = __SSAT(((((int32_t)x << 16) >> 24) - (((int32_t)y << 16) >> 24)), 8) &
      (int32_t)0x000000FF;
  t = __SSAT(((((int32_t)x << 8) >> 24) - (((int32_t)y << 8) >> 24)), 8) &
      (int32_t)0x000000FF;
  u = __SSAT(((((int32_t)x) >> 24) - (((int32_t)y) >> 24)), 8) &
      (int32_t)0x000000FF;
  return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r)));
}


x86 assembly (clang, -O0):
<__QSUB8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,%edi
shl    $0x18,%edi
sar    $0x18,%edi
mov    -0x10(%rbp),%rax
shl    $0x18,%eax
sar    $0x18,%eax
sub    %eax,%edi
mov    $0x8,%esi
call   1030 <__SSAT@plt>
and    $0xff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,%edi
shl    $0x10,%edi
sar    $0x18,%edi
mov    -0x10(%rbp),%rax
shl    $0x10,%eax
sar    $0x18,%eax
sub    %eax,%edi
mov    $0x8,%esi
call   1030 <__SSAT@plt>
and    $0xff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,%edi
shl    $0x8,%edi
sar    $0x18,%edi
mov    -0x10(%rbp),%rax
shl    $0x8,%eax
sar    $0x18,%eax
sub    %eax,%edi
mov    $0x8,%esi
call   1030 <__SSAT@plt>
and    $0xff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,%edi
sar    $0x18,%edi
mov    -0x10(%rbp),%rax
sar    $0x18,%eax
sub    %eax,%edi
mov    $0x8,%esi
call   1030 <__SSAT@plt>
and    $0xff,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
shl    $0x18,%eax
mov    -0x1c(%rbp),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x18(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
or     -0x14(%rbp),%eax
cltq
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__QSUB8>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
movsbl %bl,%edi
movsbl %r14b,%eax
sub    %eax,%edi
mov    $0x8,%esi
call   1030 <__SSAT@plt>
movzbl %al,%r12d
mov    %ebx,%eax
shr    $0x8,%eax
movsbl %al,%edi
mov    %r14d,%eax
shr    $0x8,%eax
movsbl %al,%eax
sub    %eax,%edi
mov    $0x8,%esi
call   1030 <__SSAT@plt>
mov    %eax,%ebp
mov    %ebx,%eax
shr    $0x10,%eax
movsbl %al,%edi
mov    %r14d,%eax
shr    $0x10,%eax
movsbl %al,%eax
sub    %eax,%edi
mov    $0x8,%esi
call   1030 <__SSAT@plt>
mov    %eax,%r15d
sar    $0x18,%ebx
sar    $0x18,%r14d
sub    %r14d,%ebx
mov    %ebx,%edi
mov    $0x8,%esi
call   1030 <__SSAT@plt>
shl    $0x18,%eax
movzbl %r15b,%ecx
shl    $0x10,%ecx
or     %eax,%ecx
shl    $0x8,%ebp
movzwl %bp,%eax
or     %ecx,%eax
or     %r12d,%eax
cltq
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i64 @__QSUB8(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i64 %0, i64* %3
store i64 %1, i64* %4
%9 = load i64, i64* %3
%10 = trunc i64 %9 to i32
%11 = shl i32 %10, 24
%12 = ashr i32 %11, 24
%13 = load i64, i64* %4
%14 = trunc i64 %13 to i32
%15 = shl i32 %14, 24
%16 = ashr i32 %15, 24
%17 = sub nsw i32 %12, %16
%18 = call i32 @__SSAT(i32 %17, i32 8)
%19 = and i32 %18, 255
store i32 %19, i32* %5
%20 = load i64, i64* %3
%21 = trunc i64 %20 to i32
%22 = shl i32 %21, 16
%23 = ashr i32 %22, 24
%24 = load i64, i64* %4
%25 = trunc i64 %24 to i32
%26 = shl i32 %25, 16
%27 = ashr i32 %26, 24
%28 = sub nsw i32 %23, %27
%29 = call i32 @__SSAT(i32 %28, i32 8)
%30 = and i32 %29, 255
store i32 %30, i32* %6
%31 = load i64, i64* %3
%32 = trunc i64 %31 to i32
%33 = shl i32 %32, 8
%34 = ashr i32 %33, 24
%35 = load i64, i64* %4
%36 = trunc i64 %35 to i32
%37 = shl i32 %36, 8
%38 = ashr i32 %37, 24
%39 = sub nsw i32 %34, %38
%40 = call i32 @__SSAT(i32 %39, i32 8)
%41 = and i32 %40, 255
store i32 %41, i32* %7
%42 = load i64, i64* %3
%43 = trunc i64 %42 to i32
%44 = ashr i32 %43, 24
%45 = load i64, i64* %4
%46 = trunc i64 %45 to i32
%47 = ashr i32 %46, 24
%48 = sub nsw i32 %44, %47
%49 = call i32 @__SSAT(i32 %48, i32 8)
%50 = and i32 %49, 255
store i32 %50, i32* %8
%51 = load i32, i32* %8
%52 = shl i32 %51, 24
%53 = load i32, i32* %7
%54 = shl i32 %53, 16
%55 = or i32 %52, %54
%56 = load i32, i32* %6
%57 = shl i32 %56, 8
%58 = or i32 %55, %57
%59 = load i32, i32* %5
%60 = or i32 %58, %59
%61 = sext i32 %60 to i64
ret i64 %61
}

LLVM IR (-O2):
define i64 @__QSUB8(i64 %0, i64 %1) {
%3 = trunc i64 %0 to i32
%4 = shl i32 %3, 24
%5 = ashr exact i32 %4, 24
%6 = trunc i64 %1 to i32
%7 = shl i32 %6, 24
%8 = ashr exact i32 %7, 24
%9 = sub nsw i32 %5, %8
%10 = tail call i32 @__SSAT(i32 %9, i32 8)
%11 = and i32 %10, 255
%12 = shl i32 %3, 16
%13 = ashr i32 %12, 24
%14 = shl i32 %6, 16
%15 = ashr i32 %14, 24
%16 = sub nsw i32 %13, %15
%17 = tail call i32 @__SSAT(i32 %16, i32 8)
%18 = shl i32 %3, 8
%19 = ashr i32 %18, 24
%20 = shl i32 %6, 8
%21 = ashr i32 %20, 24
%22 = sub nsw i32 %19, %21
%23 = tail call i32 @__SSAT(i32 %22, i32 8)
%24 = ashr i32 %3, 24
%25 = ashr i32 %6, 24
%26 = sub nsw i32 %24, %25
%27 = tail call i32 @__SSAT(i32 %26, i32 8)
%28 = shl i32 %27, 24
%29 = shl i32 %23, 16
%30 = and i32 %29, 16711680
%31 = or i32 %28, %30
%32 = shl i32 %17, 8
%33 = and i32 %32, 65280
%34 = or i32 %31, %33
%35 = or i32 %34, %11
%36 = sext i32 %35 to i64
ret i64 %36
}