#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*/ __DSVERIFIER_assert(int);
int /*<<< orphan*/ __DSVERIFIER_assume(int);
int /*<<< orphan*/ printf(char *, int, ...);
void double_check_limit_cycle(double *y, int y_size) {
  double reference = y[y_size - 1];
  int idx = 0;
  int window_size = 1;
  for (idx = (y_size - 2); idx >= 0; idx--) {
    if (y[idx] != reference) {
      window_size++;
    } else {
      break;
    }
  }
  __DSVERIFIER_assume(window_size != y_size && window_size != 1);
  printf("window_size %d\n", window_size);
  int desired_elements = 2 * window_size;
  int found_elements = 0;
  for (idx = (y_size - 1); idx >= 0; idx--) {
    if (idx > (y_size - window_size - 1)) {
      printf("%.0f == %.0f\n", y[idx], y[idx - window_size]);
      int cmp_idx = idx - window_size;
      if ((cmp_idx > 0) && (y[idx] == y[idx - window_size])) {
        found_elements = found_elements + 2;
      } else {
        break;
      }
    }
  }
  printf("desired_elements %d\n", desired_elements);
  printf("found_elements %d\n", found_elements);
  __DSVERIFIER_assert(desired_elements != found_elements);
}


x86 assembly (clang, -O0):
<double_check_limit_cycle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     11c0 <double_check_limit_cycle+0x90>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    119a <double_check_limit_cycle+0x6a>
jp     119a <double_check_limit_cycle+0x6a>
jmp    11a8 <double_check_limit_cycle+0x78>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11ad <double_check_limit_cycle+0x7d>
jmp    11c0 <double_check_limit_cycle+0x90>
jmp    11b2 <double_check_limit_cycle+0x82>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    116d <double_check_limit_cycle+0x3d>
mov    -0x20(%rbp),%ecx
xor    %eax,%eax
cmp    -0xc(%rbp),%ecx
mov    %al,-0x2d(%rbp)
je     11db <double_check_limit_cycle+0xab>
cmpl   $0x1,-0x20(%rbp)
setne  %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <__DSVERIFIER_assume@plt>
mov    -0x20(%rbp),%esi
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     12c6 <double_check_limit_cycle+0x196>
mov    -0x1c(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x20(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jle    12b3 <double_check_limit_cycle+0x183>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cvttsd2si (%rax,%rcx,8),%esi
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xdba(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jle    12a9 <double_check_limit_cycle+0x179>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    -0x20(%rbp),%ecx
movslq %ecx,%rcx
ucomisd (%rax,%rcx,8),%xmm0
jne    12a9 <double_check_limit_cycle+0x179>
jp     12a9 <double_check_limit_cycle+0x179>
mov    -0x28(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x28(%rbp)
jmp    12ae <double_check_limit_cycle+0x17e>
jmp    12c6 <double_check_limit_cycle+0x196>
jmp    12b3 <double_check_limit_cycle+0x183>
jmp    12b8 <double_check_limit_cycle+0x188>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1212 <double_check_limit_cycle+0xe2>
mov    -0x24(%rbp),%esi
lea    0xd4e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xd52(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <__DSVERIFIER_assert@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<double_check_limit_cycle>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebp
mov    %rdi,%r13
mov    $0x1,%ebx
cmp    $0x2,%esi
jl     1189 <double_check_limit_cycle+0x59>
movslq %ebp,%rax
movsd  -0x8(%r13,%rax,8),%xmm0
lea    -0x2(%rbp),%eax
lea    0x0(,%rax,8),%rax
add    %r13,%rax
mov    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
movsd  (%rax),%xmm1
ucomisd %xmm0,%xmm1
jne    117c <double_check_limit_cycle+0x4c>
jnp    1189 <double_check_limit_cycle+0x59>
add    $0x1,%ebx
add    $0xfffffffffffffff8,%rax
cmp    %ebx,%ebp
jne    1170 <double_check_limit_cycle+0x40>
mov    %ebp,%ebx
cmp    %ebp,%ebx
setne  %al
cmp    $0x1,%ebx
setne  %cl
and    %al,%cl
movzbl %cl,%edi
call   1040 <__DSVERIFIER_assume@plt>
lea    0xe5b(%rip),%rdi
xor    %r12d,%r12d
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    (%rbx,%rbx,1),%eax
mov    %eax,0xc(%rsp)
test   %ebp,%ebp
jle    1247 <double_check_limit_cycle+0x117>
movslq %ebx,%rax
not    %ebx
add    %ebp,%ebx
mov    %ebp,%ebp
movslq %ebx,%rbx
add    $0x1,%rbp
mov    %rax,%rcx
neg    %rcx
mov    %rcx,0x10(%rsp)
shl    $0x3,%rax
mov    %r13,%r15
sub    %rax,%r15
xor    %r12d,%r12d
jmp    11fe <double_check_limit_cycle+0xce>
nopw   0x0(%rax,%rax,1)
add    $0x2,%r12d
add    $0xffffffffffffffff,%rbp
cmp    $0x1,%rbp
jbe    1247 <double_check_limit_cycle+0x117>
lea    -0x2(%rbp),%rax
cmp    %rbx,%rax
jle    11f4 <double_check_limit_cycle+0xc4>
cvttsd2si -0x10(%r13,%rbp,8),%esi
mov    0x10(%rsp),%rax
lea    (%rax,%rbp,1),%r14
add    $0xfffffffffffffffe,%r14
movsd  -0x10(%r15,%rbp,8),%xmm0
lea    0xde7(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
test   %r14,%r14
jle    1247 <double_check_limit_cycle+0x117>
movsd  -0x10(%r13,%rbp,8),%xmm0
ucomisd -0x10(%r15,%rbp,8),%xmm0
jne    1247 <double_check_limit_cycle+0x117>
jnp    11f0 <double_check_limit_cycle+0xc0>
lea    0xdd0(%rip),%rdi
mov    0xc(%rsp),%ebx
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdd1(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
cmp    %r12d,%ebx
setne  %dil
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <__DSVERIFIER_assert@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"window_size %d\0A\00"
@.str.1 = [14 x i8] c"%.0f == %.0f\0A\00"
@.str.2 = [21 x i8] c"desired_elements %d\0A\00"
@.str.3 = [19 x i8] c"found_elements %d\0A\00"
define void @double_check_limit_cycle(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
%11 = load double*, double** %3
%12 = load i32, i32* %4
%13 = sub nsw i32 %12, 1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds double, double* %11, i64 %14
%16 = load double, double* %15
store double %16, double* %5
store i32 0, i32* %6
store i32 1, i32* %7
%17 = load i32, i32* %4
%18 = sub nsw i32 %17, 2
store i32 %18, i32* %6
br label %19
19: ; preds = %35, %2
%20 = load i32, i32* %6
%21 = icmp sge i32 %20, 0
br i1 %21, label %22, label %38
22: ; preds = %19
%23 = load double*, double** %3
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = load double, double* %5
%29 = fcmp une double %27, %28
br i1 %29, label %30, label %33
30: ; preds = %22
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %34
33: ; preds = %22
br label %38
34: ; preds = %30
br label %35
35: ; preds = %34
%36 = load i32, i32* %6
%37 = add nsw i32 %36, -1
store i32 %37, i32* %6
br label %19
38: ; preds = %33, %19
%39 = load i32, i32* %7
%40 = load i32, i32* %4
%41 = icmp ne i32 %39, %40
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = load i32, i32* %7
%44 = icmp ne i32 %43, 1
br label %45
45: ; preds = %42, %38
%46 = phi i1 [ false, %38 ], [ %44, %42 ]
%47 = zext i1 %46 to i32
%48 = call i32 @__DSVERIFIER_assume(i32 %47)
%49 = load i32, i32* %7
%50 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %49)
%51 = load i32, i32* %7
%52 = mul nsw i32 2, %51
store i32 %52, i32* %8
store i32 0, i32* %9
%53 = load i32, i32* %4
%54 = sub nsw i32 %53, 1
store i32 %54, i32* %6
br label %55
55: ; preds = %105, %45
%56 = load i32, i32* %6
%57 = icmp sge i32 %56, 0
br i1 %57, label %58, label %108
58: ; preds = %55
%59 = load i32, i32* %6
%60 = load i32, i32* %4
%61 = load i32, i32* %7
%62 = sub nsw i32 %60, %61
%63 = sub nsw i32 %62, 1
%64 = icmp sgt i32 %59, %63
br i1 %64, label %65, label %104
65: ; preds = %58
%66 = load double*, double** %3
%67 = load i32, i32* %6
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %66, i64 %68
%70 = load double, double* %69
%71 = fptosi double %70 to i32
%72 = load double*, double** %3
%73 = load i32, i32* %6
%74 = load i32, i32* %7
%75 = sub nsw i32 %73, %74
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds double, double* %72, i64 %76
%78 = load double, double* %77
%79 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %71, double %78)
%80 = load i32, i32* %6
%81 = load i32, i32* %7
%82 = sub nsw i32 %80, %81
store i32 %82, i32* %10
%83 = load i32, i32* %10
%84 = icmp sgt i32 %83, 0
br i1 %84, label %85, label %102
85: ; preds = %65
%86 = load double*, double** %3
%87 = load i32, i32* %6
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds double, double* %86, i64 %88
%90 = load double, double* %89
%91 = load double*, double** %3
%92 = load i32, i32* %6
%93 = load i32, i32* %7
%94 = sub nsw i32 %92, %93
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds double, double* %91, i64 %95
%97 = load double, double* %96
%98 = fcmp oeq double %90, %97
br i1 %98, label %99, label %102
99: ; preds = %85
%100 = load i32, i32* %9
%101 = add nsw i32 %100, 2
store i32 %101, i32* %9
br label %103
102: ; preds = %85, %65
br label %108
103: ; preds = %99
br label %104
104: ; preds = %103, %58
br label %105
105: ; preds = %104
%106 = load i32, i32* %6
%107 = add nsw i32 %106, -1
store i32 %107, i32* %6
br label %55
108: ; preds = %102, %55
%109 = load i32, i32* %8
%110 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %109)
%111 = load i32, i32* %9
%112 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %111)
%113 = load i32, i32* %8
%114 = load i32, i32* %9
%115 = icmp ne i32 %113, %114
%116 = zext i1 %115 to i32
%117 = call i32 @__DSVERIFIER_assert(i32 %116)
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"window_size %d\0A\00"
@.str.1 = [14 x i8] c"%.0f == %.0f\0A\00"
@.str.2 = [21 x i8] c"desired_elements %d\0A\00"
@.str.3 = [19 x i8] c"found_elements %d\0A\00"
define void @double_check_limit_cycle(double* nocapture %0, i32 %1) {
%3 = add nsw i32 %1, -1
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds double, double* %0, i64 %4
%6 = load double, double* %5
%7 = icmp sgt i32 %1, 1
br i1 %7, label %8, label %21
8: ; preds = %2
%9 = add nsw i32 %1, -2
%10 = zext i32 %9 to i64
br label %11
11: ; preds = %8, %17
%12 = phi i64 [ %10, %8 ], [ %19, %17 ]
%13 = phi i32 [ 1, %8 ], [ %18, %17 ]
%14 = getelementptr inbounds double, double* %0, i64 %12
%15 = load double, double* %14
%16 = fcmp une double %15, %6
br i1 %16, label %17, label %21
17: ; preds = %11
%18 = add nuw i32 %13, 1
%19 = add nsw i64 %12, -1
%20 = icmp eq i32 %18, %1
br i1 %20, label %21, label %11
21: ; preds = %17, %11, %2
%22 = phi i32 [ 1, %2 ], [ %13, %11 ], [ %1, %17 ]
%23 = icmp ne i32 %22, %1
%24 = icmp ne i32 %22, 1
%25 = and i1 %23, %24
%26 = zext i1 %25 to i32
%27 = tail call i32 @__DSVERIFIER_assume(i32 %26)
%28 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %22)
%29 = shl nuw nsw i32 %22, 1
%30 = icmp sgt i32 %1, 0
br i1 %30, label %31, label %60
31: ; preds = %21
%32 = xor i32 %22, -1
%33 = add i32 %32, %1
%34 = zext i32 %1 to i64
%35 = sext i32 %22 to i64
%36 = sext i32 %33 to i64
br label %37
37: ; preds = %31, %57
%38 = phi i64 [ %34, %31 ], [ %40, %57 ]
%39 = phi i32 [ 0, %31 ], [ %58, %57 ]
%40 = add nsw i64 %38, -1
%41 = icmp sgt i64 %40, %36
br i1 %41, label %42, label %57
42: ; preds = %37
%43 = getelementptr inbounds double, double* %0, i64 %40
%44 = load double, double* %43
%45 = fptosi double %44 to i32
%46 = sub nsw i64 %40, %35
%47 = getelementptr inbounds double, double* %0, i64 %46
%48 = load double, double* %47
%49 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %45, double %48)
%50 = icmp sgt i64 %46, 0
br i1 %50, label %51, label %60
51: ; preds = %42
%52 = load double, double* %43
%53 = load double, double* %47
%54 = fcmp oeq double %52, %53
br i1 %54, label %55, label %60
55: ; preds = %51
%56 = add nsw i32 %39, 2
br label %57
57: ; preds = %55, %37
%58 = phi i32 [ %56, %55 ], [ %39, %37 ]
%59 = icmp ugt i64 %38, 1
br i1 %59, label %37, label %60
60: ; preds = %57, %51, %42, %21
%61 = phi i32 [ 0, %21 ], [ %39, %42 ], [ %39, %51 ], [ %58, %57 ]
%62 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%63 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %61)
%64 = icmp ne i32 %29, %61
%65 = zext i1 %64 to i32
%66 = tail call i32 @__DSVERIFIER_assert(i32 %65)
ret void
}