#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*/ free(char *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ memcpy(char *, char const *, size_t);
void allocate_length_test_data(char **buf1, char **buf2, size_t buf_len,
                               const char *buf1_prefix,
                               size_t buf1_prefix_len) {
  if (NULL != *buf1)
    free(*buf1);
  if (NULL != *buf2)
    free(*buf2);
  *buf1 = (char *)malloc(buf_len + buf1_prefix_len);
  *buf2 = (char *)malloc(buf_len);
  if ((NULL == buf1) || (NULL == buf2))
    return;
  memcpy(*buf1, buf1_prefix, buf1_prefix_len);
  for (size_t i = 0; i < buf_len; i += 64) {
    size_t bytes_to_copy = buf_len - i;
    if (64 < bytes_to_copy)
      bytes_to_copy = 64;
    memcpy(*buf1 + i + buf1_prefix_len,
           "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-",
           bytes_to_copy);
    memcpy(*buf2 + i,
           "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-",
           bytes_to_copy);
  }
}


x86 assembly (clang, -O0):
<allocate_length_test_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rcx
xor    %eax,%eax
cmp    (%rcx),%rax
je     1167 <allocate_length_test_data+0x37>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmp    (%rcx),%rax
je     1182 <allocate_length_test_data+0x52>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
add    -0x28(%rbp),%rdi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rdi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
xor    %eax,%eax
cmp    -0x8(%rbp),%rax
je     11c4 <allocate_length_test_data+0x94>
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    11c9 <allocate_length_test_data+0x99>
jmp    1261 <allocate_length_test_data+0x131>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <memcpy@plt>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1261 <allocate_length_test_data+0x131>
mov    -0x18(%rbp),%rax
sub    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x40,%eax
cmp    -0x38(%rbp),%rax
jae    1216 <allocate_length_test_data+0xe6>
movq   $0x40,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
add    -0x30(%rbp),%rdi
add    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xdd0(%rip),%rsi
call   1040 <memcpy@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
add    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xdb5(%rip),%rsi
call   1040 <memcpy@plt>
mov    -0x30(%rbp),%rax
add    $0x40,%rax
mov    %rax,-0x30(%rbp)
jmp    11e5 <allocate_length_test_data+0xb5>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<allocate_length_test_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%r12
mov    %rcx,%r14
mov    %rdx,%rbp
mov    %rsi,%r15
mov    %rdi,%r13
mov    (%rdi),%rdi
test   %rdi,%rdi
je     115a <allocate_length_test_data+0x2a>
call   1030 <free@plt>
mov    (%r15),%rdi
test   %rdi,%rdi
je     1167 <allocate_length_test_data+0x37>
call   1030 <free@plt>
lea    (%r12,%rbp,1),%rdi
call   1050 <malloc@plt>
mov    %rax,0x0(%r13)
mov    %rbp,%rdi
call   1050 <malloc@plt>
mov    %rax,(%r15)
mov    0x0(%r13),%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1040 <memcpy@plt>
test   %rbp,%rbp
mov    %r15,0x10(%rsp)
mov    %rbp,0x8(%rsp)
je     11f6 <allocate_length_test_data+0xc6>
xor    %r14d,%r14d
lea    0xe59(%rip),%rbx
mov    0x8(%rsp),%rbp
mov    %rbp,%r15
nop
sub    $0x40,%r15
mov    $0x40,%edx
cmovae %rdx,%rbp
mov    0x0(%r13),%rdi
add    %r12,%rdi
add    %r14,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1040 <memcpy@plt>
mov    0x10(%rsp),%rax
mov    (%rax),%rdi
add    %r14,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1040 <memcpy@plt>
add    $0x40,%r14
mov    %r15,%rbp
cmp    0x8(%rsp),%r14
jb     11b0 <allocate_length_test_data+0x80>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [65 x i8] c"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-\00"
define void @allocate_length_test_data(i8** %0, i8** %1, i64 %2, i8* %3, i64 %4) {
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
store i8** %0, i8*** %6
store i8** %1, i8*** %7
store i64 %2, i64* %8
store i8* %3, i8** %9
store i64 %4, i64* %10
%13 = load i8**, i8*** %6
%14 = load i8*, i8** %13
%15 = icmp ne i8* null, %14
br i1 %15, label %16, label %20
16: ; preds = %5
%17 = load i8**, i8*** %6
%18 = load i8*, i8** %17
%19 = call i32 @free(i8* %18)
br label %20
20: ; preds = %16, %5
%21 = load i8**, i8*** %7
%22 = load i8*, i8** %21
%23 = icmp ne i8* null, %22
br i1 %23, label %24, label %28
24: ; preds = %20
%25 = load i8**, i8*** %7
%26 = load i8*, i8** %25
%27 = call i32 @free(i8* %26)
br label %28
28: ; preds = %24, %20
%29 = load i64, i64* %8
%30 = load i64, i64* %10
%31 = add i64 %29, %30
%32 = call i64 @malloc(i64 %31)
%33 = inttoptr i64 %32 to i8*
%34 = load i8**, i8*** %6
store i8* %33, i8** %34
%35 = load i64, i64* %8
%36 = call i64 @malloc(i64 %35)
%37 = inttoptr i64 %36 to i8*
%38 = load i8**, i8*** %7
store i8* %37, i8** %38
%39 = load i8**, i8*** %6
%40 = icmp eq i8** null, %39
br i1 %40, label %44, label %41
41: ; preds = %28
%42 = load i8**, i8*** %7
%43 = icmp eq i8** null, %42
br i1 %43, label %44, label %45
44: ; preds = %41, %28
br label %80
45: ; preds = %41
%46 = load i8**, i8*** %6
%47 = load i8*, i8** %46
%48 = load i8*, i8** %9
%49 = load i64, i64* %10
%50 = call i32 @memcpy(i8* %47, i8* %48, i64 %49)
store i64 0, i64* %11
br label %51
51: ; preds = %77, %45
%52 = load i64, i64* %11
%53 = load i64, i64* %8
%54 = icmp ult i64 %52, %53
br i1 %54, label %55, label %80
55: ; preds = %51
%56 = load i64, i64* %8
%57 = load i64, i64* %11
%58 = sub i64 %56, %57
store i64 %58, i64* %12
%59 = load i64, i64* %12
%60 = icmp ult i64 64, %59
br i1 %60, label %61, label %62
61: ; preds = %55
store i64 64, i64* %12
br label %62
62: ; preds = %61, %55
%63 = load i8**, i8*** %6
%64 = load i8*, i8** %63
%65 = load i64, i64* %11
%66 = getelementptr inbounds i8, i8* %64, i64 %65
%67 = load i64, i64* %10
%68 = getelementptr inbounds i8, i8* %66, i64 %67
%69 = load i64, i64* %12
%70 = call i32 @memcpy(i8* %68, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i64 %69)
%71 = load i8**, i8*** %7
%72 = load i8*, i8** %71
%73 = load i64, i64* %11
%74 = getelementptr inbounds i8, i8* %72, i64 %73
%75 = load i64, i64* %12
%76 = call i32 @memcpy(i8* %74, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i64 %75)
br label %77
77: ; preds = %62
%78 = load i64, i64* %11
%79 = add i64 %78, 64
store i64 %79, i64* %11
br label %51
80: ; preds = %44, %51
ret void
}

