#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 */
int /*<<< orphan*/ fabsf(float);
float fmaxf(float, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, float);
int scanf(char *, float *);
int main(void) {
  unsigned long sample_number = 0;
  float sample_value;
  float running_peak = 0;
  float output_peak = 0;
  while (scanf("%f", &sample_value) == 1) {
    running_peak = fmaxf(running_peak, fabsf(sample_value));
    printf("%f\n", output_peak);
    sample_number++;
    if (sample_number % (44100 * 50 / 1000) == 0) {
      output_peak = running_peak;
      running_peak = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
lea    0xe92(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    11f1 <main+0xb1>
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x14(%rbp),%xmm0
call   1030 <fabsf@plt>
movss  -0x20(%rbp),%xmm0
mov    %eax,%edi
call   1050 <fmaxf@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x1c(%rbp),%xmm0
lea    0xe52(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x89d,%ecx
xor    %edx,%edx
div    %rcx
cmp    $0x0,%rdx
jne    11ec <main+0xac>
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    1167 <main+0x27>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeab(%rip),%rdi
lea    0x14(%rsp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    1227 <main+0xe7>
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
mov    $0xffffffffffffffff,%r13
mov    $0x1,%ebx
lea    0xe7f(%rip),%r14
lea    0xe75(%rip),%r15
lea    0x14(%rsp),%r12
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
jmp    11c4 <main+0x84>
nopl   0x0(%rax,%rax,1)
movss  0x10(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
add    $0xffffffffffffffff,%r13
add    $0x1,%rbx
cmp    $0x1,%eax
jne    1227 <main+0xe7>
mov    %rbx,%rax
movabs $0x76e2dbe499b75251,%rcx
db e2 76
mul    %rcx
shr    $0xa,%rdx
imul   $0x89d,%rdx,%rbp
movss  0x14(%rsp),%xmm0
call   1030 <fabsf@plt>
movss  0x8(%rsp),%xmm0
mov    %eax,%edi
call   1050 <fmaxf@plt>
movss  %xmm0,0x10(%rsp)
mov    %r14,%rdi
movss  0xc(%rsp),%xmm0
call   1040 <printf@plt>
add    %r13,%rbp
jne    11a0 <main+0x60>
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
movss  0x10(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
jmp    11ac <main+0x6c>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%f\00"
@.str.1 = [4 x i8] c"%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca float
%4 = alloca float
%5 = alloca float
store i32 0, i32* %1
store i64 0, i64* %2
store float 0.000000e+00, float* %4
store float 0.000000e+00, float* %5
br label %6
6: ; preds = %23, %0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %3)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %24
9: ; preds = %6
%10 = load float, float* %4
%11 = load float, float* %3
%12 = call i32 @fabsf(float %11)
%13 = call float @fmaxf(float %10, i32 %12)
store float %13, float* %4
%14 = load float, float* %5
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), float %14)
%16 = load i64, i64* %2
%17 = add i64 %16, 1
store i64 %17, i64* %2
%18 = load i64, i64* %2
%19 = urem i64 %18, 2205
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %9
%22 = load float, float* %4
store float %22, float* %5
store float 0.000000e+00, float* %4
br label %23
23: ; preds = %21, %9
br label %6
24: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%f\00"
@.str.1 = [4 x i8] c"%f\0A\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %1)
%4 = icmp eq i32 %3, 1
br i1 %4, label %5, label %20
5: ; preds = %0, %5
%6 = phi float [ %17, %5 ], [ 0.000000e+00, %0 ]
%7 = phi float [ %16, %5 ], [ 0.000000e+00, %0 ]
%8 = phi i64 [ %13, %5 ], [ 0, %0 ]
%9 = load float, float* %1
%10 = call i32 @fabsf(float %9)
%11 = call float @fmaxf(float %7, i32 %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), float %6)
%13 = add i64 %8, 1
%14 = urem i64 %13, 2205
%15 = icmp eq i64 %14, 0
%16 = select i1 %15, float 0.000000e+00, float %11
%17 = select i1 %15, float %11, float %6
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %1)
%19 = icmp eq i32 %18, 1
br i1 %19, label %5, label %20
20: ; preds = %5, %0
ret i32 0
}