#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*/ memcpy(int *, int *, size_t const);
void memcpy_imatrix(int **dst, int **const src, const size_t nrow,
                    const size_t ncol) {
  for (size_t i = 0; i < nrow; i++) {
    memcpy(dst[i], src[i], ncol * sizeof(int));
  }
}


x86 assembly (clang, -O0):
<memcpy_imatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1174 <memcpy_imatrix+0x64>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x20(%rbp),%rdx
shl    $0x2,%rdx
call   1030 <memcpy@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1130 <memcpy_imatrix+0x20>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memcpy_imatrix>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %rdx,%rdx
je     1149 <memcpy_imatrix+0x39>
mov    %rcx,%r14
mov    %rdx,%r13
mov    %rsi,%r15
mov    %rdi,%r12
shl    $0x2,%r14
xor    %ebx,%ebx
mov    (%r12,%rbx,8),%rdi
mov    (%r15,%rbx,8),%rsi
mov    %r14,%rdx
call   1030 <memcpy@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1130 <memcpy_imatrix+0x20>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @memcpy_imatrix(i32** nocapture %0, i32** nocapture %1, i64 %2, i64 %3) {
%5 = icmp eq i64 %2, 0
br i1 %5, label %8, label %6
6: ; preds = %4
%7 = shl i64 %3, 2
br label %9
8: ; preds = %9, %4
ret void
9: ; preds = %6, %9
%10 = phi i64 [ 0, %6 ], [ %16, %9 ]
%11 = getelementptr inbounds i32*, i32** %0, i64 %10
%12 = load i32*, i32** %11
%13 = getelementptr inbounds i32*, i32** %1, i64 %10
%14 = load i32*, i32** %13
%15 = tail call i32 @memcpy(i32* %12, i32* %14, i64 %7)
%16 = add nuw i64 %10, 1
%17 = icmp eq i64 %16, %2
br i1 %17, label %8, label %9
}