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

/* Variables and functions */
void rgb24to32(const uint8_t *src, uint8_t *dst, long src_size) {
  uint8_t *dest = dst;
  const uint8_t *s = src;
  const uint8_t *end;
  end = s + src_size;
  while (s < end) {
    *dest++ = *s++;
    *dest++ = *s++;
    *dest++ = *s++;
    *dest++ = 0;
  }
}


x86 assembly (clang, -O0):
<rgb24to32>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    11c1 <rgb24to32+0xc1>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x28(%rbp)
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x20(%rbp)
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x28(%rbp)
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x20(%rbp)
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x28(%rbp)
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x20(%rbp)
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x20(%rbp)
movl   $0x0,(%rax)
jmp    1133 <rgb24to32+0x33>
pop    %rbp
ret

x86 assembly (clang, -O2):
<rgb24to32>:
test   %rdx,%rdx
jle    1134 <rgb24to32+0x34>
lea    (%rdi,%rdx,4),%rax
nopl   0x0(%rax)
mov    (%rdi),%ecx
mov    %ecx,(%rsi)
mov    0x4(%rdi),%ecx
mov    %ecx,0x4(%rsi)
mov    0x8(%rdi),%ecx
mov    %ecx,0x8(%rsi)
movl   $0x0,0xc(%rsi)
add    $0xc,%rdi
add    $0x10,%rsi
cmp    %rax,%rdi
jb     1110 <rgb24to32+0x10>
ret

LLVM IR (-O0):
define void @rgb24to32(i32* %0, i32* %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
store i32* %0, i32** %4
store i32* %1, i32** %5
store i64 %2, i64* %6
%10 = load i32*, i32** %5
store i32* %10, i32** %7
%11 = load i32*, i32** %4
store i32* %11, i32** %8
%12 = load i32*, i32** %8
%13 = load i64, i64* %6
%14 = getelementptr inbounds i32, i32* %12, i64 %13
store i32* %14, i32** %9
br label %15
15: ; preds = %19, %3
%16 = load i32*, i32** %8
%17 = load i32*, i32** %9
%18 = icmp ult i32* %16, %17
br i1 %18, label %19, label %37
19: ; preds = %15
%20 = load i32*, i32** %8
%21 = getelementptr inbounds i32, i32* %20, i32 1
store i32* %21, i32** %8
%22 = load i32, i32* %20
%23 = load i32*, i32** %7
%24 = getelementptr inbounds i32, i32* %23, i32 1
store i32* %24, i32** %7
store i32 %22, i32* %23
%25 = load i32*, i32** %8
%26 = getelementptr inbounds i32, i32* %25, i32 1
store i32* %26, i32** %8
%27 = load i32, i32* %25
%28 = load i32*, i32** %7
%29 = getelementptr inbounds i32, i32* %28, i32 1
store i32* %29, i32** %7
store i32 %27, i32* %28
%30 = load i32*, i32** %8
%31 = getelementptr inbounds i32, i32* %30, i32 1
store i32* %31, i32** %8
%32 = load i32, i32* %30
%33 = load i32*, i32** %7
%34 = getelementptr inbounds i32, i32* %33, i32 1
store i32* %34, i32** %7
store i32 %32, i32* %33
%35 = load i32*, i32** %7
%36 = getelementptr inbounds i32, i32* %35, i32 1
store i32* %36, i32** %7
store i32 0, i32* %35
br label %15
37: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @rgb24to32(i32* %0, i32* nocapture writeonly %1, i64 %2) {
%4 = getelementptr inbounds i32, i32* %0, i64 %2
%5 = icmp sgt i64 %2, 0
br i1 %5, label %6, label %20
6: ; preds = %3, %6
%7 = phi i32* [ %18, %6 ], [ %1, %3 ]
%8 = phi i32* [ %15, %6 ], [ %0, %3 ]
%9 = getelementptr inbounds i32, i32* %8, i64 1
%10 = load i32, i32* %8
%11 = getelementptr inbounds i32, i32* %7, i64 1
store i32 %10, i32* %7
%12 = getelementptr inbounds i32, i32* %8, i64 2
%13 = load i32, i32* %9
%14 = getelementptr inbounds i32, i32* %7, i64 2
store i32 %13, i32* %11
%15 = getelementptr inbounds i32, i32* %8, i64 3
%16 = load i32, i32* %12
%17 = getelementptr inbounds i32, i32* %7, i64 3
store i32 %16, i32* %14
%18 = getelementptr inbounds i32, i32* %7, i64 4
store i32 0, i32* %17
%19 = icmp ult i32* %15, %4
br i1 %19, label %6, label %20
20: ; preds = %6, %3
ret void
}