#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 */
int /*<<< orphan*/ initWeights(float **, int, int);
scalar_t__ malloc(int);
float **generateWeights(int weightsRow, int weightsColumn) {
  int i;
  float **weights = (float **)malloc(sizeof(float *) * weightsRow);
  for (i = 0; i < weightsRow; i++)
    weights[i] = (float *)malloc(sizeof(float) * weightsColumn);
  initWeights(weights, weightsRow, weightsColumn);
  return weights;
}


x86 assembly (clang, -O0):
<generateWeights>:
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   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1180 <generateWeights+0x60>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1148 <generateWeights+0x28>
mov    -0x18(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1030 <initWeights@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generateWeights>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%r15d
lea    0x0(,%r15,8),%edi
call   1040 <malloc@plt>
mov    %rax,%r12
test   %r15d,%r15d
jle    1175 <generateWeights+0x55>
lea    0x0(,%r14,4),%r13d
mov    %r15d,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13d,%edi
call   1040 <malloc@plt>
mov    %rax,(%r12,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1160 <generateWeights+0x40>
mov    %r12,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
call   1030 <initWeights@plt>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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