#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 gaussian(double, double);
void randomize(float *vectors, int dim, int num_of_vectors) {
  int i;
  int j;
  float *p1;
  int dim2 = dim;
  for (i = 0; i < num_of_vectors; i++) {
    p1 = &vectors[i * dim2];
    for (j = 0; j < dim; j++) {
      p1[j] = gaussian(0.0, 25.0);
    }
    for (; j < dim2; j++) {
      p1[j] = (float)0;
    }
  }
}


x86 assembly (clang, -O0):
<randomize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11d4 <randomize+0xc4>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0x24(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1192 <randomize+0x82>
xorps  %xmm0,%xmm0
movsd  0xe8e(%rip),%xmm1
call   1030 <gaussian@plt>
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115b <randomize+0x4b>
jmp    1197 <randomize+0x87>
mov    -0x18(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11c1 <randomize+0xb1>
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1197 <randomize+0x87>
jmp    11c6 <randomize+0xb6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112f <randomize+0x1f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randomize>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,0x4(%rsp)
test   %edx,%edx
jle    1181 <randomize+0x71>
mov    %rdi,%rbx
movslq 0x4(%rsp),%r12
mov    %edx,%r15d
mov    %r12d,%ebp
shl    $0x2,%r12
xor    %r13d,%r13d
jmp    114c <randomize+0x3c>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r13
add    %r12,%rbx
cmp    %r15,%r13
je     1181 <randomize+0x71>
cmpl   $0x0,0x4(%rsp)
jle    1140 <randomize+0x30>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
movsd  0xe95(%rip),%xmm1
call   1030 <gaussian@plt>
movss  %xmm0,(%rbx,%r14,4)
add    $0x1,%r14
cmp    %r14,%rbp
jne    1160 <randomize+0x50>
jmp    1140 <randomize+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @randomize(float* %0, i32 %1, i32 %2) {
%4 = alloca float*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca float*
%10 = alloca i32
store float* %0, float** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = load i32, i32* %5
store i32 %11, i32* %10
store i32 0, i32* %7
br label %12
12: ; preds = %50, %3
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %53
16: ; preds = %12
%17 = load float*, float** %4
%18 = load i32, i32* %7
%19 = load i32, i32* %10
%20 = mul nsw i32 %18, %19
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds float, float* %17, i64 %21
store float* %22, float** %9
store i32 0, i32* %8
br label %23
23: ; preds = %33, %16
%24 = load i32, i32* %8
%25 = load i32, i32* %5
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %36
27: ; preds = %23
%28 = call float @gaussian(double 0.000000e+00, double 2.500000e+01)
%29 = load float*, float** %9
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds float, float* %29, i64 %31
store float %28, float* %32
br label %33
33: ; preds = %27
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %23
36: ; preds = %23
br label %37
37: ; preds = %46, %36
%38 = load i32, i32* %8
%39 = load i32, i32* %10
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %49
41: ; preds = %37
%42 = load float*, float** %9
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds float, float* %42, i64 %44
store float 0.000000e+00, float* %45
br label %46
46: ; preds = %41
%47 = load i32, i32* %8
%48 = add nsw i32 %47, 1
store i32 %48, i32* %8
br label %37
49: ; preds = %37
br label %50
50: ; preds = %49
%51 = load i32, i32* %7
%52 = add nsw i32 %51, 1
store i32 %52, i32* %7
br label %12
53: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @randomize(float* nocapture writeonly %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %23
5: ; preds = %3
%6 = icmp sgt i32 %1, 0
%7 = sext i32 %1 to i64
%8 = zext i32 %2 to i64
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %5, %20
%11 = phi i64 [ 0, %5 ], [ %21, %20 ]
%12 = mul nsw i64 %11, %7
%13 = getelementptr inbounds float, float* %0, i64 %12
br i1 %6, label %14, label %20
14: ; preds = %10, %14
%15 = phi i64 [ %18, %14 ], [ 0, %10 ]
%16 = tail call float @gaussian(double 0.000000e+00, double 2.500000e+01)
%17 = getelementptr inbounds float, float* %13, i64 %15
store float %16, float* %17
%18 = add nuw nsw i64 %15, 1
%19 = icmp eq i64 %18, %9
br i1 %19, label %20, label %14
20: ; preds = %14, %10
%21 = add nuw nsw i64 %11, 1
%22 = icmp eq i64 %21, %8
br i1 %22, label %23, label %10
23: ; preds = %20, %3
ret void
}