#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 */
typedef int /*<<< orphan*/ tmp;
typedef int /*<<< orphan*/ mpfr_t;
typedef int /*<<< orphan*/ mpfr_prec_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ m_clear(int /*<<< orphan*/);
int /*<<< orphan*/ m_init2(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ *malloc(size_t const);
int /*<<< orphan*/ stderr;
void createArray(mpfr_t **result, const size_t n, mpfr_prec_t precision) {
  mpfr_t tmp;
  m_init2(tmp, precision);
  (*result) = malloc(n * sizeof(tmp));
  if ((*result) == NULL) {
    fprintf(stderr, "Error - unable to allocate required memory\n");
  } else {
    for (size_t i = 0; i < n; ++i) {
      m_init2((*result)[i], precision);
    }
  }
  m_clear(tmp);
}


x86 assembly (clang, -O0):
<createArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1060 <m_init2@plt>
mov    -0x10(%rbp),%rdi
shl    $0x2,%rdi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    119d <createArray+0x5d>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
lea    0xe6d(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11df <createArray+0x9f>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11da <createArray+0x9a>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x14(%rbp),%esi
call   1060 <m_init2@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11a5 <createArray+0x65>
jmp    11df <createArray+0x9f>
mov    -0x18(%rbp),%edi
call   1050 <m_clear@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createArray>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %edx,%esi
call   1060 <m_init2@plt>
lea    0x0(,%rbx,4),%rdi
call   1040 <malloc@plt>
mov    %rax,(%r14)
test   %rax,%rax
je     11a9 <createArray+0x69>
test   %rbx,%rbx
je     11be <createArray+0x7e>
mov    (%rax),%edi
mov    %r15d,%esi
call   1060 <m_init2@plt>
cmp    $0x1,%rbx
je     11be <createArray+0x7e>
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    (%r14),%rax
mov    (%rax,%rbp,4),%edi
mov    %r15d,%esi
call   1060 <m_init2@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1190 <createArray+0x50>
jmp    11be <createArray+0x7e>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
lea    0xe47(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <m_clear@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [44 x i8] c"Error - unable to allocate required memory\0A\00"
define void @createArray(i32** %0, i64 %1, i32 %2) {
%4 = alloca i32**
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
store i32** %0, i32*** %4
store i64 %1, i64* %5
store i32 %2, i32* %6
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = call i32 @m_init2(i32 %9, i32 %10)
%12 = load i64, i64* %5
%13 = mul i64 %12, 4
%14 = call i32* @malloc(i64 %13)
%15 = load i32**, i32*** %4
store i32* %14, i32** %15
%16 = load i32**, i32*** %4
%17 = load i32*, i32** %16
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %22
19: ; preds = %3
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %39
22: ; preds = %3
store i64 0, i64* %8
br label %23
23: ; preds = %35, %22
%24 = load i64, i64* %8
%25 = load i64, i64* %5
%26 = icmp ult i64 %24, %25
br i1 %26, label %27, label %38
27: ; preds = %23
%28 = load i32**, i32*** %4
%29 = load i32*, i32** %28
%30 = load i64, i64* %8
%31 = getelementptr inbounds i32, i32* %29, i64 %30
%32 = load i32, i32* %31
%33 = load i32, i32* %6
%34 = call i32 @m_init2(i32 %32, i32 %33)
br label %35
35: ; preds = %27
%36 = load i64, i64* %8
%37 = add i64 %36, 1
store i64 %37, i64* %8
br label %23
38: ; preds = %23
br label %39
39: ; preds = %38, %19
%40 = load i32, i32* %7
%41 = call i32 @m_clear(i32 %40)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [44 x i8] c"Error - unable to allocate required memory\0A\00"
define void @createArray(i32** nocapture %0, i64 %1, i32 %2) {
%4 = tail call i32 @m_init2(i32 undef, i32 %2)
%5 = shl i64 %1, 2
%6 = tail call i32* @malloc(i64 %5)
store i32* %6, i32** %0
%7 = icmp eq i32* %6, null
br i1 %7, label %14, label %8
8: ; preds = %3
%9 = icmp eq i64 %1, 0
br i1 %9, label %25, label %10
10: ; preds = %8
%11 = load i32, i32* %6
%12 = tail call i32 @m_init2(i32 %11, i32 %2)
%13 = icmp eq i64 %1, 1
br i1 %13, label %25, label %17
14: ; preds = %3
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %25
17: ; preds = %10, %17
%18 = phi i64 [ %23, %17 ], [ 1, %10 ]
%19 = load i32*, i32** %0
%20 = getelementptr inbounds i32, i32* %19, i64 %18
%21 = load i32, i32* %20
%22 = tail call i32 @m_init2(i32 %21, i32 %2)
%23 = add nuw i64 %18, 1
%24 = icmp eq i64 %23, %1
br i1 %24, label %25, label %17
25: ; preds = %17, %10, %8, %14
%26 = tail call i32 @m_clear(i32 undef)
ret void
}