#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;
double rand();
float *gen_coeffs(float *coeffs, int size) {
  float *curr_pointer = coeffs;
  int i = 0;
  double value;
  for (i = 0; i < size; i++) {
    value = rand() / (double)RAND_MAX;
    *curr_pointer = value;
    curr_pointer++;
  }
  return coeffs;
}


x86 assembly (clang, -O0):
<gen_coeffs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1188 <gen_coeffs+0x78>
mov    $0x0,%al
call   1030 <rand@plt>
mov    0x2e99(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1135 <gen_coeffs+0x25>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_coeffs>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
test   %esi,%esi
jle    1156 <gen_coeffs+0x46>
mov    %esi,%r12d
mov    0x2ebf(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <rand@plt>
xorps  %xmm1,%xmm1
cvtsi2sdq (%r15),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %ebx,%r12d
jne    1130 <gen_coeffs+0x20>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@RAND_MAX = global i64 0
define float* @gen_coeffs(float* %0, i32 %1) {
%3 = alloca float*
%4 = alloca i32
%5 = alloca float*
%6 = alloca i32
%7 = alloca double
store float* %0, float** %3
store i32 %1, i32* %4
%8 = load float*, float** %3
store float* %8, float** %5
store i32 0, i32* %6
store i32 0, i32* %6
br label %9
9: ; preds = %23, %2
%10 = load i32, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %26
13: ; preds = %9
%14 = call double (...) @rand()
%15 = load i64, i64* @RAND_MAX
%16 = sitofp i64 %15 to double
%17 = fdiv double %14, %16
store double %17, double* %7
%18 = load double, double* %7
%19 = fptrunc double %18 to float
%20 = load float*, float** %5
store float %19, float* %20
%21 = load float*, float** %5
%22 = getelementptr inbounds float, float* %21, i32 1
store float* %22, float** %5
br label %23
23: ; preds = %13
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %9
26: ; preds = %9
%27 = load float*, float** %3
ret float* %27
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
define float* @gen_coeffs(float* returned writeonly %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %15
4: ; preds = %2, %4
%5 = phi float* [ %12, %4 ], [ %0, %2 ]
%6 = phi i32 [ %13, %4 ], [ 0, %2 ]
%7 = tail call double (...) @rand()
%8 = load i64, i64* @RAND_MAX
%9 = sitofp i64 %8 to double
%10 = fdiv double %7, %9
%11 = fptrunc double %10 to float
store float %11, float* %5
%12 = getelementptr inbounds float, float* %5, i64 1
%13 = add nuw nsw i32 %6, 1
%14 = icmp eq i32 %13, %1
br i1 %14, label %15, label %4
15: ; preds = %4, %2
ret float* %0
}