#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 getSubMatrix(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(&A[j * size3], &matrix[(j + O2) * size1 + O1],
           size3 * sizeof(double));
  }
}


x86 assembly (clang, -O0):
<getSubMatrix>:
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 <getSubMatrix+0x84>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%eax
imul   0x10(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x24(%rbp),%eax
add    -0x18(%rbp),%eax
imul   -0xc(%rbp),%eax
add    -0x14(%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 <getSubMatrix+0x2d>
add    $0x30,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define void @getSubMatrix(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** %15
%26 = load i32, i32* %19
%27 = load i32, i32* %16
%28 = mul nsw i32 %26, %27
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %25, i64 %29
%31 = load double*, double** %10
%32 = load i32, i32* %19
%33 = load i32, i32* %14
%34 = add nsw i32 %32, %33
%35 = load i32, i32* %11
%36 = mul nsw i32 %34, %35
%37 = load i32, i32* %13
%38 = add nsw i32 %36, %37
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %31, 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* %30, 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 @getSubMatrix(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 %6 to i64
%14 = sext i32 %4 to i64
%15 = sext i32 %1 to i64
%16 = sext i32 %3 to i64
%17 = zext i32 %7 to i64
br label %18
18: ; preds = %11, %18
%19 = phi i64 [ 0, %11 ], [ %27, %18 ]
%20 = mul nsw i64 %19, %13
%21 = getelementptr inbounds double, double* %5, i64 %20
%22 = add nsw i64 %19, %14
%23 = mul nsw i64 %22, %15
%24 = add nsw i64 %23, %16
%25 = getelementptr inbounds double, double* %0, i64 %24
%26 = tail call i32 @memcpy(double* %21, 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
}