#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*/ double_ver(float *, float *, float, int, int, int);
float frac_pch(float *, float *, float, int /*<<< orphan*/, int, int, int);
float double_chk(float sig_in[], float *pcorr, float pitch, float pdouble,
                 int pmin, int pmax, int lmin) {
  int mult;
  float corr, thresh;
  float temp_pit;
  pitch = frac_pch(sig_in, pcorr, pitch, 0, pmin, pmax, lmin);
  thresh = pdouble * (*pcorr);
  for (mult = 8; mult >= 2; mult--) {
    temp_pit = pitch / mult;
    if (temp_pit >= pmin) {
      temp_pit = frac_pch(sig_in, &corr, temp_pit, 0, pmin, pmax, lmin);
      double_ver(sig_in, &corr, temp_pit, pmin, pmax, lmin);
      if (corr > thresh) {
        pitch = frac_pch(sig_in, pcorr, temp_pit, 0, pmin, pmax, lmin);
        break;
      }
    }
  }
  double_ver(sig_in, pcorr, pitch, pmin, pmax, lmin);
  return (pitch);
}


x86 assembly (clang, -O0):
<double_chk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
movss  %xmm1,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movss  -0x14(%rbp),%xmm0
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x24(%rbp),%r9d
xor    %edx,%edx
call   1040 <frac_pch@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulss  (%rax),%xmm0
movss  %xmm0,-0x30(%rbp)
movl   $0x8,-0x28(%rbp)
cmpl   $0x2,-0x28(%rbp)
jl     1241 <double_chk+0x121>
movss  -0x14(%rbp),%xmm0
cvtsi2ssl -0x28(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x34(%rbp),%xmm0
cvtsi2ssl -0x1c(%rbp),%xmm1
ucomiss %xmm1,%xmm0
jb     122e <double_chk+0x10e>
mov    -0x8(%rbp),%rdi
movss  -0x34(%rbp),%xmm0
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x24(%rbp),%r9d
lea    -0x2c(%rbp),%rsi
xor    %edx,%edx
call   1040 <frac_pch@plt>
movss  %xmm0,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
movss  -0x34(%rbp),%xmm0
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%r8d
lea    -0x2c(%rbp),%rsi
call   1030 <double_ver@plt>
movss  -0x2c(%rbp),%xmm0
ucomiss -0x30(%rbp),%xmm0
jbe    1229 <double_chk+0x109>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movss  -0x34(%rbp),%xmm0
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x24(%rbp),%r9d
xor    %edx,%edx
call   1040 <frac_pch@plt>
movss  %xmm0,-0x14(%rbp)
jmp    1241 <double_chk+0x121>
jmp    122e <double_chk+0x10e>
jmp    1233 <double_chk+0x113>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    1181 <double_chk+0x61>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movss  -0x14(%rbp),%xmm0
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%r8d
call   1030 <double_ver@plt>
movss  -0x14(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<double_chk>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8d,%r14d
mov    %ecx,%r12d
mov    %edx,%ebx
movss  %xmm1,0xc(%rsp)
mov    %rsi,%r15
mov    %rdi,%rbp
xor    %edx,%edx
mov    %ebx,%ecx
mov    %r12d,%r8d
mov    %r14d,%r9d
call   1040 <frac_pch@plt>
movaps %xmm0,%xmm2
cvtsi2ss %ebx,%xmm3
mov    %r15,0x20(%rsp)
movss  0xc(%rsp),%xmm0
mulss  (%r15),%xmm0
movss  %xmm0,0xc(%rsp)
mov    $0x9,%r15d
lea    0x1c(%rsp),%r13
movss  %xmm2,0x10(%rsp)
movss  %xmm3,0x18(%rsp)
jmp    119a <double_chk+0x7a>
nopw   0x0(%rax,%rax,1)
cmp    $0x2,%r15d
jbe    121e <double_chk+0xfe>
add    $0xffffffff,%r15d
xorps  %xmm1,%xmm1
cvtsi2ss %r15d,%xmm1
movaps %xmm2,%xmm0
divss  %xmm1,%xmm0
ucomiss %xmm3,%xmm0
jb     1190 <double_chk+0x70>
mov    %rbp,%rdi
mov    %r13,%rsi
xor    %edx,%edx
mov    %ebx,%ecx
mov    %r12d,%r8d
mov    %r14d,%r9d
call   1040 <frac_pch@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
movss  %xmm0,0x14(%rsp)
mov    %ebx,%edx
mov    %r12d,%ecx
mov    %r14d,%r8d
call   1030 <double_ver@plt>
movss  0x18(%rsp),%xmm3
movss  0x10(%rsp),%xmm2
movss  0x1c(%rsp),%xmm0
ucomiss 0xc(%rsp),%xmm0
jbe    1190 <double_chk+0x70>
mov    %rbp,%rdi
mov    0x20(%rsp),%r15
mov    %r15,%rsi
movss  0x14(%rsp),%xmm0
xor    %edx,%edx
mov    %ebx,%ecx
mov    %r12d,%r8d
mov    %r14d,%r9d
call   1040 <frac_pch@plt>
movaps %xmm0,%xmm2
jmp    1223 <double_chk+0x103>
mov    0x20(%rsp),%r15
movss  %xmm2,0x10(%rsp)
mov    %rbp,%rdi
mov    %r15,%rsi
movaps %xmm2,%xmm0
mov    %ebx,%edx
mov    %r12d,%ecx
mov    %r14d,%r8d
call   1030 <double_ver@plt>
movss  0x10(%rsp),%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define float @double_chk(float* %0, float* %1, float %2, float %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca float*
%9 = alloca float*
%10 = alloca float
%11 = alloca float
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca float
%17 = alloca float
%18 = alloca float
store float* %0, float** %8
store float* %1, float** %9
store float %2, float* %10
store float %3, float* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%19 = load float*, float** %8
%20 = load float*, float** %9
%21 = load float, float* %10
%22 = load i32, i32* %12
%23 = load i32, i32* %13
%24 = load i32, i32* %14
%25 = call float @frac_pch(float* %19, float* %20, float %21, i32 0, i32 %22, i32 %23, i32 %24)
store float %25, float* %10
%26 = load float, float* %11
%27 = load float*, float** %9
%28 = load float, float* %27
%29 = fmul float %26, %28
store float %29, float* %17
store i32 8, i32* %15
br label %30
30: ; preds = %68, %7
%31 = load i32, i32* %15
%32 = icmp sge i32 %31, 2
br i1 %32, label %33, label %71
33: ; preds = %30
%34 = load float, float* %10
%35 = load i32, i32* %15
%36 = sitofp i32 %35 to float
%37 = fdiv float %34, %36
store float %37, float* %18
%38 = load float, float* %18
%39 = load i32, i32* %12
%40 = sitofp i32 %39 to float
%41 = fcmp oge float %38, %40
br i1 %41, label %42, label %67
42: ; preds = %33
%43 = load float*, float** %8
%44 = load float, float* %18
%45 = load i32, i32* %12
%46 = load i32, i32* %13
%47 = load i32, i32* %14
%48 = call float @frac_pch(float* %43, float* %16, float %44, i32 0, i32 %45, i32 %46, i32 %47)
store float %48, float* %18
%49 = load float*, float** %8
%50 = load float, float* %18
%51 = load i32, i32* %12
%52 = load i32, i32* %13
%53 = load i32, i32* %14
%54 = call i32 @double_ver(float* %49, float* %16, float %50, i32 %51, i32 %52, i32 %53)
%55 = load float, float* %16
%56 = load float, float* %17
%57 = fcmp ogt float %55, %56
br i1 %57, label %58, label %66
58: ; preds = %42
%59 = load float*, float** %8
%60 = load float*, float** %9
%61 = load float, float* %18
%62 = load i32, i32* %12
%63 = load i32, i32* %13
%64 = load i32, i32* %14
%65 = call float @frac_pch(float* %59, float* %60, float %61, i32 0, i32 %62, i32 %63, i32 %64)
store float %65, float* %10
br label %71
66: ; preds = %42
br label %67
67: ; preds = %66, %33
br label %68
68: ; preds = %67
%69 = load i32, i32* %15
%70 = add nsw i32 %69, -1
store i32 %70, i32* %15
br label %30
71: ; preds = %58, %30
%72 = load float*, float** %8
%73 = load float*, float** %9
%74 = load float, float* %10
%75 = load i32, i32* %12
%76 = load i32, i32* %13
%77 = load i32, i32* %14
%78 = call i32 @double_ver(float* %72, float* %73, float %74, i32 %75, i32 %76, i32 %77)
%79 = load float, float* %10
ret float %79
}

LLVM IR (-O2):
define float @double_chk(float* %0, float* %1, float %2, float %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca float
%9 = bitcast float* %8 to i8*
%10 = tail call float @frac_pch(float* %0, float* %1, float %2, i32 0, i32 %4, i32 %5, i32 %6)
%11 = load float, float* %1
%12 = fmul float %11, %3
%13 = sitofp i32 %4 to float
br label %14
14: ; preds = %7, %26
%15 = phi i32 [ 8, %7 ], [ %27, %26 ]
%16 = sitofp i32 %15 to float
%17 = fdiv float %10, %16
%18 = fcmp ult float %17, %13
br i1 %18, label %26, label %19
19: ; preds = %14
%20 = call float @frac_pch(float* %0, float* %8, float %17, i32 0, i32 %4, i32 %5, i32 %6)
%21 = call i32 @double_ver(float* %0, float* %8, float %20, i32 %4, i32 %5, i32 %6)
%22 = load float, float* %8
%23 = fcmp ogt float %22, %12
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = call float @frac_pch(float* %0, float* %1, float %20, i32 0, i32 %4, i32 %5, i32 %6)
br label %29
26: ; preds = %14, %19
%27 = add nsw i32 %15, -1
%28 = icmp ugt i32 %15, 2
br i1 %28, label %14, label %29
29: ; preds = %26, %24
%30 = phi float [ %25, %24 ], [ %10, %26 ]
%31 = call i32 @double_ver(float* %0, float* %1, float %30, i32 %4, i32 %5, i32 %6)
ret float %30
}