#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(char *, char *, unsigned int);
int /*<<< orphan*/ vector_insert_make_room(char **, unsigned int, unsigned int,
                                           unsigned int, unsigned int);
void vector_insert_array(char **data, unsigned int *size,
                         unsigned int data_size, char *array,
                         unsigned int length, unsigned int position) {
  vector_insert_make_room(data, *size, data_size, length, position);
  memcpy(*data + position * data_size, array, length * data_size);
  *size += length;
}


x86 assembly (clang, -O0):
<vector_insert_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x14(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
call   1040 <vector_insert_make_room@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,%eax
add    %rax,%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
imul   -0x14(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vector_insert_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%ebx
mov    %r8d,%r15d
mov    %rcx,%r14
mov    %edx,%ebp
mov    %rsi,%r12
mov    %rdi,%r13
mov    (%rsi),%esi
mov    %r8d,%ecx
mov    %r9d,%r8d
call   1040 <vector_insert_make_room@plt>
imul   %ebp,%ebx
add    0x0(%r13),%rbx
imul   %r15d,%ebp
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1030 <memcpy@plt>
add    %r15d,(%r12)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @vector_insert_array(i8** %0, i32* %1, i32 %2, i8* %3, i32 %4, i32 %5) {
%7 = alloca i8**
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
store i8** %0, i8*** %7
store i32* %1, i32** %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%13 = load i8**, i8*** %7
%14 = load i32*, i32** %8
%15 = load i32, i32* %14
%16 = load i32, i32* %9
%17 = load i32, i32* %11
%18 = load i32, i32* %12
%19 = call i32 @vector_insert_make_room(i8** %13, i32 %15, i32 %16, i32 %17, i32 %18)
%20 = load i8**, i8*** %7
%21 = load i8*, i8** %20
%22 = load i32, i32* %12
%23 = load i32, i32* %9
%24 = mul i32 %22, %23
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %21, i64 %25
%27 = load i8*, i8** %10
%28 = load i32, i32* %11
%29 = load i32, i32* %9
%30 = mul i32 %28, %29
%31 = call i32 @memcpy(i8* %26, i8* %27, i32 %30)
%32 = load i32, i32* %11
%33 = load i32*, i32** %8
%34 = load i32, i32* %33
%35 = add i32 %34, %32
store i32 %35, i32* %33
ret void
}

LLVM IR (-O2):
define void @vector_insert_array(i8** %0, i32* nocapture %1, i32 %2, i8* %3, i32 %4, i32 %5) {
%7 = load i32, i32* %1
%8 = tail call i32 @vector_insert_make_room(i8** %0, i32 %7, i32 %2, i32 %4, i32 %5)
%9 = load i8*, i8** %0
%10 = mul i32 %5, %2
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = mul i32 %4, %2
%14 = tail call i32 @memcpy(i8* %12, i8* %3, i32 %13)
%15 = load i32, i32* %1
%16 = add i32 %15, %4
store i32 %16, i32* %1
ret void
}