#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 */
typedef struct PeakData TYPE_1__;

/* Type definitions */
struct PeakData {
  float min;
  float max;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
float atof(char *);
float fabsf(float);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ fread(TYPE_1__ *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int c = 0, d = 0;
  float thresh = -1.f;
  if (argc < 2 || argc > 3) {
    fprintf(stderr, "usage: %s [threshold] <peakfile>\n", argv[0]);
    return -1;
  }
  if (argc == 3) {
    thresh = atof(argv[1]);
  }
  FILE *F = fopen(argv[argc - 1], "r");
  if (!F) {
    fprintf(stderr, "Cannot open file '%s'\n", argv[argc - 1]);
    return -1;
  }
  printf("   #    )   audio sample range   :   MIN    MAX\n");
  while (!feof(F)) {
    struct PeakData {
      float min;
      float max;
    } buf;
    if (fread(&buf, sizeof(struct PeakData), 1, F) <= 0) {
      break;
    }
    if (fabsf(buf.min) > thresh || fabsf(buf.max) > thresh) {
      printf("%8d) %10d - %10d: %+.3f %+.3f\n", ++d, 256 * c, 256 * (c + 1) - 1,
             buf.min, buf.max);
    }
    ++c;
  }
  fclose(F);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movss  0xe64(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     11b5 <main+0x45>
cmpl   $0x3,-0x8(%rbp)
jle    11dd <main+0x6d>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe54(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1336 <main+0x1c6>
cmpl   $0x3,-0x8(%rbp)
jne    11f9 <main+0x89>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atof@plt>
movss  %xmm0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe31(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1257 <main+0xe7>
mov    0x2db4(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xdfe(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1336 <main+0x1c6>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1283 <main+0x113>
jmp    1326 <main+0x1b6>
lea    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x8,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x0,%rax
jg     12a9 <main+0x139>
jmp    1326 <main+0x1b6>
movss  -0x30(%rbp),%xmm0
movaps 0xd5b(%rip),%xmm1
pand   %xmm1,%xmm0
ucomiss -0x1c(%rbp),%xmm0
ja     12dd <main+0x16d>
movss  -0x2c(%rbp),%xmm0
movaps 0xd41(%rip),%xmm1
pand   %xmm1,%xmm0
ucomiss -0x1c(%rbp),%xmm0
jbe    1318 <main+0x1a8>
mov    -0x18(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x18(%rbp)
mov    -0x14(%rbp),%edx
shl    $0x8,%edx
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
shl    $0x8,%ecx
sub    $0x1,%ecx
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x2c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd7b(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1265 <main+0xf5>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
lea    -0x4(%rbp),%eax
cmp    $0xfffffffd,%eax
ja     11ae <main+0x2e>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xe74(%rip),%rsi
jmp    121f <main+0x9f>
cmp    $0x3,%ebp
jne    11be <main+0x3e>
mov    0x8(%r14),%rdi
call   1050 <atof@plt>
jmp    11c6 <main+0x46>
movss  0xe3a(%rip),%xmm0
movss  %xmm0,0x4(%rsp)
add    $0xffffffff,%ebp
mov    (%r14,%rbp,8),%rdi
lea    0xe68(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     120b <main+0x8b>
mov    %rax,%rbx
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1090 <feof@plt>
test   %eax,%eax
je     1236 <main+0xb6>
mov    %rbx,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
jmp    1229 <main+0xa9>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
mov    (%r14,%rbp,8),%rdx
lea    0xe25(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r14d,%r14d
mov    $0xff,%ebp
lea    0x8(%rsp),%r15
lea    0xe11(%rip),%r12
jmp    1287 <main+0x107>
nopl   0x0(%rax)
add    $0x1,%r14d
lea    -0xff(%rbp),%edx
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
mov    %r12,%rdi
mov    %r14d,%esi
mov    %ebp,%ecx
mov    $0x2,%al
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1090 <feof@plt>
add    $0x100,%ebp
test   %eax,%eax
jne    11ff <main+0x7f>
mov    %r15,%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
test   %rax,%rax
jle    11ff <main+0x7f>
movss  0x8(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
movaps %xmm0,%xmm2
movaps 0xd55(%rip),%xmm4
andps  %xmm4,%xmm2
movss  0x4(%rsp),%xmm3
ucomiss %xmm3,%xmm2
ja     1250 <main+0xd0>
movaps %xmm1,%xmm2
andps  %xmm4,%xmm2
ucomiss %xmm3,%xmm2
jbe    1271 <main+0xf1>
jmp    1250 <main+0xd0>

LLVM IR (-O0):
%struct.PeakData = type { float, float }
%struct.PeakData.0 = type { float, float }
@stderr = global i32 0
@.str = [34 x i8] c"usage: %s [threshold] <peakfile>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [23 x i8] c"Cannot open file '%s'\0A\00"
@.str.3 = [49 x i8] c" # ) audio sample range : MIN MAX\0A\00"
@.str.4 = [31 x i8] c"%8d) %10d - %10d: %+.3f %+.3f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca float
%9 = alloca i32*
%10 = alloca %struct.PeakData
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store float -1.000000e+00, float* %8
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 3
br i1 %15, label %16, label %22
16: ; preds = %13, %2
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %20)
store i32 -1, i32* %3
br label %96
22: ; preds = %13
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 3
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call float @atof(i8* %28)
store float %29, float* %8
br label %30
30: ; preds = %25, %22
%31 = load i8**, i8*** %5
%32 = load i32, i32* %4
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %31, i64 %34
%36 = load i8*, i8** %35
%37 = call i32* @fopen(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %37, i32** %9
%38 = load i32*, i32** %9
%39 = icmp ne i32* %38, null
br i1 %39, label %49, label %40
40: ; preds = %30
%41 = load i32, i32* @stderr
%42 = load i8**, i8*** %5
%43 = load i32, i32* %4
%44 = sub nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %42, i64 %45
%47 = load i8*, i8** %46
%48 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %47)
store i32 -1, i32* %3
br label %96
49: ; preds = %30
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
br label %51
51: ; preds = %90, %49
%52 = load i32*, i32** %9
%53 = call i32 @feof(i32* %52)
%54 = icmp ne i32 %53, 0
%55 = xor i1 %54, true
br i1 %55, label %56, label %93
56: ; preds = %51
%57 = bitcast %struct.PeakData* %10 to %struct.PeakData.0*
%58 = load i32*, i32** %9
%59 = call i64 @fread(%struct.PeakData.0* %57, i32 8, i32 1, i32* %58)
%60 = icmp sle i64 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %56
br label %93
62: ; preds = %56
%63 = getelementptr inbounds %struct.PeakData, %struct.PeakData* %10, i32 0, i32 0
%64 = load float, float* %63
%65 = call float @llvm.fabs.f32(float %64)
%66 = load float, float* %8
%67 = fcmp ogt float %65, %66
br i1 %67, label %74, label %68
68: ; preds = %62
%69 = getelementptr inbounds %struct.PeakData, %struct.PeakData* %10, i32 0, i32 1
%70 = load float, float* %69
%71 = call float @llvm.fabs.f32(float %70)
%72 = load float, float* %8
%73 = fcmp ogt float %71, %72
br i1 %73, label %74, label %90
74: ; preds = %68, %62
%75 = load i32, i32* %7
%76 = add nsw i32 %75, 1
store i32 %76, i32* %7
%77 = load i32, i32* %6
%78 = mul nsw i32 256, %77
%79 = load i32, i32* %6
%80 = add nsw i32 %79, 1
%81 = mul nsw i32 256, %80
%82 = sub nsw i32 %81, 1
%83 = getelementptr inbounds %struct.PeakData, %struct.PeakData* %10, i32 0, i32 0
%84 = load float, float* %83
%85 = fpext float %84 to double
%86 = getelementptr inbounds %struct.PeakData, %struct.PeakData* %10, i32 0, i32 1
%87 = load float, float* %86
%88 = fpext float %87 to double
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %76, i32 %78, i32 %82, double %85, double %88)
br label %90
90: ; preds = %74, %68
%91 = load i32, i32* %6
%92 = add nsw i32 %91, 1
store i32 %92, i32* %6
br label %51
93: ; preds = %61, %51
%94 = load i32*, i32** %9
%95 = call i32 @fclose(i32* %94)
store i32 0, i32* %3
br label %96
96: ; preds = %93, %40, %16
%97 = load i32, i32* %3
ret i32 %97
}

LLVM IR (-O2):
%struct.PeakData = type { float, float }
%struct.PeakData.0 = type { float, float }
@stderr = global i32 0
@.str = [34 x i8] c"usage: %s [threshold] <peakfile>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [23 x i8] c"Cannot open file '%s'\0A\00"
@.str.4 = [31 x i8] c"%8d) %10d - %10d: %+.3f %+.3f\0A\00"
@str = [48 x i8] c" # ) audio sample range : MIN MAX\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.PeakData
%4 = add i32 %0, -4
%5 = icmp ult i32 %4, -2
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %65
10: ; preds = %2
%11 = icmp eq i32 %0, 3
br i1 %11, label %12, label %16
12: ; preds = %10
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call float @atof(i8* %14)
br label %16
16: ; preds = %12, %10
%17 = phi float [ %15, %12 ], [ -1.000000e+00, %10 ]
%18 = add nsw i32 %0, -1
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %1, i64 %19
%21 = load i8*, i8** %20
%22 = tail call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %28
24: ; preds = %16
%25 = load i32, i32* @stderr
%26 = load i8*, i8** %20
%27 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %26)
br label %65
28: ; preds = %16
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
%30 = tail call i32 @feof(i32* %22)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %63
32: ; preds = %28
%33 = bitcast %struct.PeakData* %3 to i8*
%34 = bitcast %struct.PeakData* %3 to %struct.PeakData.0*
%35 = getelementptr inbounds %struct.PeakData, %struct.PeakData* %3, i64 0, i32 0
%36 = getelementptr inbounds %struct.PeakData, %struct.PeakData* %3, i64 0, i32 1
br label %37
37: ; preds = %32, %58
%38 = phi i32 [ 0, %32 ], [ %59, %58 ]
%39 = phi i32 [ 0, %32 ], [ %60, %58 ]
%40 = call i64 @fread(%struct.PeakData.0* %34, i32 8, i32 1, i32* %22)
%41 = icmp slt i64 %40, 1
br i1 %41, label %42, label %43
42: ; preds = %37
br label %63
43: ; preds = %37
%44 = load float, float* %35
%45 = tail call float @llvm.fabs.f32(float %44)
%46 = fcmp ogt float %45, %17
%47 = load float, float* %36
%48 = tail call float @llvm.fabs.f32(float %47)
%49 = fcmp ogt float %48, %17
%50 = select i1 %46, i1 true, i1 %49
br i1 %50, label %51, label %58
51: ; preds = %43
%52 = add nsw i32 %38, 1
%53 = shl nsw i32 %39, 8
%54 = or i32 %53, 255
%55 = fpext float %44 to double
%56 = fpext float %47 to double
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %52, i32 %53, i32 %54, double %55, double %56)
br label %58
58: ; preds = %43, %51
%59 = phi i32 [ %52, %51 ], [ %38, %43 ]
%60 = add nuw nsw i32 %39, 1
%61 = tail call i32 @feof(i32* %22)
%62 = icmp eq i32 %61, 0
br i1 %62, label %37, label %63
63: ; preds = %58, %28, %42
%64 = tail call i32 @fclose(i32* %22)
br label %65
65: ; preds = %24, %63, %6
%66 = phi i32 [ -1, %6 ], [ 0, %63 ], [ -1, %24 ]
ret i32 %66
}