#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*/ Hdetect(double *, double *, unsigned char *, double *);
int /*<<< orphan*/ dHDs(double *, double *, int, double *, int *, double *);
int /*<<< orphan*/ sortDs(double *, double *, unsigned char *);
int /*<<< orphan*/ u2h(double *, int *, int, double *, double *);
int checksample(double *F, double *u7, double th, double *H) {
  unsigned char IDXS[5][3] = {
      {0, 1, 2}, {3, 4, 5}, {0, 1, 6}, {3, 4, 6}, {2, 5, 6}};
  int i, j;
  double Ds[7], sDs[7];
  unsigned char idx[7], inlCount = 0;
  int inl[7];
  double buffer[5 * 18 * sizeof(double)], bufferZ[7 * 18 * sizeof(double)];
  int bufferP[7 * sizeof(int)];
  for (i = 0; i < 5; ++i) {
    Hdetect(F, u7, IDXS[i], H);
    dHDs(H, u7, 7, Ds, bufferP, bufferZ);
    sortDs(Ds, sDs, idx);
    for (j = 0; j < 5; ++j) {
      inl[j] = idx[j];
    }
    u2h(u7, inl, 5, H, buffer);
    dHDs(H, u7, 7, Ds, bufferP, bufferZ);
    inlCount = 0;
    for (j = 0; j < 7; ++j) {
      if (Ds[j] < th) {
        ++inlCount;
      }
    }
    if (inlCount > 4) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<checksample>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3760,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    0xe9d(%rip),%rax
mov    %rax,-0x37(%rbp)
mov    0xe9b(%rip),%eax
mov    %eax,-0x2f(%rbp)
mov    0xe95(%rip),%ax
mov    %ax,-0x2b(%rbp)
mov    0xe8d(%rip),%al
mov    %al,-0x29(%rbp)
movb   $0x0,-0xc8(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x5,-0x3c(%rbp)
jge    12f2 <checksample+0x1b2>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x3c(%rbp),%rax
lea    -0x37(%rbp),%rdx
imul   $0x3,%rax,%rax
add    %rax,%rdx
mov    -0x28(%rbp),%rcx
call   1030 <Hdetect@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x80(%rbp),%rcx
lea    -0x3760(%rbp),%r8
lea    -0x36f0(%rbp),%r9
mov    $0x7,%edx
call   1060 <dHDs@plt>
lea    -0x80(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
lea    -0xc7(%rbp),%rdx
call   1040 <sortDs@plt>
movl   $0x0,-0x40(%rbp)
cmpl   $0x5,-0x40(%rbp)
jge    122d <checksample+0xed>
movslq -0x40(%rbp),%rax
movzbl -0xc7(%rbp,%rax,1),%ecx
ff
movslq -0x40(%rbp),%rax
mov    %ecx,-0xf0(%rbp,%rax,4)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11fe <checksample+0xbe>
mov    -0x18(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
mov    -0x28(%rbp),%rcx
lea    -0x1770(%rbp),%r8
mov    $0x5,%edx
call   1050 <u2h@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x80(%rbp),%rcx
lea    -0x3760(%rbp),%r8
lea    -0x36f0(%rbp),%r9
mov    $0x7,%edx
call   1060 <dHDs@plt>
movb   $0x0,-0xc8(%rbp)
movl   $0x0,-0x40(%rbp)
cmpl   $0x7,-0x40(%rbp)
jge    12c3 <checksample+0x183>
movslq -0x40(%rbp),%rax
movsd  -0x80(%rbp,%rax,8),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12b0 <checksample+0x170>
mov    -0xc8(%rbp),%al
add    $0x1,%al
mov    %al,-0xc8(%rbp)
jmp    12b5 <checksample+0x175>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    127f <checksample+0x13f>
movzbl -0xc8(%rbp),%eax
cmp    $0x4,%eax
jle    12df <checksample+0x19f>
movl   $0x1,-0x4(%rbp)
jmp    12f9 <checksample+0x1b9>
jmp    12e4 <checksample+0x1a4>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1192 <checksample+0x52>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x3760,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checksample>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3758,%rsp
mov    %rdx,%r14
mov    %rsi,%r13
mov    %rdi,0x8(%rsp)
mov    0xea4(%rip),%rax
mov    %rax,0x17(%rsp)
mov    0xe91(%rip),%rax
mov    %rax,0x10(%rsp)
movaps %xmm0,0x30(%rsp)
movlhps %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
xor    %r15d,%r15d
lea    0x60(%rsp),%r12
lea    0x17d0(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    (%rsp,%r15,1),%rdx
add    $0x10,%rdx
mov    0x8(%rsp),%rdi
mov    %r13,%rsi
mov    %r14,%rcx
call   1030 <Hdetect@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    $0x7,%edx
mov    %r12,%rcx
lea    0xe0(%rsp),%rbx
mov    %rbx,%r8
mov    %rbp,%r9
call   1060 <dHDs@plt>
mov    %r12,%rdi
lea    0xa0(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <sortDs@plt>
movd   (%rsp),%xmm0
pxor   %xmm1,%xmm1
punpcklbw %xmm1,%xmm0
punpcklwd %xmm1,%xmm0
movdqa %xmm0,0x40(%rsp)
movzbl 0x4(%rsp),%eax
mov    %eax,0x50(%rsp)
mov    %r13,%rdi
lea    0x40(%rsp),%rsi
mov    $0x5,%edx
mov    %r14,%rcx
lea    0x150(%rsp),%r8
call   1050 <u2h@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    $0x7,%edx
mov    %r12,%rcx
mov    %rbx,%r8
mov    %rbp,%r9
call   1060 <dHDs@plt>
movapd 0x30(%rsp),%xmm2
ucomisd 0x80(%rsp),%xmm2
seta   %al
ucomisd 0x88(%rsp),%xmm2
movapd 0x60(%rsp),%xmm0
seta   %cl
movapd 0x70(%rsp),%xmm1
ucomisd 0x90(%rsp),%xmm2
seta   %dl
movapd 0x20(%rsp),%xmm2
cmpltpd %xmm2,%xmm1
cmpltpd %xmm2,%xmm0
packssdw %xmm1,%xmm0
movmskps %xmm0,%esi
mov    %esi,%ebx
shr    %bl
and    $0x5,%bl
sub    %bl,%sil
mov    %esi,%ebx
and    $0x33,%bl
shr    $0x2,%sil
and    $0x33,%sil
add    %bl,%sil
mov    %esi,%ebx
shr    $0x4,%bl
add    %sil,%bl
and    $0xf,%bl
add    %al,%bl
add    %cl,%bl
add    %dl,%bl
cmp    $0x5,%bl
jae    12d1 <checksample+0x191>
add    $0x3,%r15
cmp    $0xf,%r15
jne    11a0 <checksample+0x60>
xor    %eax,%eax
jmp    12d6 <checksample+0x196>
mov    $0x1,%eax
add    $0x3758,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.checksample.IDXS = [5 x [3 x i8]] [[3 x i8] c"\00\01\02", [3 x i8] c"\03\04\05", [3 x i8] c"\00\01\06", [3 x i8] c"\03\04\06", [3 x i8] c"\02\05\06"]
define i32 @checksample(double* %0, double* %1, double %2, double* %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca double*
%8 = alloca double
%9 = alloca double*
%10 = alloca [5 x [3 x i8]]
%11 = alloca i32
%12 = alloca i32
%13 = alloca [7 x double]
%14 = alloca [7 x double]
%15 = alloca [7 x i8]
%16 = alloca i8
%17 = alloca [7 x i32]
%18 = alloca [720 x double]
%19 = alloca [1008 x double]
%20 = alloca [28 x i32]
store double* %0, double** %6
store double* %1, double** %7
store double %2, double* %8
store double* %3, double** %9
%21 = bitcast [5 x [3 x i8]]* %10 to i8*
store i8 0, i8* %16
store i32 0, i32* %11
br label %22
22: ; preds = %94, %4
%23 = load i32, i32* %11
%24 = icmp slt i32 %23, 5
br i1 %24, label %25, label %97
25: ; preds = %22
%26 = load double*, double** %6
%27 = load double*, double** %7
%28 = load i32, i32* %11
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [5 x [3 x i8]], [5 x [3 x i8]]* %10, i64 0, i64 %29
%31 = getelementptr inbounds [3 x i8], [3 x i8]* %30, i64 0, i64 0
%32 = load double*, double** %9
%33 = call i32 @Hdetect(double* %26, double* %27, i8* %31, double* %32)
%34 = load double*, double** %9
%35 = load double*, double** %7
%36 = getelementptr inbounds [7 x double], [7 x double]* %13, i64 0, i64 0
%37 = getelementptr inbounds [28 x i32], [28 x i32]* %20, i64 0, i64 0
%38 = getelementptr inbounds [1008 x double], [1008 x double]* %19, i64 0, i64 0
%39 = call i32 @dHDs(double* %34, double* %35, i32 7, double* %36, i32* %37, double* %38)
%40 = getelementptr inbounds [7 x double], [7 x double]* %13, i64 0, i64 0
%41 = getelementptr inbounds [7 x double], [7 x double]* %14, i64 0, i64 0
%42 = getelementptr inbounds [7 x i8], [7 x i8]* %15, i64 0, i64 0
%43 = call i32 @sortDs(double* %40, double* %41, i8* %42)
store i32 0, i32* %12
br label %44
44: ; preds = %56, %25
%45 = load i32, i32* %12
%46 = icmp slt i32 %45, 5
br i1 %46, label %47, label %59
47: ; preds = %44
%48 = load i32, i32* %12
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [7 x i8], [7 x i8]* %15, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = load i32, i32* %12
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [7 x i32], [7 x i32]* %17, i64 0, i64 %54
store i32 %52, i32* %55
br label %56
56: ; preds = %47
%57 = load i32, i32* %12
%58 = add nsw i32 %57, 1
store i32 %58, i32* %12
br label %44
59: ; preds = %44
%60 = load double*, double** %7
%61 = getelementptr inbounds [7 x i32], [7 x i32]* %17, i64 0, i64 0
%62 = load double*, double** %9
%63 = getelementptr inbounds [720 x double], [720 x double]* %18, i64 0, i64 0
%64 = call i32 @u2h(double* %60, i32* %61, i32 5, double* %62, double* %63)
%65 = load double*, double** %9
%66 = load double*, double** %7
%67 = getelementptr inbounds [7 x double], [7 x double]* %13, i64 0, i64 0
%68 = getelementptr inbounds [28 x i32], [28 x i32]* %20, i64 0, i64 0
%69 = getelementptr inbounds [1008 x double], [1008 x double]* %19, i64 0, i64 0
%70 = call i32 @dHDs(double* %65, double* %66, i32 7, double* %67, i32* %68, double* %69)
store i8 0, i8* %16
store i32 0, i32* %12
br label %71
71: ; preds = %85, %59
%72 = load i32, i32* %12
%73 = icmp slt i32 %72, 7
br i1 %73, label %74, label %88
74: ; preds = %71
%75 = load i32, i32* %12
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [7 x double], [7 x double]* %13, i64 0, i64 %76
%78 = load double, double* %77
%79 = load double, double* %8
%80 = fcmp olt double %78, %79
br i1 %80, label %81, label %84
81: ; preds = %74
%82 = load i8, i8* %16
%83 = add i8 %82, 1
store i8 %83, i8* %16
br label %84
84: ; preds = %81, %74
br label %85
85: ; preds = %84
%86 = load i32, i32* %12
%87 = add nsw i32 %86, 1
store i32 %87, i32* %12
br label %71
88: ; preds = %71
%89 = load i8, i8* %16
%90 = zext i8 %89 to i32
%91 = icmp sgt i32 %90, 4
br i1 %91, label %92, label %93
92: ; preds = %88
store i32 1, i32* %5
br label %98
93: ; preds = %88
br label %94
94: ; preds = %93
%95 = load i32, i32* %11
%96 = add nsw i32 %95, 1
store i32 %96, i32* %11
br label %22
97: ; preds = %22
store i32 0, i32* %5
br label %98
98: ; preds = %97, %92
%99 = load i32, i32* %5
ret i32 %99
}

LLVM IR (-O2):
@__const.checksample.IDXS = [5 x [3 x i8]] [[3 x i8] c"\00\01\02", [3 x i8] c"\03\04\05", [3 x i8] c"\00\01\06", [3 x i8] c"\03\04\06", [3 x i8] c"\02\05\06"]
define i32 @checksample(double* %0, double* %1, double %2, double* %3) {
%5 = alloca [5 x [3 x i8]]
%6 = alloca [7 x double]
%7 = alloca [7 x double]
%8 = alloca [7 x i8]
%9 = alloca [7 x i32]
%10 = alloca [720 x double]
%11 = alloca [1008 x double]
%12 = alloca [28 x i32]
%13 = getelementptr inbounds [5 x [3 x i8]], [5 x [3 x i8]]* %5, i64 0, i64 0, i64 0
%14 = bitcast [7 x double]* %6 to i8*
%15 = bitcast [7 x double]* %7 to i8*
%16 = getelementptr inbounds [7 x i8], [7 x i8]* %8, i64 0, i64 0
%17 = bitcast [7 x i32]* %9 to i8*
%18 = bitcast [720 x double]* %10 to i8*
%19 = bitcast [1008 x double]* %11 to i8*
%20 = bitcast [28 x i32]* %12 to i8*
%21 = getelementptr inbounds [7 x double], [7 x double]* %6, i64 0, i64 0
%22 = getelementptr inbounds [28 x i32], [28 x i32]* %12, i64 0, i64 0
%23 = getelementptr inbounds [1008 x double], [1008 x double]* %11, i64 0, i64 0
%24 = getelementptr inbounds [7 x double], [7 x double]* %7, i64 0, i64 0
%25 = getelementptr inbounds [7 x i32], [7 x i32]* %9, i64 0, i64 0
%26 = getelementptr inbounds [720 x double], [720 x double]* %10, i64 0, i64 0
%27 = getelementptr inbounds [7 x i8], [7 x i8]* %8, i64 0, i64 4
%28 = getelementptr inbounds [7 x i32], [7 x i32]* %9, i64 0, i64 4
%29 = getelementptr inbounds [7 x double], [7 x double]* %6, i64 0, i64 4
%30 = getelementptr inbounds [7 x double], [7 x double]* %6, i64 0, i64 5
%31 = getelementptr inbounds [7 x double], [7 x double]* %6, i64 0, i64 6
%32 = insertelement <4 x double> poison, double %2, i64 0
%33 = shufflevector <4 x double> %32, <4 x double> poison, <4 x i32> zeroinitializer
%34 = bitcast [7 x i8]* %8 to <4 x i8>*
%35 = bitcast [7 x i32]* %9 to <4 x i32>*
%36 = bitcast [7 x double]* %6 to <4 x double>*
br label %40
37: ; preds = %40
%38 = add nuw nsw i64 %41, 1
%39 = icmp eq i64 %38, 5
br i1 %39, label %70, label %40
40: ; preds = %4, %37
%41 = phi i64 [ 0, %4 ], [ %38, %37 ]
%42 = getelementptr inbounds [5 x [3 x i8]], [5 x [3 x i8]]* %5, i64 0, i64 %41, i64 0
%43 = call i32 @Hdetect(double* %0, double* %1, i8* %42, double* %3)
%44 = call i32 @dHDs(double* %3, double* %1, i32 7, double* %21, i32* %22, double* %23)
%45 = call i32 @sortDs(double* %21, double* %24, i8* %16)
%46 = load <4 x i8>, <4 x i8>* %34
%47 = zext <4 x i8> %46 to <4 x i32>
store <4 x i32> %47, <4 x i32>* %35
%48 = load i8, i8* %27
%49 = zext i8 %48 to i32
store i32 %49, i32* %28
%50 = call i32 @u2h(double* %1, i32* %25, i32 5, double* %3, double* %26)
%51 = call i32 @dHDs(double* %3, double* %1, i32 7, double* %21, i32* %22, double* %23)
%52 = load <4 x double>, <4 x double>* %36
%53 = fcmp olt <4 x double> %52, %33
%54 = load double, double* %29
%55 = fcmp olt double %54, %2
%56 = zext i1 %55 to i8
%57 = load double, double* %30
%58 = fcmp olt double %57, %2
%59 = zext i1 %58 to i8
%60 = load double, double* %31
%61 = fcmp olt double %60, %2
%62 = zext i1 %61 to i8
%63 = bitcast <4 x i1> %53 to i4
%64 = call i4 @llvm.ctpop.i4(i4 %63)
%65 = zext i4 %64 to i8
%66 = add nuw nsw i8 %65, %56
%67 = add nuw nsw i8 %66, %59
%68 = add nuw nsw i8 %67, %62
%69 = icmp ugt i8 %68, 4
br i1 %69, label %70, label %37
70: ; preds = %37, %40
%71 = phi i32 [ 1, %40 ], [ 0, %37 ]
ret i32 %71
}