#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 */
void *malloc(long);
long double **alloc_2d_ld(long width, long height) {
  long i;
  long double **rows;
  rows = malloc(height * sizeof(long double *));
  for (i = 0; i < height; i++) {
    rows[i] = malloc(width * sizeof(long double));
  }
  return rows;
}


x86 assembly (clang, -O0):
<alloc_2d_ld>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
shl    $0x3,%rdi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    1174 <alloc_2d_ld+0x64>
mov    -0x8(%rbp),%rdi
shl    $0x4,%rdi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1139 <alloc_2d_ld+0x29>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alloc_2d_ld>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
lea    0x0(,%rsi,8),%rdi
call   1030 <malloc@plt>
mov    %rax,%r12
test   %r15,%r15
jle    1155 <alloc_2d_ld+0x45>
shl    $0x4,%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <malloc@plt>
mov    %rax,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <alloc_2d_ld+0x30>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define noalias x86_fp80** @alloc_2d_ld(i64 %0, i64 %1) {
%3 = shl i64 %1, 3
%4 = tail call i8* @malloc(i64 %3)
%5 = bitcast i8* %4 to x86_fp80**
%6 = icmp sgt i64 %1, 0
br i1 %6, label %7, label %16
7: ; preds = %2
%8 = shl i64 %0, 4
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %14, %9 ]
%11 = tail call i8* @malloc(i64 %8)
%12 = getelementptr inbounds x86_fp80*, x86_fp80** %5, i64 %10
%13 = bitcast x86_fp80** %12 to i8**
store i8* %11, i8** %13
%14 = add nuw nsw i64 %10, 1
%15 = icmp eq i64 %14, %1
br i1 %15, label %16, label %9
16: ; preds = %9, %2
ret x86_fp80** %5
}