#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*/ assert(int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char const *, unsigned int);
void copy_plane(unsigned char *dest, unsigned dest_stride,
                const unsigned char *src, unsigned src_stride, unsigned length,
                unsigned rows) {
  unsigned i;
  assert(dest_stride >= length);
  assert(src_stride >= length);
  for (i = 0; i < rows; ++i)
    memcpy(&dest[dest_stride * i], &src[src_stride * i], length);
}


x86 assembly (clang, -O0):
<copy_plane>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x20(%rbp),%eax
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jae    11ad <copy_plane+0x8d>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
imul   -0x28(%rbp),%eax
mov    %eax,%eax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%eax
imul   -0x28(%rbp),%eax
mov    %eax,%eax
add    %rax,%rsi
mov    -0x20(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    116b <copy_plane+0x4b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy_plane>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%ebp
mov    %r8d,%ebx
mov    %ecx,%r15d
mov    %rdx,0x10(%rsp)
mov    %esi,%r13d
mov    %rdi,0x8(%rsp)
xor    %edi,%edi
cmp    %r8d,%esi
setae  %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmp    %ebx,%r15d
setae  %dil
call   1030 <assert@plt>
test   %ebp,%ebp
je     1193 <copy_plane+0x73>
mov    %ebp,%ebp
xor    %r14d,%r14d
xor    %r12d,%r12d
nopl   0x0(%rax)
mov    %r14d,%edi
add    0x8(%rsp),%rdi
mov    %r12d,%esi
add    0x10(%rsp),%rsi
mov    %ebx,%edx
call   1040 <memcpy@plt>
add    %r15d,%r12d
add    %r13d,%r14d
add    $0xffffffffffffffff,%rbp
jne    1170 <copy_plane+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @copy_plane(i8* %0, i32 %1, i8* %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%14 = load i32, i32* %8
%15 = load i32, i32* %11
%16 = icmp uge i32 %14, %15
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i32, i32* %10
%20 = load i32, i32* %11
%21 = icmp uge i32 %19, %20
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
store i32 0, i32* %13
br label %24
24: ; preds = %43, %6
%25 = load i32, i32* %13
%26 = load i32, i32* %12
%27 = icmp ult i32 %25, %26
br i1 %27, label %28, label %46
28: ; preds = %24
%29 = load i8*, i8** %7
%30 = load i32, i32* %8
%31 = load i32, i32* %13
%32 = mul i32 %30, %31
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %29, i64 %33
%35 = load i8*, i8** %9
%36 = load i32, i32* %10
%37 = load i32, i32* %13
%38 = mul i32 %36, %37
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %35, i64 %39
%41 = load i32, i32* %11
%42 = call i32 @memcpy(i8* %34, i8* %40, i32 %41)
br label %43
43: ; preds = %28
%44 = load i32, i32* %13
%45 = add i32 %44, 1
store i32 %45, i32* %13
br label %24
46: ; preds = %24
ret void
}

LLVM IR (-O2):
define void @copy_plane(i8* %0, i32 %1, i8* %2, i32 %3, i32 %4, i32 %5) {
%7 = icmp uge i32 %1, %4
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = icmp uge i32 %3, %4
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = icmp eq i32 %5, 0
br i1 %13, label %28, label %14
14: ; preds = %6
%15 = zext i32 %5 to i64
br label %16
16: ; preds = %14, %16
%17 = phi i64 [ 0, %14 ], [ %26, %16 ]
%18 = trunc i64 %17 to i32
%19 = mul i32 %18, %1
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %0, i64 %20
%22 = mul i32 %18, %3
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %2, i64 %23
%25 = tail call i32 @memcpy(i8* %21, i8* %24, i32 %4)
%26 = add nuw nsw i64 %17, 1
%27 = icmp eq i64 %26, %15
br i1 %27, label %28, label %16
28: ; preds = %16, %6
ret void
}