#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
float RAND_MAX;
int /*<<< orphan*/ assert(int);
int floor(float);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(float *, int, int, int /*<<< orphan*/ *);
double rand();
int main(void) {
  FILE *f = fopen("testamp.flt", "wb");
  int i, m, L, index;
  float amp, noisey_amp, pitch, Wo;
  float sparse_pe[80];
  for (i = 0; i < 200000; i++) {
    for (amp = 1.0; amp <= 8.0; amp++) {
      pitch = 20 + (160 - 20) * ((float)rand() / RAND_MAX);
      Wo = 6.283185307f / pitch;
      L = floor(3.141592654f / Wo);
      for (m = 0; m < 80; m++) {
        sparse_pe[m] = 0.0;
      }
      for (m = 1; m <= L; m++) {
        index = 80 * m * Wo / 3.141592654f;
        assert(index < 80);
        noisey_amp = amp + 0.2 * (1.0 - 2.0 * rand() / RAND_MAX);
        sparse_pe[index] = noisey_amp;
      }
      fwrite(sparse_pe, sizeof(float), 80 / 8, f);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x180,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xecf(%rip),%rdi
lea    0xed4(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x30d40,-0x14(%rbp)
jge    134a <main+0x1fa>
movss  0xe6b(%rip),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe6d(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1337 <main+0x1e7>
mov    $0x0,%al
call   1070 <rand@plt>
cvtsd2ss %xmm0,%xmm0
mov    0x2e21(%rip),%rax
divss  (%rax),%xmm0
movss  0xe39(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe31(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  0xe18(%rip),%xmm0
divss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  0xe02(%rip),%xmm0
divss  -0x30(%rbp),%xmm0
call   1060 <floor@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x50,-0x18(%rbp)
jge    123e <main+0xee>
movslq -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,-0x170(%rbp,%rax,4)
ff ff
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1216 <main+0xc6>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     1306 <main+0x1b6>
imul   $0x50,-0x18(%rbp),%eax
cvtsi2ss %eax,%xmm0
mulss  -0x30(%rbp),%xmm0
movss  0xd9e(%rip),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x50,-0x20(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x178(%rbp)
ff
mov    $0x0,%al
call   1070 <rand@plt>
movsd  -0x178(%rbp),%xmm1
ff
movsd  0xd86(%rip),%xmm2
mulsd  %xmm0,%xmm2
mov    0x2d33(%rip),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  %xmm0,%xmm2
movsd  0xd5f(%rip),%xmm0
subsd  %xmm2,%xmm0
movsd  0xd4b(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
movslq -0x20(%rbp),%rax
movss  %xmm0,-0x170(%rbp,%rax,4)
ff ff
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1245 <main+0xf5>
lea    -0x170(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x4,%esi
mov    $0xa,%edx
call   1050 <fwrite@plt>
movss  0xcd8(%rip),%xmm0
addss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
jmp    119a <main+0x4a>
jmp    133c <main+0x1ec>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1180 <main+0x30>
xor    %eax,%eax
add    $0x180,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x168,%rsp
lea    0xeb0(%rip),%rdi
lea    0xeb5(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
movsd  0xe89(%rip),%xmm0
mov    0x2e52(%rip),%r13
lea    0x20(%rsp),%r15
xor    %eax,%eax
jmp    11ba <main+0x5a>
nop
mov    0xc(%rsp),%eax
add    $0x1,%eax
cmp    $0x30d40,%eax
movsd  0xe64(%rip),%xmm0
je     1301 <main+0x1a1>
mov    %eax,0xc(%rsp)
movaps %xmm0,%xmm2
movss  0xe37(%rip),%xmm1
jmp    1207 <main+0xa7>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x4,%esi
mov    $0xa,%edx
mov    %r14,%rcx
call   1060 <fwrite@plt>
movss  0x10(%rsp),%xmm1
addss  0xe0d(%rip),%xmm1
xorps  %xmm2,%xmm2
cvtss2sd %xmm1,%xmm2
movss  0xe12(%rip),%xmm0
ucomiss %xmm1,%xmm0
jb     11a0 <main+0x40>
movsd  %xmm2,0x18(%rsp)
movss  %xmm1,0x10(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
cvtsd2ss %xmm0,%xmm0
divss  0x0(%r13),%xmm0
mulss  0xdd8(%rip),%xmm0
addss  0xdd4(%rip),%xmm0
movss  0xdd0(%rip),%xmm1
divss  %xmm0,%xmm1
movss  0xdc8(%rip),%xmm0
movss  %xmm1,0x14(%rsp)
divss  %xmm1,%xmm0
call   1070 <floor@plt>
mov    %eax,%ebp
mov    $0x140,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
test   %ebp,%ebp
jle    11d0 <main+0x70>
mov    $0x50,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0x14(%rsp),%xmm0
divss  0xd7b(%rip),%xmm0
cvttss2si %xmm0,%r12d
xor    %edi,%edi
cmp    $0x50,%r12d
setl   %dil
call   1040 <assert@plt>
xor    %eax,%eax
call   1080 <rand@plt>
movsd  0xd60(%rip),%xmm2
addsd  %xmm0,%xmm0
movss  0x0(%r13),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
movapd %xmm2,%xmm1
movsd  0xd4a(%rip),%xmm2
subsd  %xmm0,%xmm1
mulsd  %xmm2,%xmm1
addsd  0x18(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movslq %r12d,%rax
movss  %xmm0,0x20(%rsp,%rax,4)
add    $0x50,%ebx
add    $0xffffffff,%ebp
jne    1280 <main+0x120>
jmp    11d0 <main+0x70>
xor    %eax,%eax
add    $0x168,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"testamp.flt\00"
@.str.1 = [3 x i8] c"wb\00"
@RAND_MAX = global float 0.000000e+00
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca [80 x float]
store i32 0, i32* %1
%12 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %2
store i32 0, i32* %3
br label %13
13: ; preds = %84, %0
%14 = load i32, i32* %3
%15 = icmp slt i32 %14, 200000
br i1 %15, label %16, label %87
16: ; preds = %13
store float 1.000000e+00, float* %7
br label %17
17: ; preds = %80, %16
%18 = load float, float* %7
%19 = fpext float %18 to double
%20 = fcmp ole double %19, 8.000000e+00
br i1 %20, label %21, label %83
21: ; preds = %17
%22 = call double (...) @rand()
%23 = fptrunc double %22 to float
%24 = load float, float* @RAND_MAX
%25 = fdiv float %23, %24
%26 = call float @llvm.fmuladd.f32(float 1.400000e+02, float %25, float 2.000000e+01)
store float %26, float* %9
%27 = load float, float* %9
%28 = fdiv float 0x401921FB60000000, %27
store float %28, float* %10
%29 = load float, float* %10
%30 = fdiv float 0x400921FB60000000, %29
%31 = call i32 @floor(float %30)
store i32 %31, i32* %5
store i32 0, i32* %4
br label %32
32: ; preds = %39, %21
%33 = load i32, i32* %4
%34 = icmp slt i32 %33, 80
br i1 %34, label %35, label %42
35: ; preds = %32
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [80 x float], [80 x float]* %11, i64 0, i64 %37
store float 0.000000e+00, float* %38
br label %39
39: ; preds = %35
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %32
42: ; preds = %32
store i32 1, i32* %4
br label %43
43: ; preds = %73, %42
%44 = load i32, i32* %4
%45 = load i32, i32* %5
%46 = icmp sle i32 %44, %45
br i1 %46, label %47, label %76
47: ; preds = %43
%48 = load i32, i32* %4
%49 = mul nsw i32 80, %48
%50 = sitofp i32 %49 to float
%51 = load float, float* %10
%52 = fmul float %50, %51
%53 = fdiv float %52, 0x400921FB60000000
%54 = fptosi float %53 to i32
store i32 %54, i32* %6
%55 = load i32, i32* %6
%56 = icmp slt i32 %55, 80
%57 = zext i1 %56 to i32
%58 = call i32 @assert(i32 %57)
%59 = load float, float* %7
%60 = fpext float %59 to double
%61 = call double (...) @rand()
%62 = fmul double 2.000000e+00, %61
%63 = load float, float* @RAND_MAX
%64 = fpext float %63 to double
%65 = fdiv double %62, %64
%66 = fsub double 1.000000e+00, %65
%67 = call double @llvm.fmuladd.f64(double 2.000000e-01, double %66, double %60)
%68 = fptrunc double %67 to float
store float %68, float* %8
%69 = load float, float* %8
%70 = load i32, i32* %6
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [80 x float], [80 x float]* %11, i64 0, i64 %71
store float %69, float* %72
br label %73
73: ; preds = %47
%74 = load i32, i32* %4
%75 = add nsw i32 %74, 1
store i32 %75, i32* %4
br label %43
76: ; preds = %43
%77 = getelementptr inbounds [80 x float], [80 x float]* %11, i64 0, i64 0
%78 = load i32*, i32** %2
%79 = call i32 @fwrite(float* %77, i32 4, i32 10, i32* %78)
br label %80
80: ; preds = %76
%81 = load float, float* %7
%82 = fadd float %81, 1.000000e+00
store float %82, float* %7
br label %17
83: ; preds = %17
br label %84
84: ; preds = %83
%85 = load i32, i32* %3
%86 = add nsw i32 %85, 1
store i32 %86, i32* %3
br label %13
87: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"testamp.flt\00"
@.str.1 = [3 x i8] c"wb\00"
@RAND_MAX = global float 0.000000e+00
define i32 @main() {
%1 = alloca [80 x float]
%2 = bitcast [80 x float]* %1 to i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = getelementptr inbounds [80 x float], [80 x float]* %1, i64 0, i64 0
br label %5
5: ; preds = %0, %46
%6 = phi i32 [ 0, %0 ], [ %47, %46 ]
br label %7
7: ; preds = %5, %41
%8 = phi double [ 1.000000e+00, %5 ], [ %44, %41 ]
%9 = phi float [ 1.000000e+00, %5 ], [ %43, %41 ]
%10 = tail call double (...) @rand()
%11 = fptrunc double %10 to float
%12 = load float, float* @RAND_MAX
%13 = fdiv float %11, %12
%14 = tail call float @llvm.fmuladd.f32(float %13, float 1.400000e+02, float 2.000000e+01)
%15 = fdiv float 0x401921FB60000000, %14
%16 = fdiv float 0x400921FB60000000, %15
%17 = tail call i32 @floor(float %16)
%18 = icmp slt i32 %17, 1
br i1 %18, label %41, label %19
19: ; preds = %7, %19
%20 = phi i32 [ %39, %19 ], [ 1, %7 ]
%21 = mul nuw nsw i32 %20, 80
%22 = sitofp i32 %21 to float
%23 = fmul float %15, %22
%24 = fdiv float %23, 0x400921FB60000000
%25 = fptosi float %24 to i32
%26 = icmp slt i32 %25, 80
%27 = zext i1 %26 to i32
%28 = tail call i32 @assert(i32 %27)
%29 = tail call double (...) @rand()
%30 = fmul double %29, 2.000000e+00
%31 = load float, float* @RAND_MAX
%32 = fpext float %31 to double
%33 = fdiv double %30, %32
%34 = fsub double 1.000000e+00, %33
%35 = tail call double @llvm.fmuladd.f64(double %34, double 2.000000e-01, double %8)
%36 = fptrunc double %35 to float
%37 = sext i32 %25 to i64
%38 = getelementptr inbounds [80 x float], [80 x float]* %1, i64 0, i64 %37
store float %36, float* %38
%39 = add nuw i32 %20, 1
%40 = icmp eq i32 %20, %17
br i1 %40, label %41, label %19
41: ; preds = %19, %7
%42 = call i32 @fwrite(float* %4, i32 4, i32 10, i32* %3)
%43 = fadd float %9, 1.000000e+00
%44 = fpext float %43 to double
%45 = fcmp ugt float %43, 8.000000e+00
br i1 %45, label %46, label %7
46: ; preds = %41
%47 = add nuw nsw i32 %6, 1
%48 = icmp eq i32 %47, 200000
br i1 %48, label %49, label %5
49: ; preds = %46
ret i32 0
}