#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 */
int premul_nozero(unsigned int, unsigned char);
void argb32p_rgb32_inplace(unsigned int *dest, unsigned int *src) {
  unsigned char alpha = *src >> 24;
  if (alpha == 0x00) {
  } else if (alpha == 0xFF) {
    *dest = *src;
  } else {
    alpha = 0xff - alpha;
    *dest = ((premul_nozero(*dest, alpha) & 0xFFFFFF) + *src) | 0xFF000000;
  }
}


x86 assembly (clang, -O0):
<argb32p_rgb32_inplace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
shr    $0x18,%eax
mov    %al,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0x0,%eax
jne    113e <argb32p_rgb32_inplace+0x2e>
jmp    119a <argb32p_rgb32_inplace+0x8a>
movzbl -0x11(%rbp),%eax
cmp    $0xff,%eax
jne    115e <argb32p_rgb32_inplace+0x4e>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
jmp    1195 <argb32p_rgb32_inplace+0x85>
movzbl -0x11(%rbp),%ecx
mov    $0xff,%eax
sub    %ecx,%eax
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
movzbl -0x11(%rbp),%esi
call   1030 <premul_nozero@plt>
mov    %eax,%ecx
and    $0xffffff,%ecx
mov    -0x10(%rbp),%rax
add    (%rax),%ecx
or     $0xff000000,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
jmp    119a <argb32p_rgb32_inplace+0x8a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<argb32p_rgb32_inplace>:
push   %r14
push   %rbx
push   %rax
mov    (%rsi),%eax
cmp    $0x1000000,%eax
jb     1147 <argb32p_rgb32_inplace+0x37>
mov    %rdi,%r14
mov    %eax,%ecx
shr    $0x18,%ecx
cmp    $0xff,%ecx
je     1144 <argb32p_rgb32_inplace+0x34>
mov    %rsi,%rbx
not    %cl
mov    (%r14),%edi
movzbl %cl,%esi
call   1030 <premul_nozero@plt>
add    (%rbx),%eax
or     $0xff000000,%eax
mov    %eax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @argb32p_rgb32_inplace(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i8
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = load i32*, i32** %4
%7 = load i32, i32* %6
%8 = lshr i32 %7, 24
%9 = trunc i32 %8 to i8
store i8 %9, i8* %5
%10 = load i8, i8* %5
%11 = zext i8 %10 to i32
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %2
br label %38
14: ; preds = %2
%15 = load i8, i8* %5
%16 = zext i8 %15 to i32
%17 = icmp eq i32 %16, 255
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i32*, i32** %4
%20 = load i32, i32* %19
%21 = load i32*, i32** %3
store i32 %20, i32* %21
br label %37
22: ; preds = %14
%23 = load i8, i8* %5
%24 = zext i8 %23 to i32
%25 = sub nsw i32 255, %24
%26 = trunc i32 %25 to i8
store i8 %26, i8* %5
%27 = load i32*, i32** %3
%28 = load i32, i32* %27
%29 = load i8, i8* %5
%30 = call i32 @premul_nozero(i32 %28, i8 zeroext %29)
%31 = and i32 %30, 16777215
%32 = load i32*, i32** %4
%33 = load i32, i32* %32
%34 = add i32 %31, %33
%35 = or i32 %34, -16777216
%36 = load i32*, i32** %3
store i32 %35, i32* %36
br label %37
37: ; preds = %22, %18
br label %38
38: ; preds = %37, %13
ret void
}

LLVM IR (-O2):
define void @argb32p_rgb32_inplace(i32* nocapture %0, i32* nocapture %1) {
%3 = load i32, i32* %1
%4 = lshr i32 %3, 24
%5 = icmp ult i32 %3, 16777216
br i1 %5, label %18, label %6
6: ; preds = %2
%7 = icmp eq i32 %4, 255
br i1 %7, label %16, label %8
8: ; preds = %6
%9 = trunc i32 %4 to i8
%10 = xor i8 %9, -1
%11 = load i32, i32* %0
%12 = tail call i32 @premul_nozero(i32 %11, i8 zeroext %10)
%13 = load i32, i32* %1
%14 = add i32 %13, %12
%15 = or i32 %14, -16777216
br label %16
16: ; preds = %6, %8
%17 = phi i32 [ %15, %8 ], [ %3, %6 ]
store i32 %17, i32* %0
br label %18
18: ; preds = %16, %2
ret void
}