#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*/ FreeStringArray(char **, int const);
char **malloc(int const);
char **SafeInitialiseStringArray_m(char **output, const int mainSizeOutput,
                                   const int mainSize) {
  if (output != NULL) {
    FreeStringArray(output, mainSizeOutput);
  }
  output = malloc(mainSize * sizeof(char *));
  int i = 0;
  for (i = 0; i < mainSize; i++) {
    output[i] = NULL;
  }
  return output;
}


x86 assembly (clang, -O0):
<SafeInitialiseStringArray_m>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1149 <SafeInitialiseStringArray_m+0x29>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <FreeStringArray@plt>
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1194 <SafeInitialiseStringArray_m+0x74>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116a <SafeInitialiseStringArray_m+0x4a>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SafeInitialiseStringArray_m>:
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
test   %rdi,%rdi
je     1140 <SafeInitialiseStringArray_m+0x10>
call   1030 <FreeStringArray@plt>
lea    0x0(,%rbx,8),%edi
call   1050 <malloc@plt>
mov    %rax,%r14
test   %ebx,%ebx
jle    1163 <SafeInitialiseStringArray_m+0x33>
mov    %ebx,%edx
shl    $0x3,%rdx
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8** @SafeInitialiseStringArray_m(i8** %0, i32 %1, i32 %2) {
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8** %0, i8*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i8**, i8*** %4
%9 = icmp ne i8** %8, null
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = load i8**, i8*** %4
%12 = load i32, i32* %5
%13 = call i32 @FreeStringArray(i8** %11, i32 %12)
br label %14
14: ; preds = %10, %3
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = mul i64 %16, 8
%18 = trunc i64 %17 to i32
%19 = call i8** @malloc(i32 %18)
store i8** %19, i8*** %4
store i32 0, i32* %7
store i32 0, i32* %7
br label %20
20: ; preds = %29, %14
%21 = load i32, i32* %7
%22 = load i32, i32* %6
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %32
24: ; preds = %20
%25 = load i8**, i8*** %4
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
store i8* null, i8** %28
br label %29
29: ; preds = %24
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %20
32: ; preds = %20
%33 = load i8**, i8*** %4
ret i8** %33
}

LLVM IR (-O2):
define noalias i8** @SafeInitialiseStringArray_m(i8** %0, i32 %1, i32 %2) {
%4 = icmp eq i8** %0, null
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = tail call i32 @FreeStringArray(i8** %0, i32 %1)
br label %7
7: ; preds = %5, %3
%8 = shl i32 %2, 3
%9 = tail call i8** @malloc(i32 %8)
%10 = icmp sgt i32 %2, 0
br i1 %10, label %11, label %15
11: ; preds = %7
%12 = bitcast i8** %9 to i8*
%13 = zext i32 %2 to i64
%14 = shl nuw nsw i64 %13, 3
br label %15
15: ; preds = %11, %7
ret i8** %9
}