#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__ malloc(int);
double **get_double_tab(int x, int y) {
  int i, j;
  double **tab;
  tab = (double **)malloc(x * sizeof(double *));
  for (i = 0; i < x; i++) {
    tab[i] = (double *)malloc(y * sizeof(double));
    for (j = 0; j < y; j++) {
      tab[i][j] = 0.0;
    }
  }
  return tab;
}


x86 assembly (clang, -O0):
<get_double_tab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11ae <get_double_tab+0x9e>
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    119b <get_double_tab+0x8b>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1169 <get_double_tab+0x59>
jmp    11a0 <get_double_tab+0x90>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1138 <get_double_tab+0x28>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_double_tab>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%ebx
lea    0x0(,%rbx,8),%edi
call   1040 <malloc@plt>
mov    %rax,%r13
test   %ebx,%ebx
jle    118a <get_double_tab+0x6a>
lea    0x0(,%r14,8),%r12d
mov    %r14d,%r15d
shl    $0x3,%r15
mov    %ebx,%ebx
xor    %ebp,%ebp
jmp    1169 <get_double_tab+0x49>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%rbx
je     118a <get_double_tab+0x6a>
mov    %r12d,%edi
call   1040 <malloc@plt>
mov    %rax,0x0(%r13,%rbp,8)
test   %r14d,%r14d
jle    1160 <get_double_tab+0x40>
mov    %rax,%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   1030 <memset@plt>
jmp    1160 <get_double_tab+0x40>
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double** @get_double_tab(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double**
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = mul i64 %9, 8
%11 = trunc i64 %10 to i32
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to double**
store double** %13, double*** %7
store i32 0, i32* %5
br label %14
14: ; preds = %46, %2
%15 = load i32, i32* %5
%16 = load i32, i32* %3
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %49
18: ; preds = %14
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = mul i64 %20, 8
%22 = trunc i64 %21 to i32
%23 = call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to double*
%25 = load double**, double*** %7
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double*, double** %25, i64 %27
store double* %24, double** %28
store i32 0, i32* %6
br label %29
29: ; preds = %42, %18
%30 = load i32, i32* %6
%31 = load i32, i32* %4
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %45
33: ; preds = %29
%34 = load double**, double*** %7
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double*, double** %34, i64 %36
%38 = load double*, double** %37
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
store double 0.000000e+00, double* %41
br label %42
42: ; preds = %33
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %29
45: ; preds = %29
br label %46
46: ; preds = %45
%47 = load i32, i32* %5
%48 = add nsw i32 %47, 1
store i32 %48, i32* %5
br label %14
49: ; preds = %14
%50 = load double**, double*** %7
ret double** %50
}

LLVM IR (-O2):
define double** @get_double_tab(i32 %0, i32 %1) {
%3 = shl i32 %0, 3
%4 = tail call i64 @malloc(i32 %3)
%5 = inttoptr i64 %4 to double**
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %23
7: ; preds = %2
%8 = shl i32 %1, 3
%9 = icmp sgt i32 %1, 0
%10 = zext i32 %1 to i64
%11 = shl nuw nsw i64 %10, 3
%12 = zext i32 %0 to i64
br label %13
13: ; preds = %7, %20
%14 = phi i64 [ 0, %7 ], [ %21, %20 ]
%15 = tail call i64 @malloc(i32 %8)
%16 = inttoptr i64 %15 to double*
%17 = getelementptr inbounds double*, double** %5, i64 %14
store double* %16, double** %17
br i1 %9, label %18, label %20
18: ; preds = %13
%19 = inttoptr i64 %15 to i8*
br label %20
20: ; preds = %18, %13
%21 = add nuw nsw i64 %14, 1
%22 = icmp eq i64 %21, %12
br i1 %22, label %23, label %13
23: ; preds = %20, %2
ret double** %5
}