#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 */
char **malloc(int);
int /*<<< orphan*/ memcpy(char **, char **, size_t);
char **__array_concat_at_begin(void *v1, void *v2, int length) {
  char *first_text = (char *)v1;
  char **following_texts = (char **)v2;
  char **all_texts = malloc(sizeof(char *) * (length + 1));
  size_t char_ptr_size = sizeof(char *);
  *all_texts = first_text;
  memcpy(all_texts + 1, following_texts, char_ptr_size * length);
  return all_texts;
}


x86 assembly (clang, -O0):
<__array_concat_at_begin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x30(%rbp)
movq   $0x8,-0x38(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rdi
add    $0x8,%rdi
mov    -0x28(%rbp),%rsi
mov    -0x38(%rbp),%rdx
movslq -0x14(%rbp),%rax
imul   %rax,%rdx
call   1030 <memcpy@plt>
mov    -0x30(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__array_concat_at_begin>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edx,%r12d
mov    %rsi,%r14
mov    %rdi,%r15
lea    0x8(,%r12,8),%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %r15,(%rax)
lea    0x8(%rax),%rdi
movslq %r12d,%rdx
shl    $0x3,%rdx
mov    %r14,%rsi
call   1030 <memcpy@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8** @__array_concat_at_begin(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8**
%9 = alloca i8**
%10 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%11 = load i8*, i8** %4
store i8* %11, i8** %7
%12 = load i8*, i8** %5
%13 = bitcast i8* %12 to i8**
store i8** %13, i8*** %8
%14 = load i32, i32* %6
%15 = add nsw i32 %14, 1
%16 = sext i32 %15 to i64
%17 = mul i64 8, %16
%18 = trunc i64 %17 to i32
%19 = call i8** @malloc(i32 %18)
store i8** %19, i8*** %9
store i64 8, i64* %10
%20 = load i8*, i8** %7
%21 = load i8**, i8*** %9
store i8* %20, i8** %21
%22 = load i8**, i8*** %9
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8**, i8*** %8
%25 = load i64, i64* %10
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = mul i64 %25, %27
%29 = call i32 @memcpy(i8** %23, i8** %24, i64 %28)
%30 = load i8**, i8*** %9
ret i8** %30
}

LLVM IR (-O2):
define i8** @__array_concat_at_begin(i8* %0, i8* %1, i32 %2) {
%4 = bitcast i8* %1 to i8**
%5 = shl i32 %2, 3
%6 = add i32 %5, 8
%7 = tail call i8** @malloc(i32 %6)
store i8* %0, i8** %7
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = sext i32 %2 to i64
%10 = shl nsw i64 %9, 3
%11 = tail call i32 @memcpy(i8** %8, i8** %4, i64 %10)
ret i8** %7
}