#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*/ free(float *);
scalar_t__ malloc(int);
int rand();
int /*<<< orphan*/ rowechelon(unsigned int, float *);
int /*<<< orphan*/ srand(unsigned int);
int main() {
  unsigned int size = 0xA00;
  float *matrix = (float *)malloc(sizeof(float) * size * size);
  int i, j;
  srand(size);
  for (i = 0; i < size; i++) {
    for (j = 0; j < size; j++) {
      matrix[i * size + j] = (float)(rand() % 9);
    }
  }
  rowechelon(size, matrix);
  free(matrix);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa00,-0x8(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x2,%rax
mov    -0x8(%rbp),%ecx
imul   %rcx,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <srand@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    11f6 <main+0xa6>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    11e3 <main+0x93>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x9,%ecx
cltd
idiv   %ecx
cvtsi2ss %edx,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x18(%rbp),%ecx
mov    %ecx,%ecx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a1 <main+0x51>
jmp    11e8 <main+0x98>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118e <main+0x3e>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <rowechelon@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x1900000,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    $0xa00,%edi
call   1040 <srand@plt>
mov    %r14,%r12
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,(%r12,%rbx,4)
add    $0x1,%rbx
cmp    $0xa00,%rbx
jne    1190 <main+0x40>
add    $0x1,%r15
add    $0x2800,%r12
cmp    $0xa00,%r15
jne    1180 <main+0x30>
mov    $0xa00,%edi
mov    %r14,%rsi
call   1060 <rowechelon@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i64 @malloc(i32 26214400)
%2 = inttoptr i64 %1 to float*
%3 = tail call i32 @srand(i32 2560)
br label %4
4: ; preds = %0, %16
%5 = phi i64 [ 0, %0 ], [ %17, %16 ]
%6 = mul nuw nsw i64 %5, 2560
br label %7
7: ; preds = %4, %7
%8 = phi i64 [ 0, %4 ], [ %14, %7 ]
%9 = tail call i32 (...) @rand()
%10 = srem i32 %9, 9
%11 = sitofp i32 %10 to float
%12 = add nuw nsw i64 %8, %6
%13 = getelementptr inbounds float, float* %2, i64 %12
store float %11, float* %13
%14 = add nuw nsw i64 %8, 1
%15 = icmp eq i64 %14, 2560
br i1 %15, label %16, label %7
16: ; preds = %7
%17 = add nuw nsw i64 %5, 1
%18 = icmp eq i64 %17, 2560
br i1 %18, label %19, label %4
19: ; preds = %16
%20 = tail call i32 @rowechelon(i32 2560, float* %2)
%21 = tail call i32 @free(float* %2)
ret i32 0
}