LLVM IR (-O2):
@.str = [65 x i8] c"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-\00"
define void @allocate_length_test_data(i8** nocapture %0, i8** nocapture %1, i64 %2, i8* %3, i64 %4) {
%6 = load i8*, i8** %0
%7 = icmp eq i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 @free(i8* %6)
br label %10
10: ; preds = %8, %5
%11 = load i8*, i8** %1
%12 = icmp eq i8* %11, null
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 @free(i8* %11)
br label %15
15: ; preds = %13, %10
%16 = add i64 %4, %2
%17 = tail call i64 @malloc(i64 %16)
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %0
%19 = tail call i64 @malloc(i64 %2)
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %1
%21 = load i8*, i8** %0
%22 = tail call i32 @memcpy(i8* %21, i8* %3, i64 %4)
%23 = icmp eq i64 %2, 0
br i1 %23, label %38, label %24
24: ; preds = %15, %24
%25 = phi i64 [ %36, %24 ], [ 0, %15 ]
%26 = sub i64 %2, %25
%27 = icmp ult i64 %26, 64
%28 = select i1 %27, i64 %26, i64 64
%29 = load i8*, i8** %0
%30 = getelementptr inbounds i8, i8* %29, i64 %4
%31 = getelementptr inbounds i8, i8* %30, i64 %25
%32 = tail call i32 @memcpy(i8* %31, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i64 %28)
%33 = load i8*, i8** %1
%34 = getelementptr inbounds i8, i8* %33, i64 %25
%35 = tail call i32 @memcpy(i8* %34, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i64 %28)
%36 = add i64 %25, 64
%37 = icmp ult i64 %36, %2
br i1 %37, label %24, label %38
38: ; preds = %24, %15
ret void
}