#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*/ exit(int);
void *malloc(int);
int /*<<< orphan*/ mutate(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char **reproduce(int num_children, char *parent, int length) {
  int i;
  char **children = malloc(sizeof(char *[num_children]));
  if (!children) {
    printf("Could not allocate memory\n");
    exit(1);
  }
  for (i = 0; i < num_children; i++) {
    children[i] = malloc(sizeof(char[length + 1]));
    if (!children[i]) {
      printf("Could not allocate memory\n");
      exit(1);
    }
    strncpy(children[i], parent, length + 1);
    mutate(children[i]);
  }
  return children;
}


x86 assembly (clang, -O0):
<reproduce>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1195 <reproduce+0x45>
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1229 <reproduce+0xd9>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,%eax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    11ef <reproduce+0x9f>
lea    0xe20(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
add    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <mutate@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    119c <reproduce+0x4c>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reproduce>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r13d
mov    %rsi,%r14
mov    %edi,%r12d
lea    0x0(,%r12,8),%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     11d5 <reproduce+0x85>
mov    %rax,%r15
test   %r12d,%r12d
jle    11c3 <reproduce+0x73>
add    $0x1,%r13d
mov    %r12d,%r12d
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r13d,%edi
call   1050 <malloc@plt>
mov    %rax,(%r15,%rbp,8)
test   %rax,%rax
je     11d5 <reproduce+0x85>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r13d,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   1070 <mutate@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1190 <reproduce+0x40>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe24(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"Could not allocate memory\0A\00"
define i8** @reproduce(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i32, i32* %4
%10 = zext i32 %9 to i64
%11 = mul nuw i64 8, %10
%12 = trunc i64 %11 to i32
%13 = call i8* @malloc(i32 %12)
%14 = bitcast i8* %13 to i8**
store i8** %14, i8*** %8
%15 = load i8**, i8*** %8
%16 = icmp ne i8** %15, null
br i1 %16, label %20, label %17
17: ; preds = %3
%18 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %3
store i32 0, i32* %7
br label %21
21: ; preds = %60, %20
%22 = load i32, i32* %7
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %63
25: ; preds = %21
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
%28 = zext i32 %27 to i64
%29 = trunc i64 %28 to i32
%30 = call i8* @malloc(i32 %29)
%31 = load i8**, i8*** %8
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
store i8* %30, i8** %34
%35 = load i8**, i8*** %8
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
%39 = load i8*, i8** %38
%40 = icmp ne i8* %39, null
br i1 %40, label %44, label %41
41: ; preds = %25
%42 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %25
%45 = load i8**, i8*** %8
%46 = load i32, i32* %7
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %45, i64 %47
%49 = load i8*, i8** %48
%50 = load i8*, i8** %5
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
%53 = call i32 @strncpy(i8* %49, i8* %50, i32 %52)
%54 = load i8**, i8*** %8
%55 = load i32, i32* %7
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %54, i64 %56
%58 = load i8*, i8** %57
%59 = call i32 @mutate(i8* %58)
br label %60
60: ; preds = %44
%61 = load i32, i32* %7
%62 = add nsw i32 %61, 1
store i32 %62, i32* %7
br label %21
63: ; preds = %21
%64 = load i8**, i8*** %8
ret i8** %64
}

LLVM IR (-O2):
@str.1 = [26 x i8] c"Could not allocate memory\00"
define noalias i8** @reproduce(i32 %0, i8* %1, i32 %2) {
%4 = shl i32 %0, 3
%5 = tail call i8* @malloc(i32 %4)
%6 = bitcast i8* %5 to i8**
%7 = icmp eq i8* %5, null
br i1 %7, label %13, label %8
8: ; preds = %3
%9 = icmp sgt i32 %0, 0
br i1 %9, label %10, label %29
10: ; preds = %8
%11 = add nsw i32 %2, 1
%12 = zext i32 %0 to i64
br label %16
13: ; preds = %3
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.1, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %10, %24
%17 = phi i64 [ 0, %10 ], [ %27, %24 ]
%18 = tail call i8* @malloc(i32 %11)
%19 = getelementptr inbounds i8*, i8** %6, i64 %17
store i8* %18, i8** %19
%20 = icmp eq i8* %18, null
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.1, i64 0, i64 0))
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %16
%25 = tail call i32 @strncpy(i8* %18, i8* %1, i32 %11)
%26 = tail call i32 @mutate(i8* %18)
%27 = add nuw nsw i64 %17, 1
%28 = icmp eq i64 %27, %12
br i1 %28, label %29, label %16
29: ; preds = %24, %8
ret i8** %6
}