#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;
typedef int uint;
struct osd_rle_elem_s {
  int dummy;
};
struct osd_clut_s {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ rle_palette_to_rgba(int /*<<< orphan*/ *,
                                       struct osd_clut_s const *, int);
int /*<<< orphan*/ rle_uncompress_u32(int /*<<< orphan*/ *, int, int, int,
                                      struct osd_rle_elem_s const *, int,
                                      int /*<<< orphan*/ *);
void rle_uncompress_rgba(uint32_t *dst, uint w, uint h, uint stride,
                         const struct osd_rle_elem_s *rle_data, uint num_rle,
                         const struct osd_clut_s *palette,
                         uint palette_entries) {
  uint32_t lut[256] = {0};
  if (palette_entries > 256)
    return;
  rle_palette_to_rgba(lut, palette, palette_entries);
  rle_uncompress_u32(dst, w, h, stride, rle_data, num_rle, lut);
}


x86 assembly (clang, -O0):
<rle_uncompress_rgba>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
lea    -0x430(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
cmpl   $0x100,0x18(%rbp)
jle    117c <rle_uncompress_rgba+0x4c>
jmp    11b4 <rle_uncompress_rgba+0x84>
lea    -0x430(%rbp),%rdi
mov    0x10(%rbp),%rsi
mov    0x18(%rbp),%edx
call   1040 <rle_palette_to_rgba@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%r8
mov    -0x24(%rbp),%r9d
lea    -0x430(%rbp),%rax
mov    %rax,(%rsp)
call   1030 <rle_uncompress_u32@plt>
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rle_uncompress_rgba>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    %r9d,0x14(%rsp)
mov    %r8,0x18(%rsp)
mov    %ecx,%r12d
mov    %edx,%r13d
mov    %esi,%ebp
mov    %rdi,%rbx
mov    0x468(%rsp),%r15d
lea    0x20(%rsp),%r14
mov    $0x400,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
cmp    $0x100,%r15d
jg     11ac <rle_uncompress_rgba+0x7c>
mov    0x460(%rsp),%rsi
mov    %r14,%rdi
mov    %r15d,%edx
call   1040 <rle_palette_to_rgba@plt>
mov    %r14,(%rsp)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    0x18(%rsp),%r8
mov    0x14(%rsp),%r9d
call   1030 <rle_uncompress_u32@plt>
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.osd_rle_elem_s = type { i32 }
%struct.osd_clut_s = type { i32 }
define void @rle_uncompress_rgba(i32* %0, i32 %1, i32 %2, i32 %3, %struct.osd_rle_elem_s* %4, i32 %5, %struct.osd_clut_s* %6, i32 %7) {
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca %struct.osd_rle_elem_s*
%14 = alloca i32
%15 = alloca %struct.osd_clut_s*
%16 = alloca i32
%17 = alloca [256 x i32]
store i32* %0, i32** %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store %struct.osd_rle_elem_s* %4, %struct.osd_rle_elem_s** %13
store i32 %5, i32* %14
store %struct.osd_clut_s* %6, %struct.osd_clut_s** %15
store i32 %7, i32* %16
%18 = bitcast [256 x i32]* %17 to i8*
%19 = load i32, i32* %16
%20 = icmp sgt i32 %19, 256
br i1 %20, label %21, label %22
21: ; preds = %8
br label %35
22: ; preds = %8
%23 = getelementptr inbounds [256 x i32], [256 x i32]* %17, i64 0, i64 0
%24 = load %struct.osd_clut_s*, %struct.osd_clut_s** %15
%25 = load i32, i32* %16
%26 = call i32 @rle_palette_to_rgba(i32* %23, %struct.osd_clut_s* %24, i32 %25)
%27 = load i32*, i32** %9
%28 = load i32, i32* %10
%29 = load i32, i32* %11
%30 = load i32, i32* %12
%31 = load %struct.osd_rle_elem_s*, %struct.osd_rle_elem_s** %13
%32 = load i32, i32* %14
%33 = getelementptr inbounds [256 x i32], [256 x i32]* %17, i64 0, i64 0
%34 = call i32 @rle_uncompress_u32(i32* %27, i32 %28, i32 %29, i32 %30, %struct.osd_rle_elem_s* %31, i32 %32, i32* %33)
br label %35
35: ; preds = %22, %21
ret void
}

LLVM IR (-O2):
%struct.osd_rle_elem_s = type { i32 }
%struct.osd_clut_s = type { i32 }
define void @rle_uncompress_rgba(i32* %0, i32 %1, i32 %2, i32 %3, %struct.osd_rle_elem_s* %4, i32 %5, %struct.osd_clut_s* %6, i32 %7) {
%9 = alloca [256 x i32]
%10 = bitcast [256 x i32]* %9 to i8*
%11 = icmp sgt i32 %7, 256
br i1 %11, label %16, label %12
12: ; preds = %8
%13 = getelementptr inbounds [256 x i32], [256 x i32]* %9, i64 0, i64 0
%14 = call i32 @rle_palette_to_rgba(i32* %13, %struct.osd_clut_s* %6, i32 %7)
%15 = call i32 @rle_uncompress_u32(i32* %0, i32 %1, i32 %2, i32 %3, %struct.osd_rle_elem_s* %4, i32 %5, i32* %13)
br label %16
16: ; preds = %8, %12
ret void
}