#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 RAND_MAX;
int /*<<< orphan*/ printf(char *);
scalar_t__ rand();
void data_gen(float *data_x, float *data_y, int numValues) {
  printf("Input data is a linear function: 0.5 *x - 27 with randon noise "
         "added.\n");
  int i;
  for (i = 0; i < numValues; i++) {
    data_x[i] = (float)i;
    data_y[i] = 0.5 * (float)i - 27 + (float)rand() / RAND_MAX - 0.5;
  }
}


x86 assembly (clang, -O0):
<data_gen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    0xed6(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d9 <data_gen+0xb9>
cvtsi2ssl -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
cvtsi2ssl -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe8b(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe87(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
movsd  -0x20(%rbp),%xmm0
cvtsi2ss %rax,%xmm1
mov    0x2e46(%rip),%rax
divss  (%rax),%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm1,%xmm0
movsd  0xe4a(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1146 <data_gen+0x26>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<data_gen>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xedd(%rip),%rdi
call   1030 <puts@plt>
test   %ebp,%ebp
jle    11b0 <data_gen+0x90>
mov    %ebp,%ebp
mov    0x2e9b(%rip),%r15
xor    %ebx,%ebx
nop
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
movss  %xmm0,(%r12,%rbx,4)
cvtss2sd %xmm0,%xmm0
mulsd  0xe97(%rip),%xmm0
addsd  0xe97(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
divss  (%r15),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0x8(%rsp),%xmm0
addsd  0xe73(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1150 <data_gen+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [71 x i8] c"Input data is a linear function: 0.5 *x - 27 with randon noise added.\0A\00"
@RAND_MAX = global float 0.000000e+00
define void @data_gen(float* %0, float* %1, i32 %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca i32
%7 = alloca i32
store float* %0, float** %4
store float* %1, float** %5
store i32 %2, i32* %6
%8 = call i32 @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %9
9: ; preds = %36, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %6
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %39
13: ; preds = %9
%14 = load i32, i32* %7
%15 = sitofp i32 %14 to float
%16 = load float*, float** %4
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds float, float* %16, i64 %18
store float %15, float* %19
%20 = load i32, i32* %7
%21 = sitofp i32 %20 to float
%22 = fpext float %21 to double
%23 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %22, double -2.700000e+01)
%24 = call i64 (...) @rand()
%25 = sitofp i64 %24 to float
%26 = load float, float* @RAND_MAX
%27 = fdiv float %25, %26
%28 = fpext float %27 to double
%29 = fadd double %23, %28
%30 = fsub double %29, 5.000000e-01
%31 = fptrunc double %30 to float
%32 = load float*, float** %5
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds float, float* %32, i64 %34
store float %31, float* %35
br label %36
36: ; preds = %13
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %9
39: ; preds = %9
ret void
}

LLVM IR (-O2):
@RAND_MAX = global float 0.000000e+00
@str = [70 x i8] c"Input data is a linear function: 0.5 *x - 27 with randon noise added.\00"
define void @data_gen(float* nocapture writeonly %0, float* nocapture writeonly %1, i32 %2) {
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str, i64 0, i64 0))
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %26
6: ; preds = %3
%7 = zext i32 %2 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %24, %8 ]
%10 = trunc i64 %9 to i32
%11 = sitofp i32 %10 to float
%12 = getelementptr inbounds float, float* %0, i64 %9
store float %11, float* %12
%13 = fpext float %11 to double
%14 = tail call double @llvm.fmuladd.f64(double %13, double 5.000000e-01, double -2.700000e+01)
%15 = tail call i64 (...) @rand()
%16 = sitofp i64 %15 to float
%17 = load float, float* @RAND_MAX
%18 = fdiv float %16, %17
%19 = fpext float %18 to double
%20 = fadd double %14, %19
%21 = fadd double %20, -5.000000e-01
%22 = fptrunc double %21 to float
%23 = getelementptr inbounds float, float* %1, i64 %9
store float %22, float* %23
%24 = add nuw nsw i64 %9, 1
%25 = icmp eq i64 %24, %7
br i1 %25, label %26, label %8
26: ; preds = %8, %3
ret void
}