#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(unsigned int *, unsigned int *, unsigned int);
scalar_t__ rax_malloc(unsigned int);
unsigned int **copyBitVectors(int numberOfTrees,
                              unsigned int *vectorLengthPerTree,
                              unsigned int **originalBitVectors) {
  unsigned int **bitVectors =
      (unsigned int **)rax_malloc(sizeof(unsigned int *) * numberOfTrees);
  int i = 0;
  for (i = 0; i < numberOfTrees; i++) {
    bitVectors[i] = (unsigned int *)rax_malloc(vectorLengthPerTree[i] *
                                               sizeof(unsigned int));
    memcpy(bitVectors[i], originalBitVectors[i],
           vectorLengthPerTree[i] * sizeof(unsigned int));
  }
  return bitVectors;
}


x86 assembly (clang, -O0):
<copyBitVectors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <rax_malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11c1 <copyBitVectors+0xa1>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <rax_malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
shl    $0x2,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1154 <copyBitVectors+0x34>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copyBitVectors>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r13
mov    %edi,%r12d
lea    0x0(,%r12,8),%edi
call   1030 <rax_malloc@plt>
mov    %rax,%r15
test   %r12d,%r12d
jle    117e <copyBitVectors+0x5e>
mov    %r12d,%r12d
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    0x0(%r13,%rbx,4),%edi
shl    $0x2,%edi
call   1030 <rax_malloc@plt>
mov    %rax,(%r15,%rbx,8)
mov    (%r14,%rbx,8),%rsi
mov    0x0(%r13,%rbx,4),%edx
shl    $0x2,%edx
mov    %rax,%rdi
call   1040 <memcpy@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1150 <copyBitVectors+0x30>
mov    %r15,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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