#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 */
double *allocate_double_1D(int);
double **allocate_double_2D_AP(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
double **allocate_s_double_LT(int n_X) {
  int i, total = n_X * (n_X + 1) / 2;
  double **pointerarray = allocate_double_2D_AP(n_X);
  if (pointerarray == NULL) {
    fprintf(stderr, "PE: Memory allocation fails!\n");
    exit(1);
  }
  pointerarray[0] = allocate_double_1D(total);
  if (pointerarray[0] == NULL) {
    fprintf(stderr, "PE: Memory allocation fails!\n");
    exit(1);
  }
  for (i = 0; i < total; i++) {
    pointerarray[0][i] = 0.0;
  }
  for (i = 1; i < n_X; i++) {
    pointerarray[i] = pointerarray[i - 1] + i;
  }
  return (pointerarray);
}


x86 assembly (clang, -O0):
<allocate_s_double_LT>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <allocate_double_2D_AP@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1198 <allocate_s_double_LT+0x58>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
lea    0xe77(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0xc(%rbp),%edi
call   1040 <allocate_double_1D@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11d7 <allocate_s_double_LT+0x97>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
lea    0xe38(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    120b <allocate_s_double_LT+0xcb>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movslq -0x8(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11de <allocate_s_double_LT+0x9e>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1254 <allocate_s_double_LT+0x114>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1212 <allocate_s_double_LT+0xd2>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<allocate_s_double_LT>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r15d
call   1070 <allocate_double_2D_AP@plt>
test   %rax,%rax
je     12ae <allocate_s_double_LT+0x15e>
mov    %rax,%r14
lea    0x1(%r15),%ebp
imul   %r15d,%ebp
mov    %ebp,%r12d
shr    $0x1f,%r12d
add    %ebp,%r12d
sar    %r12d
mov    %r12d,%edi
call   1050 <allocate_double_1D@plt>
mov    %rax,(%r14)
test   %rax,%rax
je     12ae <allocate_s_double_LT+0x15e>
mov    %rax,%rbx
cmp    $0x2,%ebp
jl     11b3 <allocate_s_double_LT+0x63>
add    $0xffffffff,%r12d
lea    0x8(,%r12,8),%rdx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
cmp    $0x2,%r15d
jl     12a2 <allocate_s_double_LT+0x152>
mov    %r15d,%esi
lea    -0x1(%rsi),%rdx
add    $0xfffffffffffffffe,%rsi
mov    %edx,%eax
and    $0x7,%eax
mov    $0x1,%ecx
cmp    $0x7,%rsi
jb     1281 <allocate_s_double_LT+0x131>
and    $0xfffffffffffffff8,%rdx
neg    %rdx
mov    $0x8,%ecx
nopl   0x0(%rax,%rax,1)
lea    (%rbx,%rcx,8),%rsi
lea    (%rbx,%rcx,8),%rdi
add    $0xffffffffffffffc8,%rdi
mov    %rdi,-0x38(%r14,%rcx,8)
lea    -0x38(%rsi,%rcx,8),%rdi
lea    -0x68(%rsi,%rcx,8),%rsi
mov    %rsi,-0x30(%r14,%rcx,8)
lea    -0x30(%rdi,%rcx,8),%rsi
lea    -0x58(%rdi,%rcx,8),%rdi
mov    %rdi,-0x28(%r14,%rcx,8)
lea    -0x28(%rsi,%rcx,8),%rdi
lea    -0x48(%rsi,%rcx,8),%rsi
mov    %rsi,-0x20(%r14,%rcx,8)
lea    -0x20(%rdi,%rcx,8),%rsi
lea    -0x38(%rdi,%rcx,8),%rdi
mov    %rdi,-0x18(%r14,%rcx,8)
lea    -0x18(%rsi,%rcx,8),%rdi
lea    -0x28(%rsi,%rcx,8),%rsi
mov    %rsi,-0x10(%r14,%rcx,8)
lea    -0x10(%rdi,%rcx,8),%rsi
lea    -0x18(%rdi,%rcx,8),%rdi
mov    %rdi,-0x8(%r14,%rcx,8)
lea    (%rsi,%rcx,8),%rbx
add    $0xfffffffffffffff8,%rbx
mov    %rbx,(%r14,%rcx,8)
lea    (%rdx,%rcx,1),%rsi
add    $0x8,%rsi
add    $0x8,%rcx
cmp    $0x8,%rsi
jne    11f0 <allocate_s_double_LT+0xa0>
add    $0xfffffffffffffff9,%rcx
test   %rax,%rax
je     12a2 <allocate_s_double_LT+0x152>
cs nopw 0x0(%rax,%rax,1)
lea    (%rbx,%rcx,8),%rbx
mov    %rbx,(%r14,%rcx,8)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rax
jne    1290 <allocate_s_double_LT+0x140>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d2b(%rip),%rax
mov    (%rax),%edi
lea    0xd42(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"PE: Memory allocation fails!\0A\00"
define double** @allocate_s_double_LT(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double**
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = load i32, i32* %2
%8 = add nsw i32 %7, 1
%9 = mul nsw i32 %6, %8
%10 = sdiv i32 %9, 2
store i32 %10, i32* %4
%11 = load i32, i32* %2
%12 = call double** @allocate_double_2D_AP(i32 %11)
store double** %12, double*** %5
%13 = load double**, double*** %5
%14 = icmp eq double** %13, null
br i1 %14, label %15, label %19
15: ; preds = %1
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %1
%20 = load i32, i32* %4
%21 = call double* @allocate_double_1D(i32 %20)
%22 = load double**, double*** %5
%23 = getelementptr inbounds double*, double** %22, i64 0
store double* %21, double** %23
%24 = load double**, double*** %5
%25 = getelementptr inbounds double*, double** %24, i64 0
%26 = load double*, double** %25
%27 = icmp eq double* %26, null
br i1 %27, label %28, label %32
28: ; preds = %19
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %19
store i32 0, i32* %3
br label %33
33: ; preds = %44, %32
%34 = load i32, i32* %3
%35 = load i32, i32* %4
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %47
37: ; preds = %33
%38 = load double**, double*** %5
%39 = getelementptr inbounds double*, double** %38, i64 0
%40 = load double*, double** %39
%41 = load i32, i32* %3
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %40, i64 %42
store double 0.000000e+00, double* %43
br label %44
44: ; preds = %37
%45 = load i32, i32* %3
%46 = add nsw i32 %45, 1
store i32 %46, i32* %3
br label %33
47: ; preds = %33
store i32 1, i32* %3
br label %48
48: ; preds = %66, %47
%49 = load i32, i32* %3
%50 = load i32, i32* %2
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %69
52: ; preds = %48
%53 = load double**, double*** %5
%54 = load i32, i32* %3
%55 = sub nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double*, double** %53, i64 %56
%58 = load double*, double** %57
%59 = load i32, i32* %3
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %58, i64 %60
%62 = load double**, double*** %5
%63 = load i32, i32* %3
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double*, double** %62, i64 %64
store double* %61, double** %65
br label %66
66: ; preds = %52
%67 = load i32, i32* %3
%68 = add nsw i32 %67, 1
store i32 %68, i32* %3
br label %48
69: ; preds = %48
%70 = load double**, double*** %5
ret double** %70
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"PE: Memory allocation fails!\0A\00"
define double** @allocate_s_double_LT(i32 %0) {
%2 = add nsw i32 %0, 1
%3 = mul nsw i32 %2, %0
%4 = sdiv i32 %3, 2
%5 = tail call double** @allocate_double_2D_AP(i32 %0)
%6 = icmp eq double** %5, null
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %1
%12 = tail call double* @allocate_double_1D(i32 %4)
%13 = bitcast double* %12 to i8*
store double* %12, double** %5
%14 = icmp eq double* %12, null
br i1 %14, label %22, label %15
15: ; preds = %11
%16 = icmp sgt i32 %3, 1
br i1 %16, label %17, label %26
17: ; preds = %15
%18 = add nsw i32 %4, -1
%19 = zext i32 %18 to i64
%20 = shl nuw nsw i64 %19, 3
%21 = add nuw nsw i64 %20, 8
br label %26
22: ; preds = %11
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %17, %15
%27 = icmp sgt i32 %0, 1
br i1 %27, label %28, label %79
28: ; preds = %26
%29 = zext i32 %0 to i64
%30 = add nsw i64 %29, -1
%31 = add nsw i64 %29, -2
%32 = and i64 %30, 7
%33 = icmp ult i64 %31, 7
br i1 %33, label %66, label %34
34: ; preds = %28
%35 = and i64 %30, -8
br label %36
36: ; preds = %36, %34
%37 = phi double* [ %12, %34 ], [ %61, %36 ]
%38 = phi i64 [ 1, %34 ], [ %63, %36 ]
%39 = phi i64 [ 0, %34 ], [ %64, %36 ]
%40 = getelementptr inbounds double, double* %37, i64 %38
%41 = getelementptr inbounds double*, double** %5, i64 %38
store double* %40, double** %41
%42 = add nuw nsw i64 %38, 1
%43 = getelementptr inbounds double, double* %40, i64 %42
%44 = getelementptr inbounds double*, double** %5, i64 %42
store double* %43, double** %44
%45 = add nuw nsw i64 %38, 2
%46 = getelementptr inbounds double, double* %43, i64 %45
%47 = getelementptr inbounds double*, double** %5, i64 %45
store double* %46, double** %47
%48 = add nuw nsw i64 %38, 3
%49 = getelementptr inbounds double, double* %46, i64 %48
%50 = getelementptr inbounds double*, double** %5, i64 %48
store double* %49, double** %50
%51 = add nuw nsw i64 %38, 4
%52 = getelementptr inbounds double, double* %49, i64 %51
%53 = getelementptr inbounds double*, double** %5, i64 %51
store double* %52, double** %53
%54 = add nuw nsw i64 %38, 5
%55 = getelementptr inbounds double, double* %52, i64 %54
%56 = getelementptr inbounds double*, double** %5, i64 %54
store double* %55, double** %56
%57 = add nuw nsw i64 %38, 6
%58 = getelementptr inbounds double, double* %55, i64 %57
%59 = getelementptr inbounds double*, double** %5, i64 %57
store double* %58, double** %59
%60 = add nuw nsw i64 %38, 7
%61 = getelementptr inbounds double, double* %58, i64 %60
%62 = getelementptr inbounds double*, double** %5, i64 %60
store double* %61, double** %62
%63 = add nuw nsw i64 %38, 8
%64 = add i64 %39, 8
%65 = icmp eq i64 %64, %35
br i1 %65, label %66, label %36
66: ; preds = %36, %28
%67 = phi double* [ %12, %28 ], [ %61, %36 ]
%68 = phi i64 [ 1, %28 ], [ %63, %36 ]
%69 = icmp eq i64 %32, 0
br i1 %69, label %79, label %70
70: ; preds = %66, %70
%71 = phi double* [ %74, %70 ], [ %67, %66 ]
%72 = phi i64 [ %76, %70 ], [ %68, %66 ]
%73 = phi i64 [ %77, %70 ], [ 0, %66 ]
%74 = getelementptr inbounds double, double* %71, i64 %72
%75 = getelementptr inbounds double*, double** %5, i64 %72
store double* %74, double** %75
%76 = add nuw nsw i64 %72, 1
%77 = add i64 %73, 1
%78 = icmp eq i64 %77, %32
br i1 %78, label %79, label %70
79: ; preds = %66, %70, %26
ret double** %5
}