#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__ RAND_MAX;
scalar_t__ malloc(int);
scalar_t__ rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
double *randvec(int m, double c) {
  srand(time(NULL));
  double *X;
  int i;
  int j;
  X = (double *)malloc(m * sizeof(double));
  for (i = 0; i < m; i++)
    X[i] = ((double)rand()) / ((double)RAND_MAX) * c;
  return X;
}


x86 assembly (clang, -O0):
<randvec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11c2 <randvec+0x82>
mov    $0x0,%al
call   1060 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e4f(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117a <randvec+0x3a>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randvec>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movsd  %xmm0,(%rsp)
mov    %edi,%r14d
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
lea    0x0(,%r14,8),%edi
call   1050 <malloc@plt>
mov    %rax,%r15
test   %r14d,%r14d
jle    11af <randvec+0x6f>
mov    %r14d,%r12d
mov    0x2e6b(%rip),%r14
xor    %ebx,%ebx
nop
xor    %eax,%eax
call   1060 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq (%r14),%xmm1
divsd  %xmm1,%xmm0
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1180 <randvec+0x40>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@RAND_MAX = global i64 0
define double* @randvec(i32 %0, double %1) {
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = shl i32 %0, 3
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to double*
%8 = icmp sgt i32 %0, 0
br i1 %8, label %9, label %22
9: ; preds = %2
%10 = zext i32 %0 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %20, %11 ]
%13 = tail call i64 (...) @rand()
%14 = sitofp i64 %13 to double
%15 = load i64, i64* @RAND_MAX
%16 = sitofp i64 %15 to double
%17 = fdiv double %14, %16
%18 = fmul double %17, %1
%19 = getelementptr inbounds double, double* %7, i64 %12
store double %18, double* %19
%20 = add nuw nsw i64 %12, 1
%21 = icmp eq i64 %20, %10
br i1 %21, label %22, label %11
22: ; preds = %11, %2
ret double* %7
}