#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 /*<<< orphan*/ uint32_t;

/* Variables and functions */
unsigned int pack_rgba(int /*<<< orphan*/, int /*<<< orphan*/,
                       int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ pixel_get_a(int /*<<< orphan*/);
int /*<<< orphan*/ pixel_get_b(int /*<<< orphan*/);
int /*<<< orphan*/ pixel_get_g(int /*<<< orphan*/);
int /*<<< orphan*/ pixel_get_r(int /*<<< orphan*/);
int draw_block4x4_argb8(const unsigned char *bitstring,
                        unsigned int *image_buffer, int flags) {
  uint32_t pixel = *(uint32_t *)&bitstring[0];
  image_buffer[0] = pack_rgba(pixel_get_a(pixel), pixel_get_r(pixel),
                              pixel_get_g(pixel), pixel_get_b(pixel));
  return 1;
}


x86 assembly (clang, -O0):
<draw_block4x4_argb8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1060 <pixel_get_a@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <pixel_get_r@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%edi
call   1050 <pixel_get_g@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <pixel_get_b@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    %eax,%ecx
call   1070 <pack_rgba@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_block4x4_argb8>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    (%rdi),%ebp
mov    %ebp,%edi
call   1060 <pixel_get_a@plt>
mov    %eax,%r15d
mov    %ebp,%edi
call   1030 <pixel_get_r@plt>
mov    %eax,%r12d
mov    %ebp,%edi
call   1050 <pixel_get_g@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1040 <pixel_get_b@plt>
mov    %r15d,%edi
mov    %r12d,%esi
mov    %ebx,%edx
mov    %eax,%ecx
call   1070 <pack_rgba@plt>
mov    %eax,(%r14)
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @draw_block4x4_argb8(i8* %0, i32* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%8 = load i8*, i8** %4
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = bitcast i8* %9 to i32*
%11 = load i32, i32* %10
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = call i32 @pixel_get_a(i32 %12)
%14 = load i32, i32* %7
%15 = call i32 @pixel_get_r(i32 %14)
%16 = load i32, i32* %7
%17 = call i32 @pixel_get_g(i32 %16)
%18 = load i32, i32* %7
%19 = call i32 @pixel_get_b(i32 %18)
%20 = call i32 @pack_rgba(i32 %13, i32 %15, i32 %17, i32 %19)
%21 = load i32*, i32** %5
%22 = getelementptr inbounds i32, i32* %21, i64 0
store i32 %20, i32* %22
ret i32 1
}

LLVM IR (-O2):
define i32 @draw_block4x4_argb8(i8* nocapture %0, i32* nocapture writeonly %1, i32 %2) {
%4 = bitcast i8* %0 to i32*
%5 = load i32, i32* %4
%6 = tail call i32 @pixel_get_a(i32 %5)
%7 = tail call i32 @pixel_get_r(i32 %5)
%8 = tail call i32 @pixel_get_g(i32 %5)
%9 = tail call i32 @pixel_get_b(i32 %5)
%10 = tail call i32 @pack_rgba(i32 %6, i32 %7, i32 %8, i32 %9)
store i32 %10, i32* %1
ret i32 1
}