#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*/ assert(int);
double fabs(double);
int /*<<< orphan*/ printf(char *, double, double);
void verifyPhaseResp(double *res, double *fi, double dif, int N) {
  int i;
  double w;
  for (i = 0, w = 0; (w <= 1.0); ++i, w += (1.0 / N)) {
    printf("w= %f %f\n", w, res[i]);
    printf("fi= %f %f\n", w, fi[i]);
    assert(fabs(res[i] - fi[i]) <= dif);
  }
}


x86 assembly (clang, -O0):
<verifyPhaseResp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xeb1(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     11fa <verifyPhaseResp+0xda>
movsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm1
movaps 0xe59(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm1
movsd  0xe19(%rip),%xmm0
divsd  %xmm1,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1147 <verifyPhaseResp+0x27>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<verifyPhaseResp>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
cvtsi2sd %edx,%xmm1
movsd  %xmm0,0x18(%rsp)
mov    %rsi,%r14
mov    %rdi,%r13
movsd  0xebb(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
lea    0xec4(%rip),%r15
lea    0xec7(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  %xmm0,0x8(%rsp)
movsd  0x0(%r13,%rbx,1),%xmm1
mov    %r15,%rdi
movsd  0x8(%rsp),%xmm0
call   1030 <printf@plt>
movsd  (%r14,%rbx,1),%xmm1
mov    %r12,%rdi
movsd  0x8(%rsp),%xmm0
call   1030 <printf@plt>
movsd  0x0(%r13,%rbx,1),%xmm0
subsd  (%r14,%rbx,1),%xmm0
andpd  0xe5c(%rip),%xmm0
xor    %edi,%edi
movsd  0x18(%rsp),%xmm1
ucomisd %xmm0,%xmm1
setae  %dil
call   1040 <assert@plt>
movsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
add    $0x8,%rbx
movsd  0xe19(%rip),%xmm0
ucomisd 0x8(%rsp),%xmm0
movsd  0x8(%rsp),%xmm0
jae    1170 <verifyPhaseResp+0x50>
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"w= %f %f\0A\00"
@.str.1 = [11 x i8] c"fi= %f %f\0A\00"
define void @verifyPhaseResp(double* %0, double* %1, double %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store double %2, double* %7
store i32 %3, i32* %8
store i32 0, i32* %9
store double 0.000000e+00, double* %10
br label %11
11: ; preds = %45, %4
%12 = load double, double* %10
%13 = fcmp ole double %12, 1.000000e+00
br i1 %13, label %14, label %53
14: ; preds = %11
%15 = load double, double* %10
%16 = load double*, double** %5
%17 = load i32, i32* %9
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %16, i64 %18
%20 = load double, double* %19
%21 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %15, double %20)
%22 = load double, double* %10
%23 = load double*, double** %6
%24 = load i32, i32* %9
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), double %22, double %27)
%29 = load double*, double** %5
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = load double*, double** %6
%35 = load i32, i32* %9
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
%38 = load double, double* %37
%39 = fsub double %33, %38
%40 = call double @llvm.fabs.f64(double %39)
%41 = load double, double* %7
%42 = fcmp ole double %40, %41
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
br label %45
45: ; preds = %14
%46 = load i32, i32* %9
%47 = add nsw i32 %46, 1
store i32 %47, i32* %9
%48 = load i32, i32* %8
%49 = sitofp i32 %48 to double
%50 = fdiv double 1.000000e+00, %49
%51 = load double, double* %10
%52 = fadd double %51, %50
store double %52, double* %10
br label %11
53: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"w= %f %f\0A\00"
@.str.1 = [11 x i8] c"fi= %f %f\0A\00"
define void @verifyPhaseResp(double* nocapture %0, double* nocapture %1, double %2, i32 %3) {
%5 = sitofp i32 %3 to double
%6 = fdiv double 1.000000e+00, %5
br label %7
7: ; preds = %4, %7
%8 = phi i64 [ 0, %4 ], [ %23, %7 ]
%9 = phi double [ 0.000000e+00, %4 ], [ %24, %7 ]
%10 = getelementptr inbounds double, double* %0, i64 %8
%11 = load double, double* %10
%12 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %9, double %11)
%13 = getelementptr inbounds double, double* %1, i64 %8
%14 = load double, double* %13
%15 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), double %9, double %14)
%16 = load double, double* %10
%17 = load double, double* %13
%18 = fsub double %16, %17
%19 = tail call double @llvm.fabs.f64(double %18)
%20 = fcmp ole double %19, %2
%21 = zext i1 %20 to i32
%22 = tail call i32 @assert(i32 %21)
%23 = add nuw i64 %8, 1
%24 = fadd double %6, %9
%25 = fcmp ugt double %24, 1.000000e+00
br i1 %25, label %26, label %7
26: ; preds = %7
ret void
}