#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 */
double abs(double);
int isregular(double val[], int ix) {
  int counter = ix - 2, output = 1;
  double eps = 1e-6;
  double temp = val[counter] - val[counter + 1];
  while (counter) {
    counter--;
    if (abs((val[counter] - val[counter + 1]) / temp - 1) >= eps) {
      counter = 0;
      output = 0;
    }
  }
  return output;
}


x86 assembly (clang, -O0):
<isregular>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11c6 <isregular+0xb6>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  0xe69(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <abs@plt>
ucomisd -0x20(%rbp),%xmm0
jb     11c1 <isregular+0xb1>
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
jmp    1160 <isregular+0x50>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isregular>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x1,%r14d
cmp    $0x2,%esi
je     1185 <isregular+0x75>
movslq %esi,%rax
movsd  -0x10(%rdi,%rax,8),%xmm0
subsd  -0x8(%rdi,%rax,8),%xmm0
movsd  %xmm0,(%rsp)
lea    (%rdi,%rax,8),%rbx
add    $0xfffffffffffffff0,%rbx
mov    $0x2,%r15d
sub    %esi,%r15d
xor    %ebp,%ebp
nopl   0x0(%rax)
movsd  -0x8(%rbx,%rbp,8),%xmm0
subsd  (%rbx,%rbp,8),%xmm0
divsd  (%rsp),%xmm0
addsd  0xe98(%rip),%xmm0
call   1030 <abs@plt>
ucomisd 0xe93(%rip),%xmm0
jae    1182 <isregular+0x72>
add    $0xffffffffffffffff,%rbp
cmp    %ebp,%r15d
jne    1150 <isregular+0x40>
jmp    1185 <isregular+0x75>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @isregular(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
store double* %0, double** %3
store i32 %1, i32* %4
%9 = load i32, i32* %4
%10 = sub nsw i32 %9, 2
store i32 %10, i32* %5
store i32 1, i32* %6
store double 0x3EB0C6F7A0B5ED8D, double* %7
%11 = load double*, double** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds double, double* %11, i64 %13
%15 = load double, double* %14
%16 = load double*, double** %3
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %16, i64 %19
%21 = load double, double* %20
%22 = fsub double %15, %21
store double %22, double* %8
br label %23
23: ; preds = %48, %2
%24 = load i32, i32* %5
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %49
26: ; preds = %23
%27 = load i32, i32* %5
%28 = add nsw i32 %27, -1
store i32 %28, i32* %5
%29 = load double*, double** %3
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = load double*, double** %3
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %34, i64 %37
%39 = load double, double* %38
%40 = fsub double %33, %39
%41 = load double, double* %8
%42 = fdiv double %40, %41
%43 = fsub double %42, 1.000000e+00
%44 = call double @abs(double %43)
%45 = load double, double* %7
%46 = fcmp oge double %44, %45
br i1 %46, label %47, label %48
47: ; preds = %26
store i32 0, i32* %5
store i32 0, i32* %6
br label %48
48: ; preds = %47, %26
br label %23
49: ; preds = %23
%50 = load i32, i32* %6
ret i32 %50
}

LLVM IR (-O2):
define i32 @isregular(double* nocapture %0, i32 %1) {
%3 = add nsw i32 %1, -2
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds double, double* %0, i64 %4
%6 = load double, double* %5
%7 = add nsw i32 %1, -1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds double, double* %0, i64 %8
%10 = load double, double* %9
%11 = fsub double %6, %10
%12 = icmp eq i32 %3, 0
br i1 %12, label %31, label %13
13: ; preds = %2
%14 = sext i32 %1 to i64
%15 = add nsw i64 %14, -2
br label %19
16: ; preds = %19
%17 = trunc i64 %21 to i32
%18 = icmp eq i32 %17, 0
br i1 %18, label %31, label %19
19: ; preds = %13, %16
%20 = phi i64 [ %15, %13 ], [ %21, %16 ]
%21 = add nsw i64 %20, -1
%22 = getelementptr inbounds double, double* %0, i64 %21
%23 = load double, double* %22
%24 = getelementptr inbounds double, double* %0, i64 %20
%25 = load double, double* %24
%26 = fsub double %23, %25
%27 = fdiv double %26, %11
%28 = fadd double %27, -1.000000e+00
%29 = tail call double @abs(double %28)
%30 = fcmp ult double %29, 0x3EB0C6F7A0B5ED8D
br i1 %30, label %16, label %31
31: ; preds = %16, %19, %2
%32 = phi i32 [ 1, %2 ], [ 0, %19 ], [ 1, %16 ]
ret i32 %32
}