#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(double *, double *, int);
void putSubMatrix(double *matrix, int size1, int size2, int O1, int O2,
                  double *A, int size3, int size4, int nCores) {
  int j;
  for (j = 0; j < size4; j++) {
    memcpy(&matrix[(j + O2) * size1 + O1], &A[j * size3],
           size3 * sizeof(double));
  }
}


x86 assembly (clang, -O0):
<putSubMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    0x18(%rbp),%eax
jge    1194 <putSubMatrix+0x84>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
add    -0x18(%rbp),%eax
imul   -0xc(%rbp),%eax
add    -0x14(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%eax
imul   0x10(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
movslq 0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1030 <memcpy@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113d <putSubMatrix+0x2d>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putSubMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x48(%rsp),%eax
test   %eax,%eax
jle    116a <putSubMatrix+0x5a>
mov    %r9,%r13
mov    0x40(%rsp),%r14d
movslq %r8d,%rdx
movslq %esi,%r15
movslq %ecx,%rcx
movslq %r14d,%r12
shl    $0x3,%r14d
mov    %eax,%ebx
shl    $0x3,%r12
imul   %r15,%rdx
add    %rcx,%rdx
lea    (%rdi,%rdx,8),%rbp
shl    $0x3,%r15
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r14d,%edx
call   1030 <memcpy@plt>
add    %r12,%r13
add    %r15,%rbp
add    $0xffffffffffffffff,%rbx
jne    1150 <putSubMatrix+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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