#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*/ printf(char *, int, ...);
double two_tone_test(int, int, int);
int main(void) {
  int nfft = 4 * 2 * 2 * 3 * 5;
  int i, j;
  double minsnr = 500;
  double maxsnr = -500;
  double snr;
  for (i = 0; i < nfft / 2; ++i) {
    for (j = i; j < nfft / 2; j += 7) {
      snr = two_tone_test(nfft, i, j);
      if (snr < minsnr)
        minsnr = snr;
      if (snr > maxsnr)
        maxsnr = snr;
    }
  }
  snr = two_tone_test(nfft, nfft / 2, nfft / 2);
  if (snr < minsnr)
    minsnr = snr;
  if (snr > maxsnr)
    maxsnr = snr;
  printf("TwoToneTest: snr ranges from %ddB to %ddB\n", (int)minsnr,
         (int)maxsnr);
  printf("sizeof(kiss_fft_scalar) = %d\n", sizeof(float));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xf0,-0x8(%rbp)
movsd  0xeca(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xeb5(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jge    120a <main+0xea>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
cmp    %ecx,%eax
jge    11f7 <main+0xd7>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <two_tone_test@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11ca <main+0xaa>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x28(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11e4 <main+0xc4>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11e9 <main+0xc9>
mov    -0x10(%rbp),%eax
add    $0x7,%eax
mov    %eax,-0x10(%rbp)
jmp    117b <main+0x5b>
jmp    11fc <main+0xdc>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1157 <main+0x37>
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
call   1030 <two_tone_test@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    124f <main+0x12f>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x28(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1269 <main+0x149>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cvttsd2si -0x18(%rbp),%esi
cvttsd2si -0x20(%rbp),%edx
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdb3(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %ebx,%ebx
movsd  0xece(%rip),%xmm1
movsd  0xece(%rip),%xmm0
mov    $0xfffffff9,%r14d
mov    %r14d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x8(%rsp)
add    $0x7,%ebp
mov    $0xf0,%edi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <two_tone_test@plt>
movapd %xmm0,%xmm1
minsd  (%rsp),%xmm1
maxsd  0x8(%rsp),%xmm0
cmp    $0x71,%ebp
jb     1150 <main+0x30>
add    $0x1,%ebx
add    $0x1,%r14d
cmp    $0x78,%ebx
jne    1140 <main+0x20>
mov    $0xf0,%edi
mov    $0x78,%esi
mov    $0x78,%edx
movsd  %xmm0,0x8(%rsp)
movsd  %xmm1,(%rsp)
call   1030 <two_tone_test@plt>
movapd %xmm0,%xmm1
minsd  (%rsp),%xmm1
maxsd  0x8(%rsp),%xmm0
cvttsd2si %xmm1,%esi
cvttsd2si %xmm0,%edx
lea    0xe47(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe64(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"TwoToneTest: snr ranges from %ddB to %ddB\0A\00"
@.str.1 = [30 x i8] c"sizeof(kiss_fft_scalar) = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i32 0, i32* %1
store i32 240, i32* %2
store double 5.000000e+02, double* %5
store double -5.000000e+02, double* %6
store i32 0, i32* %3
br label %8
8: ; preds = %41, %0
%9 = load i32, i32* %3
%10 = load i32, i32* %2
%11 = sdiv i32 %10, 2
%12 = icmp slt i32 %9, %11
br i1 %12, label %13, label %44
13: ; preds = %8
%14 = load i32, i32* %3
store i32 %14, i32* %4
br label %15
15: ; preds = %37, %13
%16 = load i32, i32* %4
%17 = load i32, i32* %2
%18 = sdiv i32 %17, 2
%19 = icmp slt i32 %16, %18
br i1 %19, label %20, label %40
20: ; preds = %15
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = call double @two_tone_test(i32 %21, i32 %22, i32 %23)
store double %24, double* %7
%25 = load double, double* %7
%26 = load double, double* %5
%27 = fcmp olt double %25, %26
br i1 %27, label %28, label %30
28: ; preds = %20
%29 = load double, double* %7
store double %29, double* %5
br label %30
30: ; preds = %28, %20
%31 = load double, double* %7
%32 = load double, double* %6
%33 = fcmp ogt double %31, %32
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = load double, double* %7
store double %35, double* %6
br label %36
36: ; preds = %34, %30
br label %37
37: ; preds = %36
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 7
store i32 %39, i32* %4
br label %15
40: ; preds = %15
br label %41
41: ; preds = %40
%42 = load i32, i32* %3
%43 = add nsw i32 %42, 1
store i32 %43, i32* %3
br label %8
44: ; preds = %8
%45 = load i32, i32* %2
%46 = load i32, i32* %2
%47 = sdiv i32 %46, 2
%48 = load i32, i32* %2
%49 = sdiv i32 %48, 2
%50 = call double @two_tone_test(i32 %45, i32 %47, i32 %49)
store double %50, double* %7
%51 = load double, double* %7
%52 = load double, double* %5
%53 = fcmp olt double %51, %52
br i1 %53, label %54, label %56
54: ; preds = %44
%55 = load double, double* %7
store double %55, double* %5
br label %56
56: ; preds = %54, %44
%57 = load double, double* %7
%58 = load double, double* %6
%59 = fcmp ogt double %57, %58
br i1 %59, label %60, label %62
60: ; preds = %56
%61 = load double, double* %7
store double %61, double* %6
br label %62
62: ; preds = %60, %56
%63 = load double, double* %5
%64 = fptosi double %63 to i32
%65 = load double, double* %6
%66 = fptosi double %65 to i32
%67 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %64, i32 %66)
%68 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 4)
ret i32 0
}

LLVM IR (-O2):
@.str = [43 x i8] c"TwoToneTest: snr ranges from %ddB to %ddB\0A\00"
@.str.1 = [30 x i8] c"sizeof(kiss_fft_scalar) = %d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %16, %0
%2 = phi double [ -5.000000e+02, %0 ], [ %13, %16 ]
%3 = phi double [ 5.000000e+02, %0 ], [ %11, %16 ]
%4 = phi i32 [ 0, %0 ], [ %17, %16 ]
br label %5
5: ; preds = %1, %5
%6 = phi double [ %13, %5 ], [ %2, %1 ]
%7 = phi double [ %11, %5 ], [ %3, %1 ]
%8 = phi i32 [ %14, %5 ], [ %4, %1 ]
%9 = tail call double @two_tone_test(i32 240, i32 %4, i32 %8)
%10 = fcmp olt double %9, %7
%11 = select i1 %10, double %9, double %7
%12 = fcmp ogt double %9, %6
%13 = select i1 %12, double %9, double %6
%14 = add nuw nsw i32 %8, 7
%15 = icmp ult i32 %8, 113
br i1 %15, label %5, label %16
16: ; preds = %5
%17 = add nuw nsw i32 %4, 1
%18 = icmp eq i32 %17, 120
br i1 %18, label %19, label %1
19: ; preds = %16
%20 = tail call double @two_tone_test(i32 240, i32 120, i32 120)
%21 = fcmp olt double %20, %11
%22 = select i1 %21, double %20, double %11
%23 = fcmp ogt double %20, %13
%24 = select i1 %23, double %20, double %13
%25 = fptosi double %22 to i32
%26 = fptosi double %24 to i32
%27 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %25, i32 %26)
%28 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 4)
ret i32 0
}