#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__ calloc(int, int);
int /*<<< orphan*/ fun(int, int, char *, int, char **, int *);
char **generateParenthesis(int n, int *returnSize) {
  int left = n, right = n;
  char line[1024] = {0};
  int lp = 0;
  char **result = (char **)calloc(sizeof(char *), 8192);
  int i;
  for (i = 0; i < 8192; i++)
    result[i] = (char *)calloc(sizeof(char), n + 1);
  *returnSize = 0;
  fun(left, right, line, lp, result, returnSize);
  return result;
}


x86 assembly (clang, -O0):
<generateParenthesis>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
movl   $0x0,-0x424(%rbp)
mov    $0x8,%edi
mov    $0x2000,%esi
call   1050 <calloc@plt>
mov    %rax,-0x430(%rbp)
movl   $0x0,-0x434(%rbp)
cmpl   $0x2000,-0x434(%rbp)
jge    11d4 <generateParenthesis+0xa4>
mov    -0x4(%rbp),%esi
add    $0x1,%esi
mov    $0x1,%edi
call   1050 <calloc@plt>
mov    %rax,%rdx
mov    -0x430(%rbp),%rax
movslq -0x434(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x434(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x434(%rbp)
jmp    118b <generateParenthesis+0x5b>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
lea    -0x420(%rbp),%rdx
mov    -0x424(%rbp),%ecx
mov    -0x430(%rbp),%r8
mov    -0x10(%rbp),%r9
call   1030 <fun@plt>
mov    -0x430(%rbp),%rax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generateParenthesis>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%r14
mov    %edi,%r15d
mov    %rsp,%rdi
xor    %ebx,%ebx
mov    $0x400,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    $0x8,%edi
mov    $0x2000,%esi
call   1050 <calloc@plt>
mov    %rax,%r12
lea    0x1(%r15),%ebp
nopl   0x0(%rax)
mov    $0x1,%edi
mov    %ebp,%esi
call   1050 <calloc@plt>
mov    %rax,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    $0x2000,%rbx
jne    1170 <generateParenthesis+0x40>
movl   $0x0,(%r14)
mov    %rsp,%rdx
mov    %r15d,%edi
mov    %r15d,%esi
xor    %ecx,%ecx
mov    %r12,%r8
mov    %r14,%r9
call   1030 <fun@plt>
mov    %r12,%rax
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8** @generateParenthesis(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [1024 x i8]
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
%11 = load i32, i32* %3
store i32 %11, i32* %5
%12 = load i32, i32* %3
store i32 %12, i32* %6
%13 = bitcast [1024 x i8]* %7 to i8*
store i32 0, i32* %8
%14 = call i64 @calloc(i32 8, i32 8192)
%15 = inttoptr i64 %14 to i8**
store i8** %15, i8*** %9
store i32 0, i32* %10
br label %16
16: ; preds = %28, %2
%17 = load i32, i32* %10
%18 = icmp slt i32 %17, 8192
br i1 %18, label %19, label %31
19: ; preds = %16
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
%22 = call i64 @calloc(i32 1, i32 %21)
%23 = inttoptr i64 %22 to i8*
%24 = load i8**, i8*** %9
%25 = load i32, i32* %10
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
store i8* %23, i8** %27
br label %28
28: ; preds = %19
%29 = load i32, i32* %10
%30 = add nsw i32 %29, 1
store i32 %30, i32* %10
br label %16
31: ; preds = %16
%32 = load i32*, i32** %4
store i32 0, i32* %32
%33 = load i32, i32* %5
%34 = load i32, i32* %6
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%36 = load i32, i32* %8
%37 = load i8**, i8*** %9
%38 = load i32*, i32** %4
%39 = call i32 @fun(i32 %33, i32 %34, i8* %35, i32 %36, i8** %37, i32* %38)
%40 = load i8**, i8*** %9
ret i8** %40
}

LLVM IR (-O2):
define i8** @generateParenthesis(i32 %0, i32* %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @calloc(i32 8, i32 8192)
%6 = inttoptr i64 %5 to i8**
%7 = add nsw i32 %0, 1
br label %8
8: ; preds = %2, %8
%9 = phi i64 [ 0, %2 ], [ %13, %8 ]
%10 = tail call i64 @calloc(i32 1, i32 %7)
%11 = inttoptr i64 %10 to i8*
%12 = getelementptr inbounds i8*, i8** %6, i64 %9
store i8* %11, i8** %12
%13 = add nuw nsw i64 %9, 1
%14 = icmp eq i64 %13, 8192
br i1 %14, label %15, label %8
15: ; preds = %8
store i32 0, i32* %1
%16 = call i32 @fun(i32 %0, i32 %0, i8* %4, i32 0, i8** %6, i32* %1)
ret i8** %6
}