#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 */
typedef float uint32_t;
typedef int /*<<< orphan*/ int32_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
float f_rand();
int /*<<< orphan*/ fwrite(float *, int, int, int /*<<< orphan*/ *);
void genData(FILE *fn, int nVec, float xVar) {
  float xMax = 1.1;
  float xMin = -xMax;
  float xRange = (xMax - xMin);
  uint32_t nInput = 2;
  fwrite(&nInput, sizeof(int32_t), 1, fn);
  uint32_t nOutput = 0;
  fwrite(&nOutput, sizeof(int32_t), 1, fn);
  uint32_t nExamples = nVec;
  fwrite(&nExamples, sizeof(int32_t), 1, fn);
  for (int i = 0; i < nVec; i++) {
    float t = xRange * f_rand();
    float z1 = t + xVar * f_rand();
    float z2 = t * t * t + xVar * f_rand();
    fwrite(&z1, sizeof(float), 1, fn);
    fwrite(&z2, sizeof(float), 1, fn);
  }
}


x86 assembly (clang, -O0):
<genData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movss  %xmm0,-0x10(%rbp)
movss  0xec8(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
subss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xe91(%rip),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rcx
lea    -0x20(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1040 <fwrite@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x8(%rbp),%rcx
lea    -0x24(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1040 <fwrite@plt>
cvtsi2ssl -0xc(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rcx
lea    -0x28(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1040 <fwrite@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12be <genData+0x19e>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x50(%rbp)
mov    $0x0,%al
call   1030 <f_rand@plt>
movaps %xmm0,%xmm1
movss  -0x50(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x4c(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x48(%rbp)
mov    $0x0,%al
call   1030 <f_rand@plt>
movss  -0x4c(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x48(%rbp),%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x30(%rbp),%xmm0
mulss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x40(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x44(%rbp)
mov    $0x0,%al
call   1030 <f_rand@plt>
movss  -0x44(%rbp),%xmm1
movss  -0x40(%rbp),%xmm2
movaps %xmm0,%xmm3
movss  -0x3c(%rbp),%xmm0
mulss  %xmm3,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rcx
lea    -0x34(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1040 <fwrite@plt>
mov    -0x8(%rbp),%rcx
lea    -0x38(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1040 <fwrite@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11d2 <genData+0xb2>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genData>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
movss  %xmm0,0x8(%rsp)
mov    %esi,%ebx
mov    %rdi,%r14
movl   $0x40000000,0x24(%rsp)
40
lea    0x24(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <fwrite@plt>
movl   $0x0,0x20(%rsp)
lea    0x20(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <fwrite@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
movss  %xmm0,0x1c(%rsp)
lea    0x1c(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <fwrite@plt>
test   %ebx,%ebx
jle    1242 <genData+0x122>
lea    0x18(%rsp),%r15
lea    0x14(%rsp),%r12
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <f_rand@plt>
mulss  0xe41(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
xor    %eax,%eax
call   1030 <f_rand@plt>
mulss  0x8(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,0x18(%rsp)
mulss  %xmm1,%xmm1
movss  %xmm1,0x10(%rsp)
xor    %eax,%eax
call   1030 <f_rand@plt>
mulss  0x8(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
mulss  0xc(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x14(%rsp)
mov    %r15,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <fwrite@plt>
mov    %r12,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <fwrite@plt>
add    $0xffffffff,%ebx
jne    11b0 <genData+0x90>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @genData(i32* %0, i32 %1, float %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca i32
%14 = alloca float
%15 = alloca float
%16 = alloca float
store i32* %0, i32** %4
store i32 %1, i32* %5
store float %2, float* %6
store float 0x3FF19999A0000000, float* %7
%17 = load float, float* %7
%18 = fneg float %17
store float %18, float* %8
%19 = load float, float* %7
%20 = load float, float* %8
%21 = fsub float %19, %20
store float %21, float* %9
store float 2.000000e+00, float* %10
%22 = load i32*, i32** %4
%23 = call i32 @fwrite(float* %10, i32 4, i32 1, i32* %22)
store float 0.000000e+00, float* %11
%24 = load i32*, i32** %4
%25 = call i32 @fwrite(float* %11, i32 4, i32 1, i32* %24)
%26 = load i32, i32* %5
%27 = sitofp i32 %26 to float
store float %27, float* %12
%28 = load i32*, i32** %4
%29 = call i32 @fwrite(float* %12, i32 4, i32 1, i32* %28)
store i32 0, i32* %13
br label %30
30: ; preds = %54, %3
%31 = load i32, i32* %13
%32 = load i32, i32* %5
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %57
34: ; preds = %30
%35 = load float, float* %9
%36 = call float (...) @f_rand()
%37 = fmul float %35, %36
store float %37, float* %14
%38 = load float, float* %14
%39 = load float, float* %6
%40 = call float (...) @f_rand()
%41 = call float @llvm.fmuladd.f32(float %39, float %40, float %38)
store float %41, float* %15
%42 = load float, float* %14
%43 = load float, float* %14
%44 = fmul float %42, %43
%45 = load float, float* %14
%46 = load float, float* %6
%47 = call float (...) @f_rand()
%48 = fmul float %46, %47
%49 = call float @llvm.fmuladd.f32(float %44, float %45, float %48)
store float %49, float* %16
%50 = load i32*, i32** %4
%51 = call i32 @fwrite(float* %15, i32 4, i32 1, i32* %50)
%52 = load i32*, i32** %4
%53 = call i32 @fwrite(float* %16, i32 4, i32 1, i32* %52)
br label %54
54: ; preds = %34
%55 = load i32, i32* %13
%56 = add nsw i32 %55, 1
store i32 %56, i32* %13
br label %30
57: ; preds = %30
ret void
}

LLVM IR (-O2):
define void @genData(i32* nocapture %0, i32 %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = bitcast float* %4 to i8*
store float 2.000000e+00, float* %4
%10 = call i32 @fwrite(float* %4, i32 4, i32 1, i32* %0)
%11 = bitcast float* %5 to i8*
store float 0.000000e+00, float* %5
%12 = call i32 @fwrite(float* %5, i32 4, i32 1, i32* %0)
%13 = bitcast float* %6 to i8*
%14 = sitofp i32 %1 to float
store float %14, float* %6
%15 = call i32 @fwrite(float* %6, i32 4, i32 1, i32* %0)
%16 = icmp sgt i32 %1, 0
br i1 %16, label %17, label %20
17: ; preds = %3
%18 = bitcast float* %7 to i8*
%19 = bitcast float* %8 to i8*
br label %21
20: ; preds = %21, %3
ret void
21: ; preds = %17, %21
%22 = phi i32 [ 0, %17 ], [ %33, %21 ]
%23 = tail call float (...) @f_rand()
%24 = fmul float %23, 0x40019999A0000000
%25 = tail call float (...) @f_rand()
%26 = tail call float @llvm.fmuladd.f32(float %2, float %25, float %24)
store float %26, float* %7
%27 = fmul float %24, %24
%28 = tail call float (...) @f_rand()
%29 = fmul float %28, %2
%30 = tail call float @llvm.fmuladd.f32(float %27, float %24, float %29)
store float %30, float* %8
%31 = call i32 @fwrite(float* %7, i32 4, i32 1, i32* %0)
%32 = call i32 @fwrite(float* %8, i32 4, i32 1, i32* %0)
%33 = add nuw nsw i32 %22, 1
%34 = icmp eq i32 %33, %1
br i1 %34, label %20, label %21
}