#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 */
double atof(char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  FILE *f = fopen("result-dft", "r");
  double seuil = 0.2;
  printf("seuil: %lf\n", seuil);
  int echan = 44100 / 2;
  double tab[echan];
  char yolo[64];
  for (int i = 0; i < echan; i++) {
    memset(yolo, '\0', 64);
    fscanf(f, "%s", yolo);
    tab[i] = atof(yolo);
  }
  for (int i = 1; i < echan - 1; i++) {
    if (tab[i] > seuil) {
      if (tab[i] > tab[i - 1] && tab[i] > tab[i + 1]) {
        printf("freq fond: %d\n", i);
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe90(%rip),%rdi
lea    0xe94(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
movabs $0x3fc999999999999a,%rax
99 c9 3f
mov    %rax,-0x20(%rbp)
cvttsd2si -0x20(%rbp),%esi
lea    0xe73(%rip),%rdi
call   1040 <printf@plt>
movl   $0x5622,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x90(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x84(%rbp)
mov    -0x84(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    123d <main+0xed>
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
mov    -0x18(%rbp),%rdi
lea    -0x80(%rbp),%rdx
lea    0xe11(%rip),%rsi
call   1060 <fscanf@plt>
lea    -0x80(%rbp),%rdi
call   1030 <atof@plt>
mov    -0x90(%rbp),%rax
movslq -0x84(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    11da <main+0x8a>
movl   $0x1,-0x88(%rbp)
mov    -0x88(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12fd <main+0x1ad>
mov    -0x90(%rbp),%rax
movslq -0x88(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    12e4 <main+0x194>
mov    -0x90(%rbp),%rax
movslq -0x88(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x88(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
ucomisd (%rax,%rcx,8),%xmm0
jbe    12df <main+0x18f>
mov    -0x90(%rbp),%rax
movslq -0x88(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x88(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
ucomisd (%rax,%rcx,8),%xmm0
jbe    12df <main+0x18f>
mov    -0x88(%rbp),%esi
lea    0xd42(%rip),%rdi
call   1040 <printf@plt>
jmp    12e4 <main+0x194>
jmp    12e9 <main+0x199>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    1247 <main+0xf7>
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x2b158,%rsp
lea    0xea3(%rip),%rdi
lea    0xea7(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
lea    0xe9a(%rip),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
call   1040 <printf@plt>
mov    %rsp,%r12
lea    0xe93(%rip),%r15
xchg   %ax,%ax
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1060 <fscanf@plt>
mov    %r12,%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x40(%rsp,%rbx,8)
add    $0x1,%rbx
cmp    $0x5622,%rbx
jne    1190 <main+0x40>
mov    $0x2,%ebx
movsd  0xe2b(%rip),%xmm1
lea    0xe48(%rip),%r14
jmp    11ed <main+0x9d>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    $0x5622,%rbx
je     121e <main+0xce>
movsd  0x38(%rsp,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    11e0 <main+0x90>
ucomisd 0x30(%rsp,%rbx,8),%xmm0
jbe    11e0 <main+0x90>
ucomisd 0x40(%rsp,%rbx,8),%xmm0
jbe    11e0 <main+0x90>
lea    -0x1(%rbx),%esi
mov    %r14,%rdi
call   1040 <printf@plt>
movsd  0xde4(%rip),%xmm1
jmp    11e0 <main+0x90>
xor    %eax,%eax
add    $0x2b158,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"result-dft\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [12 x i8] c"seuil: %lf\0A\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [15 x i8] c"freq fond: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca double
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca [64 x i8]
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %14, i32** %6
store double 2.000000e-01, double* %7
%15 = load double, double* %7
%16 = fptosi double %15 to i32
%17 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %16)
store i32 22050, i32* %8
%18 = load i32, i32* %8
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %9
%21 = alloca double, i64 %19
store i64 %19, i64* %10
store i32 0, i32* %12
br label %22
22: ; preds = %37, %2
%23 = load i32, i32* %12
%24 = load i32, i32* %8
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %40
26: ; preds = %22
%27 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%28 = call i32 @memset(i8* %27, i8 signext 0, i32 64)
%29 = load i32*, i32** %6
%30 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%31 = call i32 @fscanf(i32* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%33 = call double @atof(i8* %32)
%34 = load i32, i32* %12
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %21, i64 %35
store double %33, double* %36
br label %37
37: ; preds = %26
%38 = load i32, i32* %12
%39 = add nsw i32 %38, 1
store i32 %39, i32* %12
br label %22
40: ; preds = %22
store i32 1, i32* %13
br label %41
41: ; preds = %80, %40
%42 = load i32, i32* %13
%43 = load i32, i32* %8
%44 = sub nsw i32 %43, 1
%45 = icmp slt i32 %42, %44
br i1 %45, label %46, label %83
46: ; preds = %41
%47 = load i32, i32* %13
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %21, i64 %48
%50 = load double, double* %49
%51 = load double, double* %7
%52 = fcmp ogt double %50, %51
br i1 %52, label %53, label %79
53: ; preds = %46
%54 = load i32, i32* %13
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %21, i64 %55
%57 = load double, double* %56
%58 = load i32, i32* %13
%59 = sub nsw i32 %58, 1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %21, i64 %60
%62 = load double, double* %61
%63 = fcmp ogt double %57, %62
br i1 %63, label %64, label %78
64: ; preds = %53
%65 = load i32, i32* %13
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %21, i64 %66
%68 = load double, double* %67
%69 = load i32, i32* %13
%70 = add nsw i32 %69, 1
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds double, double* %21, i64 %71
%73 = load double, double* %72
%74 = fcmp ogt double %68, %73
br i1 %74, label %75, label %78
75: ; preds = %64
%76 = load i32, i32* %13
%77 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %76)
br label %78
78: ; preds = %75, %64, %53
br label %79
79: ; preds = %78, %46
br label %80
80: ; preds = %79
%81 = load i32, i32* %13
%82 = add nsw i32 %81, 1
store i32 %82, i32* %13
br label %41
83: ; preds = %41
%84 = load i8*, i8** %9
%85 = load i32, i32* %3
ret i32 %85
}

LLVM IR (-O2):
@.str = [11 x i8] c"result-dft\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [12 x i8] c"seuil: %lf\0A\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [15 x i8] c"freq fond: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [64 x i8]
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 0)
%6 = alloca [22050 x double]
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
br label %8
8: ; preds = %2, %8
%9 = phi i64 [ 0, %2 ], [ %14, %8 ]
%10 = call i32 @memset(i8* %7, i8 signext 0, i32 64)
%11 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%12 = call double @atof(i8* %7)
%13 = getelementptr inbounds [22050 x double], [22050 x double]* %6, i64 0, i64 %9
store double %12, double* %13
%14 = add nuw nsw i64 %9, 1
%15 = icmp eq i64 %14, 22050
br i1 %15, label %17, label %8
16: ; preds = %35
ret i32 0
17: ; preds = %8, %35
%18 = phi i64 [ %36, %35 ], [ 1, %8 ]
%19 = getelementptr inbounds [22050 x double], [22050 x double]* %6, i64 0, i64 %18
%20 = load double, double* %19
%21 = fcmp ogt double %20, 2.000000e-01
br i1 %21, label %22, label %35
22: ; preds = %17
%23 = add nsw i64 %18, -1
%24 = getelementptr inbounds [22050 x double], [22050 x double]* %6, i64 0, i64 %23
%25 = load double, double* %24
%26 = fcmp ogt double %20, %25
br i1 %26, label %27, label %35
27: ; preds = %22
%28 = add nuw nsw i64 %18, 1
%29 = getelementptr inbounds [22050 x double], [22050 x double]* %6, i64 0, i64 %28
%30 = load double, double* %29
%31 = fcmp ogt double %20, %30
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = trunc i64 %18 to i32
%34 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %17, %32, %27, %22
%36 = add nuw nsw i64 %18, 1
%37 = icmp eq i64 %36, 22049
br i1 %37, label %16, label %17
}