#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 /*<<< orphan*/ memmove(unsigned char *, unsigned char *, int);
void unpack_component_array(unsigned char *carray, int xbuf, int xcomp,
                            int ycomp) {
  int i;
  for (i = ycomp - 1; i > 0; i--)
    memmove(carray + (xbuf * i), carray + (xcomp * i), xcomp);
}


x86 assembly (clang, -O0):
<unpack_component_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    116e <unpack_component_array+0x5e>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
imul   -0x18(%rbp),%eax
cltq
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%eax
imul   -0x18(%rbp),%eax
cltq
add    %rax,%rsi
mov    -0x10(%rbp),%edx
call   1030 <memmove@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    112e <unpack_component_array+0x1e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unpack_component_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%ecx
jl     116e <unpack_component_array+0x5e>
mov    %edx,%r14d
mov    %ecx,%r13d
movslq %esi,%r15
movslq %edx,%r12
lea    0x1(%r13),%rbp
add    $0xffffffffffffffff,%r13
mov    %r13,%rbx
imul   %r12,%rbx
add    %rdi,%rbx
neg    %r12
imul   %r15,%r13
add    %rdi,%r13
neg    %r15
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1030 <memmove@plt>
add    $0xffffffffffffffff,%rbp
add    %r12,%rbx
add    %r15,%r13
cmp    $0x2,%rbp
ja     1150 <unpack_component_array+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @unpack_component_array(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %8
%11 = sub nsw i32 %10, 1
store i32 %11, i32* %9
br label %12
12: ; preds = %30, %4
%13 = load i32, i32* %9
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %33
15: ; preds = %12
%16 = load i8*, i8** %5
%17 = load i32, i32* %6
%18 = load i32, i32* %9
%19 = mul nsw i32 %17, %18
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %16, i64 %20
%22 = load i8*, i8** %5
%23 = load i32, i32* %7
%24 = load i32, i32* %9
%25 = mul nsw i32 %23, %24
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %22, i64 %26
%28 = load i32, i32* %7
%29 = call i32 @memmove(i8* %21, i8* %27, i32 %28)
br label %30
30: ; preds = %15
%31 = load i32, i32* %9
%32 = add nsw i32 %31, -1
store i32 %32, i32* %9
br label %12
33: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @unpack_component_array(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %3, 1
br i1 %5, label %6, label %19
6: ; preds = %4
%7 = zext i32 %3 to i64
%8 = sext i32 %1 to i64
%9 = sext i32 %2 to i64
br label %10
10: ; preds = %6, %10
%11 = phi i64 [ %7, %6 ], [ %12, %10 ]
%12 = add nsw i64 %11, -1
%13 = mul nsw i64 %12, %8
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = mul nsw i64 %12, %9
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = tail call i32 @memmove(i8* %14, i8* %16, i32 %2)
%18 = icmp ugt i64 %11, 2
br i1 %18, label %10, label %19
19: ; preds = %10, %4
ret void
}