#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 atoi(char *);
int /*<<< orphan*/ printf(char *, int, ...);
double two_tone_test(int, int, int);
int main(int argc, char **argv) {
  int nfft = 4 * 2 * 2 * 3 * 5;
  if (argc > 1)
    nfft = atoi(argv[1]);
  int i, j;
  double minsnr = 500;
  double maxsnr = -500;
  double snr;
  for (i = 0; i < nfft / 2; i += (nfft >> 4) + 1) {
    for (j = i; j < nfft / 2; j += (nfft >> 4) + 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", (int)sizeof(float));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xf0,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1167 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
movsd  0xe99(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe84(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
cmp    %ecx,%eax
jge    1247 <main+0x117>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
cmp    %ecx,%eax
jge    122e <main+0xfe>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1030 <two_tone_test@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11fb <main+0xcb>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x38(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1215 <main+0xe5>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    121a <main+0xea>
mov    -0x14(%rbp),%eax
sar    $0x4,%eax
add    $0x7,%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11ac <main+0x7c>
jmp    1233 <main+0x103>
mov    -0x14(%rbp),%eax
sar    $0x4,%eax
add    $0x1,%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1188 <main+0x58>
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
call   1030 <two_tone_test@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    128c <main+0x15c>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x38(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    12a6 <main+0x176>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
cvttsd2si -0x28(%rbp),%esi
cvttsd2si -0x30(%rbp),%edx
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd76(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jl     1182 <main+0x52>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%r14d
mov    %eax,%r15d
shr    $0x1f,%r15d
add    %eax,%r15d
sar    %r15d
cmp    $0x2,%eax
jge    118e <main+0x5e>
movsd  0xe97(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xe91(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
jmp    1204 <main+0xd4>
mov    $0xf0,%r14d
mov    $0x78,%r15d
mov    %r14d,%r12d
shr    $0x4,%r12d
lea    0x7(%r12),%r13d
add    $0x1,%r12d
movsd  0xe62(%rip),%xmm1
movsd  0xe52(%rip),%xmm0
xor    %ebp,%ebp
mov    %ebp,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
mov    %r14d,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <two_tone_test@plt>
movapd %xmm0,%xmm1
minsd  0x8(%rsp),%xmm1
maxsd  0x10(%rsp),%xmm0
add    %r13d,%ebx
cmp    %r15d,%ebx
jl     11c0 <main+0x90>
add    %r12d,%ebp
cmp    %r15d,%ebp
jl     11b0 <main+0x80>
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
mov    %r14d,%edi
mov    %r15d,%esi
mov    %r15d,%edx
call   1030 <two_tone_test@plt>
movapd %xmm0,%xmm1
minsd  0x8(%rsp),%xmm1
maxsd  0x10(%rsp),%xmm0
cvttsd2si %xmm1,%esi
cvttsd2si %xmm0,%edx
lea    0xddf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdfc(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
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(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 240, i32* %6
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 1
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %6
br label %19
19: ; preds = %14, %2
store double 5.000000e+02, double* %9
store double -5.000000e+02, double* %10
store i32 0, i32* %7
br label %20
20: ; preds = %56, %19
%21 = load i32, i32* %7
%22 = load i32, i32* %6
%23 = sdiv i32 %22, 2
%24 = icmp slt i32 %21, %23
br i1 %24, label %25, label %62
25: ; preds = %20
%26 = load i32, i32* %7
store i32 %26, i32* %8
br label %27
27: ; preds = %49, %25
%28 = load i32, i32* %8
%29 = load i32, i32* %6
%30 = sdiv i32 %29, 2
%31 = icmp slt i32 %28, %30
br i1 %31, label %32, label %55
32: ; preds = %27
%33 = load i32, i32* %6
%34 = load i32, i32* %7
%35 = load i32, i32* %8
%36 = call double @two_tone_test(i32 %33, i32 %34, i32 %35)
store double %36, double* %11
%37 = load double, double* %11
%38 = load double, double* %9
%39 = fcmp olt double %37, %38
br i1 %39, label %40, label %42
40: ; preds = %32
%41 = load double, double* %11
store double %41, double* %9
br label %42
42: ; preds = %40, %32
%43 = load double, double* %11
%44 = load double, double* %10
%45 = fcmp ogt double %43, %44
br i1 %45, label %46, label %48
46: ; preds = %42
%47 = load double, double* %11
store double %47, double* %10
br label %48
48: ; preds = %46, %42
br label %49
49: ; preds = %48
%50 = load i32, i32* %6
%51 = ashr i32 %50, 4
%52 = add nsw i32 %51, 7
%53 = load i32, i32* %8
%54 = add nsw i32 %53, %52
store i32 %54, i32* %8
br label %27
55: ; preds = %27
br label %56
56: ; preds = %55
%57 = load i32, i32* %6
%58 = ashr i32 %57, 4
%59 = add nsw i32 %58, 1
%60 = load i32, i32* %7
%61 = add nsw i32 %60, %59
store i32 %61, i32* %7
br label %20
62: ; preds = %20
%63 = load i32, i32* %6
%64 = load i32, i32* %6
%65 = sdiv i32 %64, 2
%66 = load i32, i32* %6
%67 = sdiv i32 %66, 2
%68 = call double @two_tone_test(i32 %63, i32 %65, i32 %67)
store double %68, double* %11
%69 = load double, double* %11
%70 = load double, double* %9
%71 = fcmp olt double %69, %70
br i1 %71, label %72, label %74
72: ; preds = %62
%73 = load double, double* %11
store double %73, double* %9
br label %74
74: ; preds = %72, %62
%75 = load double, double* %11
%76 = load double, double* %10
%77 = fcmp ogt double %75, %76
br i1 %77, label %78, label %80
78: ; preds = %74
%79 = load double, double* %11
store double %79, double* %10
br label %80
80: ; preds = %78, %74
%81 = load double, double* %9
%82 = fptosi double %81 to i32
%83 = load double, double* %10
%84 = fptosi double %83 to i32
%85 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %82, i32 %84)
%86 = 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(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = sdiv i32 %7, 2
%9 = icmp sgt i32 %7, 1
br i1 %9, label %10, label %34
10: ; preds = %2, %4
%11 = phi i32 [ %8, %4 ], [ 120, %2 ]
%12 = phi i32 [ %7, %4 ], [ 240, %2 ]
%13 = lshr i32 %12, 4
%14 = add nuw nsw i32 %13, 7
%15 = add nuw nsw i32 %13, 1
br label %16
16: ; preds = %31, %10
%17 = phi double [ -5.000000e+02, %10 ], [ %28, %31 ]
%18 = phi double [ 5.000000e+02, %10 ], [ %26, %31 ]
%19 = phi i32 [ 0, %10 ], [ %32, %31 ]
br label %20
20: ; preds = %16, %20
%21 = phi double [ %28, %20 ], [ %17, %16 ]
%22 = phi double [ %26, %20 ], [ %18, %16 ]
%23 = phi i32 [ %29, %20 ], [ %19, %16 ]
%24 = tail call double @two_tone_test(i32 %12, i32 %19, i32 %23)
%25 = fcmp olt double %24, %22
%26 = select i1 %25, double %24, double %22
%27 = fcmp ogt double %24, %21
%28 = select i1 %27, double %24, double %21
%29 = add nuw nsw i32 %14, %23
%30 = icmp slt i32 %29, %11
br i1 %30, label %20, label %31
31: ; preds = %20
%32 = add nuw nsw i32 %15, %19
%33 = icmp slt i32 %32, %11
br i1 %33, label %16, label %34
34: ; preds = %31, %4
%35 = phi i32 [ %8, %4 ], [ %11, %31 ]
%36 = phi i32 [ %7, %4 ], [ %12, %31 ]
%37 = phi double [ 5.000000e+02, %4 ], [ %26, %31 ]
%38 = phi double [ -5.000000e+02, %4 ], [ %28, %31 ]
%39 = tail call double @two_tone_test(i32 %36, i32 %35, i32 %35)
%40 = fcmp olt double %39, %37
%41 = select i1 %40, double %39, double %37
%42 = fcmp ogt double %39, %38
%43 = select i1 %42, double %39, double %38
%44 = fptosi double %41 to i32
%45 = fptosi double %43 to i32
%46 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %44, i32 %45)
%47 = 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
}