#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 *mtrx(int rows, int cols) {
  int row, col;
  double *d, *it;
  d = (double *)malloc(rows * cols * sizeof(double));
  it = d;
  for (row = 0; row < rows; row++) {
    for (col = 0; col < cols; col++) {
      *it = 0.4711;
      it++;
    }
  }
  return d;
}


x86 assembly (clang, -O0):
<mtrx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
imul   -0x8(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a1 <mtrx+0x91>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    118e <mtrx+0x7e>
mov    -0x20(%rbp),%rax
movsd  0xe90(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1158 <mtrx+0x48>
jmp    1193 <mtrx+0x83>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1145 <mtrx+0x35>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mtrx>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r13d
mov    %edi,%r15d
imul   %esi,%edi
shl    $0x3,%edi
call   1030 <malloc@plt>
test   %r15d,%r15d
jle    1282 <mtrx+0x172>
lea    -0x1(%r13),%r14d
lea    0x1(%r14),%r8
mov    %r8,%r12
and    $0xfffffffffffffffc,%r12
lea    -0x4(%r12),%r9
mov    %r9,%r10
shr    $0x2,%r10
add    $0x1,%r10
mov    %r10d,%r11d
and    $0x7,%r11d
and    $0xfffffffffffffff8,%r10
mov    %r11,%rdi
shl    $0x5,%rdi
xor    %edx,%edx
movabs $0x3fde26809d495183,%rcx
26 de 3f
movaps 0xe87(%rip),%xmm0
mov    %rax,%rbp
jmp    118c <mtrx+0x7c>
xchg   %ax,%ax
add    $0x1,%edx
cmp    %r15d,%edx
je     1282 <mtrx+0x172>
test   %r13d,%r13d
jle    1180 <mtrx+0x70>
xor    %ebx,%ebx
cmp    $0x3,%r14d
jb     1263 <mtrx+0x153>
cmp    $0x1c,%r9
jae    11aa <mtrx+0x9a>
xor    %esi,%esi
jmp    1222 <mtrx+0x112>
mov    %r10,%rbx
xor    %esi,%esi
nop
movups %xmm0,0x0(%rbp,%rsi,8)
movups %xmm0,0x10(%rbp,%rsi,8)
movups %xmm0,0x20(%rbp,%rsi,8)
movups %xmm0,0x30(%rbp,%rsi,8)
movups %xmm0,0x40(%rbp,%rsi,8)
movups %xmm0,0x50(%rbp,%rsi,8)
movups %xmm0,0x60(%rbp,%rsi,8)
movups %xmm0,0x70(%rbp,%rsi,8)
movups %xmm0,0x80(%rbp,%rsi,8)
movups %xmm0,0x90(%rbp,%rsi,8)
movups %xmm0,0xa0(%rbp,%rsi,8)
movups %xmm0,0xb0(%rbp,%rsi,8)
movups %xmm0,0xc0(%rbp,%rsi,8)
movups %xmm0,0xd0(%rbp,%rsi,8)
movups %xmm0,0xe0(%rbp,%rsi,8)
movups %xmm0,0xf0(%rbp,%rsi,8)
add    $0x20,%rsi
add    $0xfffffffffffffff8,%rbx
jne    11b0 <mtrx+0xa0>
test   %r11,%r11
je     1252 <mtrx+0x142>
lea    0x10(,%rsi,8),%rsi
add    %rbp,%rsi
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movups %xmm0,-0x10(%rsi,%rbx,1)
movups %xmm0,(%rsi,%rbx,1)
add    $0x20,%rbx
cmp    %rbx,%rdi
jne    1240 <mtrx+0x130>
lea    0x0(%rbp,%r12,8),%rbp
mov    %r12d,%ebx
cmp    %r12,%r8
je     1180 <mtrx+0x70>
mov    %r13d,%esi
sub    %ebx,%esi
nopl   0x0(%rax,%rax,1)
mov    %rcx,0x0(%rbp)
add    $0x8,%rbp
add    $0xffffffff,%esi
jne    1270 <mtrx+0x160>
jmp    1180 <mtrx+0x70>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double* @mtrx(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
store i32 %0, i32* %3
store i32 %1, i32* %4
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%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 i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to double*
store double* %16, double** %7
%17 = load double*, double** %7
store double* %17, double** %8
store i32 0, i32* %5
br label %18
18: ; preds = %35, %2
%19 = load i32, i32* %5
%20 = load i32, i32* %3
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %38
22: ; preds = %18
store i32 0, i32* %6
br label %23
23: ; preds = %31, %22
%24 = load i32, i32* %6
%25 = load i32, i32* %4
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %34
27: ; preds = %23
%28 = load double*, double** %8
store double 4.711000e-01, double* %28
%29 = load double*, double** %8
%30 = getelementptr inbounds double, double* %29, i32 1
store double* %30, double** %8
br label %31
31: ; preds = %27
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %23
34: ; preds = %23
br label %35
35: ; preds = %34
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %18
38: ; preds = %18
%39 = load double*, double** %7
ret double* %39
}

LLVM IR (-O2):
define double* @mtrx(i32 %0, i32 %1) {
%3 = shl i32 %0, 3
%4 = mul i32 %3, %1
%5 = tail call i64 @malloc(i32 %4)
%6 = inttoptr i64 %5 to double*
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %102
8: ; preds = %2
%9 = icmp sgt i32 %1, 0
%10 = add i32 %1, -1
%11 = zext i32 %10 to i64
%12 = add nuw nsw i64 %11, 1
%13 = and i64 %12, 8589934588
%14 = add nsw i64 %13, -4
%15 = lshr exact i64 %14, 2
%16 = add nuw nsw i64 %15, 1
%17 = icmp ult i32 %10, 3
%18 = and i64 %12, 8589934588
%19 = trunc i64 %18 to i32
%20 = and i64 %16, 7
%21 = icmp ult i64 %14, 28
%22 = and i64 %16, 9223372036854775800
%23 = icmp eq i64 %20, 0
%24 = icmp eq i64 %12, %18
br label %25
25: ; preds = %8, %98
%26 = phi double* [ %6, %8 ], [ %99, %98 ]
%27 = phi i32 [ 0, %8 ], [ %100, %98 ]
br i1 %9, label %28, label %98
28: ; preds = %25
br i1 %17, label %89, label %29
29: ; preds = %28
%30 = getelementptr double, double* %26, i64 %18
br i1 %21, label %76, label %31
31: ; preds = %29, %31
%32 = phi i64 [ %73, %31 ], [ 0, %29 ]
%33 = phi i64 [ %74, %31 ], [ 0, %29 ]
%34 = getelementptr double, double* %26, i64 %32
%35 = bitcast double* %34 to <2 x double>*
store <2 x double> <double 4.711000e-01, double 4.711000e-01>, <2 x double>* %35
%36 = getelementptr double, double* %34, i64 2
%37 = bitcast double* %36 to <2 x double>*
store <2 x double> <double 4.711000e-01, double 4.711000e-01>, <2 x double>* %37
%38 = or i64 %32, 4
%39 = getelementptr double, double* %26, i64 %38
%40 = bitcast double* %39 to <2 x double>*
store <2 x double> <double 4.711000e-01, double 4.711000e-01>, <2 x double>* %40
%41 = getelementptr double, double* %39, i64 2
%42 = bitcast double* %41 to <2 x double>*
store <2 x double> <double 4.711000e-01, double 4.711000e-01>, <2 x double>* %42
%43 = or i64 %32, 8
%44 = getelementptr double, double* %26, i64 %43
%45 = bitcast double* %44 to <2 x double>*
store <2 x double> <double 4.711000e-01, double 4.711000e-01>, <2 x double>* %45
%46 = getelementptr double, double* %44, i64 2
%47 = bitcast double* %46 to <2 x double>*
store <2 x double> <double 4.711000e-01, double 4.711000e-01>, <2 x double>* %47
%48 = or i64 %32, 12
%49 = getelementptr double, double* %26, i64 %48
%50 = bitcast double* %49 to <2 x double>*
store <2 x double> <double 4.711000e-01, double 4.711000e-01>, <2 x double>* %50
%51 = getelementptr double, double* %49, i64 2
%52 = bitcast double* %51 to <2 x double>*
store <2 x double> <double 4.711000e-01, double 4.711000e-01>, <2 x double>* %52
%53 = or i64 %32, 16
%54 = getelementptr double, double* %26, i64 %53
%55 = bitcast double* %54 to <2 x double>*
store <2 x double> <double 4.711000e-01, double 4.711000e-01>, <2 x double>* %55
%56 = getelementptr double, double* %54, i64 2
%57 = bitcast double* %56 to <2 x double>*
store <2 x double> <double 4.711000e-01, double 4.711000e-01>, <2 x double>* %57
%58 = or i64 %32, 20
%59 = getelementptr double, double* %26, i64 %58
%60 = bitcast double* %59 to <2 x double>*
store <2 x double> <double 4.711000e-01, double 4.711000e-01>, <2 x double>* %60
%61 = getelementptr double, double* %59, i64 2
%62 = bitcast double* %61 to <2 x double>*
store <2 x double> <double 4.711000e-01, double 4.711000e-01>, <2 x double>* %62
%63 = or i64 %32, 24
%64 = getelementptr double, double* %26, i64 %63
%65 = bitcast double* %64 to <2 x double>*
store <2 x double> <double 4.711000e-01, double 4.711000e-01>, <2 x double>* %65
%66 = getelementptr double, double* %64, i64 2
%67 = bitcast double* %66 to <2 x double>*
store <2 x double> <double 4.711000e-01, double 4.711000e-01>, <2 x double>* %67
%68 = or i64 %32, 28
%69 = getelementptr double, double* %26, i64 %68
%70 = bitcast double* %69 to <2 x double>*
store <2 x double> <double 4.711000e-01, double 4.711000e-01>, <2 x double>* %70
%71 = getelementptr double, double* %69, i64 2
%72 = bitcast double* %71 to <2 x double>*
store <2 x double> <double 4.711000e-01, double 4.711000e-01>, <2 x double>* %72
%73 = add nuw i64 %32, 32
%74 = add i64 %33, 8
%75 = icmp eq i64 %74, %22
br i1 %75, label %76, label %31
76: ; preds = %31, %29
%77 = phi i64 [ 0, %29 ], [ %73, %31 ]
br i1 %23, label %88, label %78
78: ; preds = %76, %78
%79 = phi i64 [ %85, %78 ], [ %77, %76 ]
%80 = phi i64 [ %86, %78 ], [ 0, %76 ]
%81 = getelementptr double, double* %26, i64 %79
%82 = bitcast double* %81 to <2 x double>*
store <2 x double> <double 4.711000e-01, double 4.711000e-01>, <2 x double>* %82
%83 = getelementptr double, double* %81, i64 2
%84 = bitcast double* %83 to <2 x double>*
store <2 x double> <double 4.711000e-01, double 4.711000e-01>, <2 x double>* %84
%85 = add nuw i64 %79, 4
%86 = add i64 %80, 1
%87 = icmp eq i64 %86, %20
br i1 %87, label %88, label %78
88: ; preds = %78, %76
br i1 %24, label %98, label %89
89: ; preds = %28, %88
%90 = phi double* [ %26, %28 ], [ %30, %88 ]
%91 = phi i32 [ 0, %28 ], [ %19, %88 ]
br label %92
92: ; preds = %89, %92
%93 = phi double* [ %95, %92 ], [ %90, %89 ]
%94 = phi i32 [ %96, %92 ], [ %91, %89 ]
store double 4.711000e-01, double* %93
%95 = getelementptr inbounds double, double* %93, i64 1
%96 = add nuw nsw i32 %94, 1
%97 = icmp eq i32 %96, %1
br i1 %97, label %98, label %92
98: ; preds = %92, %88, %25
%99 = phi double* [ %26, %25 ], [ %30, %88 ], [ %95, %92 ]
%100 = add nuw nsw i32 %27, 1
%101 = icmp eq i32 %100, %0
br i1 %101, label %102, label %25
102: ; preds = %98, %2
ret double* %6
}