#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
char *readStringRet(char *, int);
char **readStringArrayRet(char headerMessage[], char elementMessage[],
                          int elementAmount, int stringLength) {
  printf("%s", headerMessage);
  char **strings = (char **)malloc(elementAmount * stringLength * sizeof(char));
  int i;
  for (i = 0; i < elementAmount; i++) {
    *(strings + i) = readStringRet(elementMessage, stringLength);
  }
  return strings;
}


x86 assembly (clang, -O0):
<readStringArrayRet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11aa <readStringArrayRet+0x7a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1050 <readStringRet@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1175 <readStringArrayRet+0x45>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readStringArrayRet>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r12d
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%rsi
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
mov    %r12d,%edi
imul   %r15d,%edi
call   1040 <malloc@plt>
mov    %rax,%r13
test   %r15d,%r15d
jle    1189 <readStringArrayRet+0x59>
mov    %r15d,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r12d,%esi
call   1050 <readStringRet@plt>
mov    %rax,0x0(%r13,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1170 <readStringArrayRet+0x40>
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define i8** @readStringArrayRet(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i8*, i8** %5
%12 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i32, i32* %7
%14 = load i32, i32* %8
%15 = mul nsw i32 %13, %14
%16 = sext i32 %15 to i64
%17 = mul i64 %16, 1
%18 = trunc i64 %17 to i32
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i8**
store i8** %20, i8*** %9
store i32 0, i32* %10
br label %21
21: ; preds = %33, %4
%22 = load i32, i32* %10
%23 = load i32, i32* %7
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %36
25: ; preds = %21
%26 = load i8*, i8** %6
%27 = load i32, i32* %8
%28 = call i8* @readStringRet(i8* %26, i32 %27)
%29 = load i8**, i8*** %9
%30 = load i32, i32* %10
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
store i8* %28, i8** %32
br label %33
33: ; preds = %25
%34 = load i32, i32* %10
%35 = add nsw i32 %34, 1
store i32 %35, i32* %10
br label %21
36: ; preds = %21
%37 = load i8**, i8*** %9
ret i8** %37
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i8** @readStringArrayRet(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = mul nsw i32 %3, %2
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i8**
%9 = icmp sgt i32 %2, 0
br i1 %9, label %10, label %18
10: ; preds = %4
%11 = zext i32 %2 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 0, %10 ], [ %16, %12 ]
%14 = tail call i8* @readStringRet(i8* %1, i32 %3)
%15 = getelementptr inbounds i8*, i8** %8, i64 %13
store i8* %14, i8** %15
%16 = add nuw nsw i64 %13, 1
%17 = icmp eq i64 %16, %11
br i1 %17, label %18, label %12
18: ; preds = %12, %4
ret i8** %8
}