#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 *malloc(int);
void d_zeros(double **pA, int row, int col) {
  *pA = malloc((row * col) * sizeof(double));
  double *A = *pA;
  int i;
  for (i = 0; i < row * col; i++)
    A[i] = 0.0;
}


x86 assembly (clang, -O0):
<d_zeros>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    1182 <d_zeros+0x72>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1152 <d_zeros+0x42>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<d_zeros>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
imul   %edx,%ebx
lea    0x0(,%rbx,8),%edi
call   1040 <malloc@plt>
mov    %rax,(%r14)
test   %ebx,%ebx
jle    114f <d_zeros+0x2f>
mov    %ebx,%edx
shl    $0x3,%rdx
mov    %rax,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @d_zeros(double** %0, i32 %1, i32 %2) {
%4 = alloca double**
%5 = alloca i32
%6 = alloca i32
%7 = alloca double*
%8 = alloca i32
store double** %0, double*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32, i32* %5
%10 = load i32, i32* %6
%11 = mul nsw i32 %9, %10
%12 = sext i32 %11 to i64
%13 = mul i64 %12, 8
%14 = trunc i64 %13 to i32
%15 = call double* @malloc(i32 %14)
%16 = load double**, double*** %4
store double* %15, double** %16
%17 = load double**, double*** %4
%18 = load double*, double** %17
store double* %18, double** %7
store i32 0, i32* %8
br label %19
19: ; preds = %30, %3
%20 = load i32, i32* %8
%21 = load i32, i32* %5
%22 = load i32, i32* %6
%23 = mul nsw i32 %21, %22
%24 = icmp slt i32 %20, %23
br i1 %24, label %25, label %33
25: ; preds = %19
%26 = load double*, double** %7
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %26, i64 %28
store double 0.000000e+00, double* %29
br label %30
30: ; preds = %25
%31 = load i32, i32* %8
%32 = add nsw i32 %31, 1
store i32 %32, i32* %8
br label %19
33: ; preds = %19
ret void
}

LLVM IR (-O2):
define void @d_zeros(double** nocapture writeonly %0, i32 %1, i32 %2) {
%4 = mul nsw i32 %2, %1
%5 = shl i32 %4, 3
%6 = tail call double* @malloc(i32 %5)
store double* %6, double** %0
%7 = icmp sgt i32 %4, 0
br i1 %7, label %8, label %12
8: ; preds = %3
%9 = bitcast double* %6 to i8*
%10 = zext i32 %4 to i64
%11 = shl nuw nsw i64 %10, 3
br label %12
12: ; preds = %8, %3
ret void
}