#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*/ init_test();
int /*<<< orphan*/ ksft_exit_fail();
int /*<<< orphan*/ ksft_exit_pass();
int /*<<< orphan*/ printf(char *);
int rand();
scalar_t__ run_test(int /*<<< orphan*/, double, double);
int /*<<< orphan*/ set_frequency(double);
int main(int argc, char **argv) {
  double freq_base, freq_step;
  int i, j, fails = 0;
  init_test();
  printf("Checking response to frequency step:\n");
  printf("  Step           1st interval              2nd interval\n");
  printf("             Freq    Dev     Max       Freq    Dev     Max\n");
  for (i = 2; i >= 0; i--) {
    for (j = 0; j < 5; j++) {
      freq_base = (rand() % (1 << 24) - (1 << 23)) / 65536e6;
      freq_step = 10e-6 * (1 << (6 * i));
      fails += run_test(0, freq_base, freq_step);
    }
  }
  set_frequency(0.0);
  if (fails)
    ksft_exit_fail();
  ksft_exit_pass();
}


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,-0x2c(%rbp)
mov    $0x0,%al
call   1080 <init_test@plt>
lea    0xe75(%rip),%rdi
call   1050 <printf@plt>
lea    0xe8f(%rip),%rdi
call   1050 <printf@plt>
lea    0xebc(%rip),%rdi
call   1050 <printf@plt>
movl   $0x2,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     1263 <main+0xf3>
movl   $0x0,-0x28(%rbp)
cmpl   $0x5,-0x28(%rbp)
jge    1250 <main+0xe0>
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x1000000,%ecx
cltd
idiv   %ecx
sub    $0x800000,%edx
cvtsi2sd %edx,%xmm0
movsd  0xe0d(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
imul   $0x6,-0x24(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
cvtsi2sd %eax,%xmm1
movsd  0xde5(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
xor    %edi,%edi
call   1060 <run_test@plt>
mov    %rax,%rcx
movslq -0x2c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11d0 <main+0x60>
jmp    1255 <main+0xe5>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    11bf <main+0x4f>
xorps  %xmm0,%xmm0
call   1070 <set_frequency@plt>
cmpl   $0x0,-0x2c(%rbp)
je     127c <main+0x10c>
mov    $0x0,%al
call   1040 <ksft_exit_fail@plt>
mov    $0x0,%al
call   1030 <ksft_exit_pass@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1080 <init_test@plt>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
lea    0xea4(%rip),%rdi
call   1030 <puts@plt>
lea    0xed0(%rip),%rdi
call   1030 <puts@plt>
mov    $0xc,%r14d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    $0x1,%eax
mov    %r14d,%ecx
shl    %cl,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe37(%rip),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1090 <rand@plt>
lea    0xffffff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xff000000,%ecx
neg    %ecx
add    %ecx,%eax
add    $0xff800000,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xe0a(%rip),%xmm1
divsd  %xmm1,%xmm0
xor    %edi,%edi
movsd  (%rsp),%xmm1
call   1060 <run_test@plt>
mov    %rax,%rbp
add    %ebx,%ebp
xor    %eax,%eax
call   1090 <rand@plt>
lea    0xffffff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xff000000,%ecx
neg    %ecx
add    %ecx,%eax
add    $0xff800000,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xdc5(%rip),%xmm0
xor    %edi,%edi
movsd  (%rsp),%xmm1
call   1060 <run_test@plt>
mov    %rax,%rbx
add    %ebp,%ebx
xor    %eax,%eax
call   1090 <rand@plt>
lea    0xffffff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xff000000,%ecx
neg    %ecx
add    %ecx,%eax
add    $0xff800000,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xd84(%rip),%xmm0
xor    %edi,%edi
movsd  (%rsp),%xmm1
call   1060 <run_test@plt>
mov    %rax,%rbp
add    %ebx,%ebp
xor    %eax,%eax
call   1090 <rand@plt>
lea    0xffffff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xff000000,%ecx
neg    %ecx
add    %ecx,%eax
add    $0xff800000,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xd43(%rip),%xmm0
xor    %edi,%edi
movsd  (%rsp),%xmm1
call   1060 <run_test@plt>
mov    %rax,%r15
add    %ebp,%r15d
xor    %eax,%eax
call   1090 <rand@plt>
lea    0xffffff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xff000000,%ecx
neg    %ecx
add    %ecx,%eax
add    $0xff800000,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xd01(%rip),%xmm0
xor    %edi,%edi
movsd  (%rsp),%xmm1
call   1060 <run_test@plt>
mov    %rax,%rbx
add    %r15d,%ebx
add    $0xfffffffa,%r14d
cmp    $0xfffffffa,%r14d
jne    11b0 <main+0x40>
xorpd  %xmm0,%xmm0
call   1070 <set_frequency@plt>
test   %ebx,%ebx
je     133b <main+0x1cb>
xor    %eax,%eax
call   1050 <ksft_exit_fail@plt>
xor    %eax,%eax
call   1040 <ksft_exit_pass@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Checking response to frequency step:\0A\00"
@.str.1 = [57 x i8] c" Step 1st interval 2nd interval\0A\00"
@.str.2 = [60 x i8] c" Freq Dev Max Freq Dev Max\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
%11 = call i32 (...) @init_test()
%12 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0))
store i32 2, i32* %8
br label %15
15: ; preds = %44, %2
%16 = load i32, i32* %8
%17 = icmp sge i32 %16, 0
br i1 %17, label %18, label %47
18: ; preds = %15
store i32 0, i32* %9
br label %19
19: ; preds = %40, %18
%20 = load i32, i32* %9
%21 = icmp slt i32 %20, 5
br i1 %21, label %22, label %43
22: ; preds = %19
%23 = call i32 (...) @rand()
%24 = srem i32 %23, 16777216
%25 = sub nsw i32 %24, 8388608
%26 = sitofp i32 %25 to double
%27 = fdiv double %26, 6.553600e+10
store double %27, double* %6
%28 = load i32, i32* %8
%29 = mul nsw i32 6, %28
%30 = shl i32 1, %29
%31 = sitofp i32 %30 to double
%32 = fmul double 1.000000e-05, %31
store double %32, double* %7
%33 = load double, double* %6
%34 = load double, double* %7
%35 = call i64 @run_test(i32 0, double %33, double %34)
%36 = load i32, i32* %10
%37 = sext i32 %36 to i64
%38 = add nsw i64 %37, %35
%39 = trunc i64 %38 to i32
store i32 %39, i32* %10
br label %40
40: ; preds = %22
%41 = load i32, i32* %9
%42 = add nsw i32 %41, 1
store i32 %42, i32* %9
br label %19
43: ; preds = %19
br label %44
44: ; preds = %43
%45 = load i32, i32* %8
%46 = add nsw i32 %45, -1
store i32 %46, i32* %8
br label %15
47: ; preds = %15
%48 = call i32 @set_frequency(double 0.000000e+00)
%49 = load i32, i32* %10
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %47
%52 = call i32 (...) @ksft_exit_fail()
br label %53
53: ; preds = %51, %47
%54 = call i32 (...) @ksft_exit_pass()
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
@str = [37 x i8] c"Checking response to frequency step:\00"
@str.3 = [56 x i8] c" Step 1st interval 2nd interval\00"
@str.4 = [59 x i8] c" Freq Dev Max Freq Dev Max\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @init_test()
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.3, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.4, i64 0, i64 0))
br label %7
7: ; preds = %2, %7
%8 = phi i32 [ 0, %2 ], [ %53, %7 ]
%9 = phi i32 [ 2, %2 ], [ %54, %7 ]
%10 = mul nuw nsw i32 %9, 6
%11 = shl nuw i32 1, %10
%12 = sitofp i32 %11 to double
%13 = fmul double %12, 1.000000e-05
%14 = tail call i32 (...) @rand()
%15 = srem i32 %14, 16777216
%16 = add nsw i32 %15, -8388608
%17 = sitofp i32 %16 to double
%18 = fdiv double %17, 6.553600e+10
%19 = tail call i64 @run_test(i32 0, double %18, double %13)
%20 = trunc i64 %19 to i32
%21 = add i32 %8, %20
%22 = tail call i32 (...) @rand()
%23 = srem i32 %22, 16777216
%24 = add nsw i32 %23, -8388608
%25 = sitofp i32 %24 to double
%26 = fdiv double %25, 6.553600e+10
%27 = tail call i64 @run_test(i32 0, double %26, double %13)
%28 = trunc i64 %27 to i32
%29 = add i32 %21, %28
%30 = tail call i32 (...) @rand()
%31 = srem i32 %30, 16777216
%32 = add nsw i32 %31, -8388608
%33 = sitofp i32 %32 to double
%34 = fdiv double %33, 6.553600e+10
%35 = tail call i64 @run_test(i32 0, double %34, double %13)
%36 = trunc i64 %35 to i32
%37 = add i32 %29, %36
%38 = tail call i32 (...) @rand()
%39 = srem i32 %38, 16777216
%40 = add nsw i32 %39, -8388608
%41 = sitofp i32 %40 to double
%42 = fdiv double %41, 6.553600e+10
%43 = tail call i64 @run_test(i32 0, double %42, double %13)
%44 = trunc i64 %43 to i32
%45 = add i32 %37, %44
%46 = tail call i32 (...) @rand()
%47 = srem i32 %46, 16777216
%48 = add nsw i32 %47, -8388608
%49 = sitofp i32 %48 to double
%50 = fdiv double %49, 6.553600e+10
%51 = tail call i64 @run_test(i32 0, double %50, double %13)
%52 = trunc i64 %51 to i32
%53 = add i32 %45, %52
%54 = add nsw i32 %9, -1
%55 = icmp eq i32 %9, 0
br i1 %55, label %56, label %7
56: ; preds = %7
%57 = tail call i32 @set_frequency(double 0.000000e+00)
%58 = icmp eq i32 %53, 0
br i1 %58, label %61, label %59
59: ; preds = %56
%60 = tail call i32 (...) @ksft_exit_fail()
br label %61
61: ; preds = %59, %56
%62 = tail call i32 (...) @ksft_exit_pass()
ret i32 0
}