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

/* Variables and functions */
uint32_t rosprite_cmyk_to_rgb(uint32_t cmyk) {
  uint8_t c = cmyk & 0xff;
  uint8_t m = (cmyk & 0xff00) >> 8;
  uint8_t y = (cmyk & 0xff0000) >> 16;
  uint8_t k = cmyk >> 24;
  uint8_t C = c + k;
  uint8_t M = m + k;
  uint8_t Y = y + k;
  uint8_t r = 255 - C;
  uint8_t g = 255 - M;
  uint8_t b = 255 - Y;
  return r << 24 | g << 16 | b << 8;
}


x86 assembly (clang, -O0):
<rosprite_cmyk_to_rgb>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff00,%eax
sar    $0x8,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff0000,%eax
sar    $0x10,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x18,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    $0xff,%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    $0xff,%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    $0xff,%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%eax
shl    $0x18,%eax
mov    -0x28(%rbp),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x2c(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<rosprite_cmyk_to_rgb>:
mov    %edi,%ecx
movzbl %ch,%eax
mov    %edi,%edx
sar    $0x18,%edx
lea    (%rcx,%rdx,1),%esi
shr    $0x10,%ecx
movzbl %cl,%ecx
add    %edx,%eax
add    %ecx,%edx
shl    $0x18,%esi
xor    $0xff000000,%esi
shl    $0x10,%eax
mov    $0xff0000,%ecx
sub    %eax,%ecx
or     %esi,%ecx
shl    $0x8,%edx
mov    $0xff00,%eax
sub    %edx,%eax
or     %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @rosprite_cmyk_to_rgb(i32 %0) {
%2 = lshr i32 %0, 8
%3 = and i32 %2, 255
%4 = lshr i32 %0, 16
%5 = and i32 %4, 255
%6 = ashr i32 %0, 24
%7 = add i32 %6, %0
%8 = add nsw i32 %3, %6
%9 = add nsw i32 %5, %6
%10 = mul i32 %7, -16777216
%11 = add i32 %10, -16777216
%12 = mul nsw i32 %8, -65536
%13 = add nsw i32 %12, 16711680
%14 = or i32 %13, %11
%15 = mul nsw i32 %9, -256
%16 = add nsw i32 %15, 65280
%17 = or i32 %14, %16
ret i32 %17
}