#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(double);
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, j, 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.283185307 / pitch;
      L = floor(3.141592654 / Wo);
      for (m = 0; m < 80; m++) {
        sparse_pe[m] = 0.0;
      }
      for (m = 1; m <= L; m++) {
        index = 80 * m * Wo / 3.141592654;
        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    $0x190,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed7(%rip),%rdi
lea    0xedc(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x30d40,-0x14(%rbp)
jge    1362 <main+0x212>
movss  0xe6b(%rip),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe65(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     134f <main+0x1ff>
mov    $0x0,%al
call   1070 <rand@plt>
cvtsd2ss %xmm0,%xmm0
mov    0x2e21(%rip),%rax
divss  (%rax),%xmm0
movss  0xe31(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe29(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe27(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x34(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe01(%rip),%xmm0
divsd  %xmm1,%xmm0
call   1060 <floor@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x50,-0x1c(%rbp)
jge    1252 <main+0x102>
movslq -0x1c(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,-0x180(%rbp,%rax,4)
ff ff
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    122a <main+0xda>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     131e <main+0x1ce>
imul   $0x50,-0x1c(%rbp),%eax
cvtsi2ss %eax,%xmm0
mulss  -0x34(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd9a(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x50,-0x24(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x188(%rbp)
ff
mov    $0x0,%al
call   1070 <rand@plt>
movsd  -0x188(%rbp),%xmm1
ff
movsd  0xd76(%rip),%xmm2
mulsd  %xmm0,%xmm2
mov    0x2d1b(%rip),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  %xmm0,%xmm2
movsd  0xd4f(%rip),%xmm0
subsd  %xmm2,%xmm0
movsd  0xd3b(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x2c(%rbp),%xmm0
movslq -0x24(%rbp),%rax
movss  %xmm0,-0x180(%rbp,%rax,4)
ff ff
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1259 <main+0x109>
lea    -0x180(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x4,%esi
mov    $0xa,%edx
call   1050 <fwrite@plt>
movss  0xcc0(%rip),%xmm0
addss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
jmp    119a <main+0x4a>
jmp    1354 <main+0x204>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1180 <main+0x30>
xor    %eax,%eax
add    $0x190,%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    0xeb8(%rip),%rdi
lea    0xebd(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
movsd  0xe81(%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  0xe5c(%rip),%xmm0
je     1315 <main+0x1b5>
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  0xe0a(%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
cvtss2sd %xmm0,%xmm0
movsd  0xdd8(%rip),%xmm1
divsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,0x14(%rsp)
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xdc0(%rip),%xmm0
divsd  %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
nopw   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  0xd77(%rip),%xmm0
cvttsd2si %xmm0,%r12d
xor    %edi,%edi
cmp    $0x50,%r12d
setl   %dil
call   1040 <assert@plt>
xor    %eax,%eax
call   1080 <rand@plt>
movsd  0xd44(%rip),%xmm2
addsd  %xmm0,%xmm0
movss  0x0(%r13),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
movapd %xmm2,%xmm1
movsd  0xd3e(%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    1290 <main+0x130>
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 i32
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca [80 x float]
store i32 0, i32* %1
%13 = 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* %13, i32** %2
store i32 0, i32* %3
br label %14
14: ; preds = %89, %0
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, 200000
br i1 %16, label %17, label %92
17: ; preds = %14
store float 1.000000e+00, float* %8
br label %18
18: ; preds = %85, %17
%19 = load float, float* %8
%20 = fpext float %19 to double
%21 = fcmp ole double %20, 8.000000e+00
br i1 %21, label %22, label %88
22: ; preds = %18
%23 = call double (...) @rand()
%24 = fptrunc double %23 to float
%25 = load float, float* @RAND_MAX
%26 = fdiv float %24, %25
%27 = call float @llvm.fmuladd.f32(float 1.400000e+02, float %26, float 2.000000e+01)
store float %27, float* %10
%28 = load float, float* %10
%29 = fpext float %28 to double
%30 = fdiv double 0x401921FB54411744, %29
%31 = fptrunc double %30 to float
store float %31, float* %11
%32 = load float, float* %11
%33 = fpext float %32 to double
%34 = fdiv double 0x400921FB54524550, %33
%35 = call i32 @floor(double %34)
store i32 %35, i32* %6
store i32 0, i32* %5
br label %36
36: ; preds = %43, %22
%37 = load i32, i32* %5
%38 = icmp slt i32 %37, 80
br i1 %38, label %39, label %46
39: ; preds = %36
%40 = load i32, i32* %5
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [80 x float], [80 x float]* %12, i64 0, i64 %41
store float 0.000000e+00, float* %42
br label %43
43: ; preds = %39
%44 = load i32, i32* %5
%45 = add nsw i32 %44, 1
store i32 %45, i32* %5
br label %36
46: ; preds = %36
store i32 1, i32* %5
br label %47
47: ; preds = %78, %46
%48 = load i32, i32* %5
%49 = load i32, i32* %6
%50 = icmp sle i32 %48, %49
br i1 %50, label %51, label %81
51: ; preds = %47
%52 = load i32, i32* %5
%53 = mul nsw i32 80, %52
%54 = sitofp i32 %53 to float
%55 = load float, float* %11
%56 = fmul float %54, %55
%57 = fpext float %56 to double
%58 = fdiv double %57, 0x400921FB54524550
%59 = fptosi double %58 to i32
store i32 %59, i32* %7
%60 = load i32, i32* %7
%61 = icmp slt i32 %60, 80
%62 = zext i1 %61 to i32
%63 = call i32 @assert(i32 %62)
%64 = load float, float* %8
%65 = fpext float %64 to double
%66 = call double (...) @rand()
%67 = fmul double 2.000000e+00, %66
%68 = load float, float* @RAND_MAX
%69 = fpext float %68 to double
%70 = fdiv double %67, %69
%71 = fsub double 1.000000e+00, %70
%72 = call double @llvm.fmuladd.f64(double 2.000000e-01, double %71, double %65)
%73 = fptrunc double %72 to float
store float %73, float* %9
%74 = load float, float* %9
%75 = load i32, i32* %7
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [80 x float], [80 x float]* %12, i64 0, i64 %76
store float %74, float* %77
br label %78
78: ; preds = %51
%79 = load i32, i32* %5
%80 = add nsw i32 %79, 1
store i32 %80, i32* %5
br label %47
81: ; preds = %47
%82 = getelementptr inbounds [80 x float], [80 x float]* %12, i64 0, i64 0
%83 = load i32*, i32** %2
%84 = call i32 @fwrite(float* %82, i32 4, i32 10, i32* %83)
br label %85
85: ; preds = %81
%86 = load float, float* %8
%87 = fadd float %86, 1.000000e+00
store float %87, float* %8
br label %18
88: ; preds = %18
br label %89
89: ; preds = %88
%90 = load i32, i32* %3
%91 = add nsw i32 %90, 1
store i32 %91, i32* %3
br label %14
92: ; preds = %14
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, %50
%6 = phi i32 [ 0, %0 ], [ %51, %50 ]
br label %7
7: ; preds = %5, %45
%8 = phi double [ 1.000000e+00, %5 ], [ %48, %45 ]
%9 = phi float [ 1.000000e+00, %5 ], [ %47, %45 ]
%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 = fpext float %14 to double
%16 = fdiv double 0x401921FB54411744, %15
%17 = fptrunc double %16 to float
%18 = fpext float %17 to double
%19 = fdiv double 0x400921FB54524550, %18
%20 = tail call i32 @floor(double %19)
%21 = icmp slt i32 %20, 1
br i1 %21, label %45, label %22
22: ; preds = %7, %22
%23 = phi i32 [ %43, %22 ], [ 1, %7 ]
%24 = mul nuw nsw i32 %23, 80
%25 = sitofp i32 %24 to float
%26 = fmul float %17, %25
%27 = fpext float %26 to double
%28 = fdiv double %27, 0x400921FB54524550
%29 = fptosi double %28 to i32
%30 = icmp slt i32 %29, 80
%31 = zext i1 %30 to i32
%32 = tail call i32 @assert(i32 %31)
%33 = tail call double (...) @rand()
%34 = fmul double %33, 2.000000e+00
%35 = load float, float* @RAND_MAX
%36 = fpext float %35 to double
%37 = fdiv double %34, %36
%38 = fsub double 1.000000e+00, %37
%39 = tail call double @llvm.fmuladd.f64(double %38, double 2.000000e-01, double %8)
%40 = fptrunc double %39 to float
%41 = sext i32 %29 to i64
%42 = getelementptr inbounds [80 x float], [80 x float]* %1, i64 0, i64 %41
store float %40, float* %42
%43 = add nuw i32 %23, 1
%44 = icmp eq i32 %23, %20
br i1 %44, label %45, label %22
45: ; preds = %22, %7
%46 = call i32 @fwrite(float* %4, i32 4, i32 10, i32* %3)
%47 = fadd float %9, 1.000000e+00
%48 = fpext float %47 to double
%49 = fcmp ugt float %47, 8.000000e+00
br i1 %49, label %50, label %7
50: ; preds = %45
%51 = add nuw nsw i32 %6, 1
%52 = icmp eq i32 %51, 200000
br i1 %52, label %53, label %5
53: ; preds = %50
ret i32 0
}