#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 */
float get_float();
float *malloc(int);
float *make_matrix(int x, int y) {
  int i;
  float *matrix = malloc(x * y * sizeof(float));
  for (i = 0; i < x * y; i++)
    matrix[i] = get_float();
  return matrix;
}


x86 assembly (clang, -O0):
<make_matrix>:
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    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x4(%rbp),%ecx
imul   -0x8(%rbp),%ecx
cmp    %ecx,%eax
jge    1181 <make_matrix+0x61>
mov    $0x0,%al
call   1030 <get_float@plt>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114d <make_matrix+0x2d>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_matrix>:
push   %r15
push   %r14
push   %rbx
mov    %edi,%r14d
imul   %esi,%r14d
lea    0x0(,%r14,4),%edi
call   1040 <malloc@plt>
mov    %rax,%r15
test   %r14d,%r14d
jle    1166 <make_matrix+0x46>
mov    %r14d,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <get_float@plt>
movss  %xmm0,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1150 <make_matrix+0x30>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define float* @make_matrix(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 = load i32, i32* %4
%9 = mul nsw i32 %7, %8
%10 = sext i32 %9 to i64
%11 = mul i64 %10, 4
%12 = trunc i64 %11 to i32
%13 = call float* @malloc(i32 %12)
store float* %13, float** %6
store i32 0, i32* %5
br label %14
14: ; preds = %26, %2
%15 = load i32, i32* %5
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = mul nsw i32 %16, %17
%19 = icmp slt i32 %15, %18
br i1 %19, label %20, label %29
20: ; preds = %14
%21 = call float (...) @get_float()
%22 = load float*, float** %6
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds float, float* %22, i64 %24
store float %21, float* %25
br label %26
26: ; preds = %20
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %14
29: ; preds = %14
%30 = load float*, float** %6
ret float* %30
}

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