#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 */
typedef int /*<<< orphan*/ uint;

/* Variables and functions */
void extractnz_boundaries_uivector(uint *v, long nl, long nh, long *nlnz,
                                   long *nhnz) {
  long left = nl, right = nh;
  ;
  while (!v[left] && left <= nh)
    left++;
  while (!v[right] && right >= nl)
    right--;
  *nlnz = left;
  *nhnz = right;
}


x86 assembly (clang, -O0):
<extractnz_boundaries_uivector>:
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)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rcx
mov    -0x30(%rbp),%rdx
xor    %eax,%eax
cmpl   $0x0,(%rcx,%rdx,4)
mov    %al,-0x39(%rbp)
jne    114d <extractnz_boundaries_uivector+0x4d>
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
setle  %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    115d <extractnz_boundaries_uivector+0x5d>
jmp    116e <extractnz_boundaries_uivector+0x6e>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1128 <extractnz_boundaries_uivector+0x28>
jmp    1173 <extractnz_boundaries_uivector+0x73>
mov    -0x8(%rbp),%rcx
mov    -0x38(%rbp),%rdx
xor    %eax,%eax
cmpl   $0x0,(%rcx,%rdx,4)
mov    %al,-0x3a(%rbp)
jne    1198 <extractnz_boundaries_uivector+0x98>
mov    -0x38(%rbp),%rax
cmp    -0x10(%rbp),%rax
setge  %al
mov    %al,-0x3a(%rbp)
mov    -0x3a(%rbp),%al
test   $0x1,%al
jne    11a8 <extractnz_boundaries_uivector+0xa8>
jmp    11b9 <extractnz_boundaries_uivector+0xb9>
mov    -0x38(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x38(%rbp)
jmp    1173 <extractnz_boundaries_uivector+0x73>
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x38(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<extractnz_boundaries_uivector>:
mov    %rsi,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x1(%rax),%r9
cmpl   $0x0,(%rdi,%rax,4)
jne    1122 <extractnz_boundaries_uivector+0x22>
cmp    %rdx,%rax
mov    %r9,%rax
jle    1110 <extractnz_boundaries_uivector+0x10>
add    $0xffffffffffffffff,%r9
cs nopw 0x0(%rax,%rax,1)
lea    -0x1(%rdx),%rax
cmpl   $0x0,(%rdi,%rdx,4)
jne    1142 <extractnz_boundaries_uivector+0x42>
cmp    %rsi,%rdx
mov    %rax,%rdx
jge    1130 <extractnz_boundaries_uivector+0x30>
mov    %r9,(%rcx)
add    $0x1,%rax
mov    %rax,(%r8)
ret

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

LLVM IR (-O2):
define void @extractnz_boundaries_uivector(i32* nocapture %0, i64 %1, i64 %2, i64* nocapture writeonly %3, i64* nocapture writeonly %4) {
br label %6
6: ; preds = %6, %5
%7 = phi i64 [ %1, %5 ], [ %13, %6 ]
%8 = getelementptr inbounds i32, i32* %0, i64 %7
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, 0
%11 = icmp sle i64 %7, %2
%12 = select i1 %10, i1 %11, i1 false
%13 = add nsw i64 %7, 1
br i1 %12, label %6, label %14
14: ; preds = %6, %14
%15 = phi i64 [ %21, %14 ], [ %2, %6 ]
%16 = getelementptr inbounds i32, i32* %0, i64 %15
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 0
%19 = icmp sge i64 %15, %1
%20 = select i1 %18, i1 %19, i1 false
%21 = add nsw i64 %15, -1
br i1 %20, label %14, label %22
22: ; preds = %14
store i64 %7, i64* %3
store i64 %15, i64* %4
ret void
}