#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 fabs(double);
void extractnz_boundaries_dvector(double *v, long nl, long nh, long *nlnz,
                                  long *nhnz, double epsillon) {
  long left = nl, right = nh;
  ;
  while (fabs(v[left]) < epsillon && left <= nh)
    left++;
  while (fabs(v[right]) < epsillon && right >= nl)
    right--;
  *nlnz = left;
  *nhnz = right;
}


x86 assembly (clang, -O0):
<extractnz_boundaries_dvector>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movaps 0xebf(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
xor    %eax,%eax
ucomisd %xmm1,%xmm0
mov    %al,-0x41(%rbp)
jbe    1167 <extractnz_boundaries_dvector+0x67>
mov    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
setle  %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    1177 <extractnz_boundaries_dvector+0x77>
jmp    1188 <extractnz_boundaries_dvector+0x88>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    112d <extractnz_boundaries_dvector+0x2d>
jmp    118d <extractnz_boundaries_dvector+0x8d>
mov    -0x8(%rbp),%rax
mov    -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movaps 0xe5f(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
xor    %eax,%eax
ucomisd %xmm1,%xmm0
mov    %al,-0x42(%rbp)
jbe    11c7 <extractnz_boundaries_dvector+0xc7>
mov    -0x40(%rbp),%rax
cmp    -0x10(%rbp),%rax
setge  %al
mov    %al,-0x42(%rbp)
mov    -0x42(%rbp),%al
test   $0x1,%al
jne    11d7 <extractnz_boundaries_dvector+0xd7>
jmp    11e8 <extractnz_boundaries_dvector+0xe8>
mov    -0x40(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x40(%rbp)
jmp    118d <extractnz_boundaries_dvector+0x8d>
mov    -0x38(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x40(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<extractnz_boundaries_dvector>:
movapd 0xef8(%rip),%xmm1
mov    %rsi,%rax
nopl   0x0(%rax,%rax,1)
movsd  (%rdi,%rax,8),%xmm2
andpd  %xmm1,%xmm2
lea    0x1(%rax),%r9
ucomisd %xmm2,%xmm0
jbe    112b <extractnz_boundaries_dvector+0x2b>
cmp    %rdx,%rax
mov    %r9,%rax
jle    1110 <extractnz_boundaries_dvector+0x10>
add    $0xffffffffffffffff,%r9
nop
movsd  (%rdi,%rdx,8),%xmm2
andpd  %xmm1,%xmm2
lea    -0x1(%rdx),%rax
ucomisd %xmm2,%xmm0
jbe    114b <extractnz_boundaries_dvector+0x4b>
cmp    %rsi,%rdx
mov    %rax,%rdx
jge    1130 <extractnz_boundaries_dvector+0x30>
mov    %r9,(%rcx)
add    $0x1,%rax
mov    %rax,(%r8)
ret

LLVM IR (-O0):
define void @extractnz_boundaries_dvector(double* %0, i64 %1, i64 %2, i64* %3, i64* %4, double %5) {
%7 = alloca double*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64*
%11 = alloca i64*
%12 = alloca double
%13 = alloca i64
%14 = alloca i64
store double* %0, double** %7
store i64 %1, i64* %8
store i64 %2, i64* %9
store i64* %3, i64** %10
store i64* %4, i64** %11
store double %5, double* %12
%15 = load i64, i64* %8
store i64 %15, i64* %13
%16 = load i64, i64* %9
store i64 %16, i64* %14
br label %17
17: ; preds = %31, %6
%18 = load double*, double** %7
%19 = load i64, i64* %13
%20 = getelementptr inbounds double, double* %18, i64 %19
%21 = load double, double* %20
%22 = call double @llvm.fabs.f64(double %21)
%23 = load double, double* %12
%24 = fcmp olt double %22, %23
br i1 %24, label %25, label %29
25: ; preds = %17
%26 = load i64, i64* %13
%27 = load i64, i64* %9
%28 = icmp sle i64 %26, %27
br label %29
29: ; preds = %25, %17
%30 = phi i1 [ false, %17 ], [ %28, %25 ]
br i1 %30, label %31, label %34
31: ; preds = %29
%32 = load i64, i64* %13
%33 = add nsw i64 %32, 1
store i64 %33, i64* %13
br label %17
34: ; preds = %29
br label %35
35: ; preds = %49, %34
%36 = load double*, double** %7
%37 = load i64, i64* %14
%38 = getelementptr inbounds double, double* %36, i64 %37
%39 = load double, double* %38
%40 = call double @llvm.fabs.f64(double %39)
%41 = load double, double* %12
%42 = fcmp olt double %40, %41
br i1 %42, label %43, label %47
43: ; preds = %35
%44 = load i64, i64* %14
%45 = load i64, i64* %8
%46 = icmp sge i64 %44, %45
br label %47
47: ; preds = %43, %35
%48 = phi i1 [ false, %35 ], [ %46, %43 ]
br i1 %48, label %49, label %52
49: ; preds = %47
%50 = load i64, i64* %14
%51 = add nsw i64 %50, -1
store i64 %51, i64* %14
br label %35
52: ; preds = %47
%53 = load i64, i64* %13
%54 = load i64*, i64** %10
store i64 %53, i64* %54
%55 = load i64, i64* %14
%56 = load i64*, i64** %11
store i64 %55, i64* %56
ret void
}

LLVM IR (-O2):
define void @extractnz_boundaries_dvector(double* nocapture %0, i64 %1, i64 %2, i64* nocapture writeonly %3, i64* nocapture writeonly %4, double %5) {
br label %7
7: ; preds = %7, %6
%8 = phi i64 [ %1, %6 ], [ %15, %7 ]
%9 = getelementptr inbounds double, double* %0, i64 %8
%10 = load double, double* %9
%11 = tail call double @llvm.fabs.f64(double %10)
%12 = fcmp olt double %11, %5
%13 = icmp sle i64 %8, %2
%14 = select i1 %12, i1 %13, i1 false
%15 = add nsw i64 %8, 1
br i1 %14, label %7, label %16
16: ; preds = %7, %16
%17 = phi i64 [ %24, %16 ], [ %2, %7 ]
%18 = getelementptr inbounds double, double* %0, i64 %17
%19 = load double, double* %18
%20 = tail call double @llvm.fabs.f64(double %19)
%21 = fcmp olt double %20, %5
%22 = icmp sge i64 %17, %1
%23 = select i1 %21, i1 %22, i1 false
%24 = add nsw i64 %17, -1
br i1 %23, label %16, label %25
25: ; preds = %16
store i64 %8, i64* %3
store i64 %17, i64* %4
ret void
}