#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 */
int /*<<< orphan*/ extractnz_boundaries_uivector(int /*<<< orphan*/ *, long,
                                                 long, long *, long *);
void extractnz_boundaries_uimatrix(uint **m, long nrl, long nrh, long ncl,
                                   long nch, long *nclnz, long *nchnz) {
  int i;
  long a, b;
  long left, right;
  extractnz_boundaries_uivector(m[nrl], ncl, nch, &left, &right);
  for (i = nrl + 1; i <= nrh; i++) {
    extractnz_boundaries_uivector(m[i], ncl, nch, &a, &b);
    if (a < left)
      left = a;
    if (b > right)
      right = b;
  }
  *nclnz = left;
  *nchnz = right;
}


x86 assembly (clang, -O0):
<extractnz_boundaries_uimatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    -0x50(%rbp),%rcx
lea    -0x58(%rbp),%r8
call   1030 <extractnz_boundaries_uivector@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x34(%rbp)
movslq -0x34(%rbp),%rax
cmp    -0x18(%rbp),%rax
jg     11ce <extractnz_boundaries_uimatrix+0xbe>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    -0x40(%rbp),%rcx
lea    -0x48(%rbp),%r8
call   1030 <extractnz_boundaries_uivector@plt>
mov    -0x40(%rbp),%rax
cmp    -0x50(%rbp),%rax
jge    11a5 <extractnz_boundaries_uimatrix+0x95>
mov    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x48(%rbp),%rax
cmp    -0x58(%rbp),%rax
jle    11bb <extractnz_boundaries_uimatrix+0xab>
mov    -0x48(%rbp),%rax
mov    %rax,-0x58(%rbp)
jmp    11c0 <extractnz_boundaries_uimatrix+0xb0>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1160 <extractnz_boundaries_uimatrix+0x50>
mov    -0x50(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x58(%rbp),%rcx
mov    0x10(%rbp),%rax
mov    %rcx,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extractnz_boundaries_uimatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,0x10(%rsp)
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    (%rdi,%rsi,8),%rdi
lea    0x8(%rsp),%rcx
mov    %rsp,%r8
mov    %r12,%rsi
mov    %r15,%rdx
call   1030 <extractnz_boundaries_uivector@plt>
add    $0x1,%ebp
movslq %ebp,%rbp
cmp    %r13,%rbp
jle    117c <extractnz_boundaries_uimatrix+0x6c>
mov    0x8(%rsp),%rax
mov    (%rsp),%rcx
mov    0x10(%rsp),%rdx
mov    %rax,(%rdx)
mov    0x60(%rsp),%rax
mov    %rcx,(%rax)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x18(%rsp),%r14
jmp    11aa <extractnz_boundaries_uimatrix+0x9a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
shl    $0x20,%rbp
movabs $0x100000000,%rdx
add    %rdx,%rbp
sar    $0x20,%rbp
cmp    %r13,%rbp
jg     115d <extractnz_boundaries_uimatrix+0x4d>
mov    (%rbx,%rbp,8),%rdi
mov    %r12,%rsi
mov    %r15,%rdx
lea    0x20(%rsp),%rcx
mov    %r14,%r8
call   1030 <extractnz_boundaries_uivector@plt>
mov    0x20(%rsp),%rcx
mov    0x8(%rsp),%rax
cmp    %rax,%rcx
jge    11d8 <extractnz_boundaries_uimatrix+0xc8>
mov    %rcx,0x8(%rsp)
mov    %rcx,%rax
mov    0x18(%rsp),%rdx
mov    (%rsp),%rcx
cmp    %rcx,%rdx
jle    1190 <extractnz_boundaries_uimatrix+0x80>
mov    %rdx,(%rsp)
mov    %rdx,%rcx
jmp    1190 <extractnz_boundaries_uimatrix+0x80>

LLVM IR (-O0):
define void @extractnz_boundaries_uimatrix(i32** %0, i64 %1, i64 %2, i64 %3, i64 %4, i64* %5, i64* %6) {
%8 = alloca i32**
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64*
%14 = alloca i64*
%15 = alloca i32
%16 = alloca i64
%17 = alloca i64
%18 = alloca i64
%19 = alloca i64
store i32** %0, i32*** %8
store i64 %1, i64* %9
store i64 %2, i64* %10
store i64 %3, i64* %11
store i64 %4, i64* %12
store i64* %5, i64** %13
store i64* %6, i64** %14
%20 = load i32**, i32*** %8
%21 = load i64, i64* %9
%22 = getelementptr inbounds i32*, i32** %20, i64 %21
%23 = load i32*, i32** %22
%24 = load i64, i64* %11
%25 = load i64, i64* %12
%26 = call i32 @extractnz_boundaries_uivector(i32* %23, i64 %24, i64 %25, i64* %18, i64* %19)
%27 = load i64, i64* %9
%28 = add nsw i64 %27, 1
%29 = trunc i64 %28 to i32
store i32 %29, i32* %15
br label %30
30: ; preds = %56, %7
%31 = load i32, i32* %15
%32 = sext i32 %31 to i64
%33 = load i64, i64* %10
%34 = icmp sle i64 %32, %33
br i1 %34, label %35, label %59
35: ; preds = %30
%36 = load i32**, i32*** %8
%37 = load i32, i32* %15
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32*, i32** %36, i64 %38
%40 = load i32*, i32** %39
%41 = load i64, i64* %11
%42 = load i64, i64* %12
%43 = call i32 @extractnz_boundaries_uivector(i32* %40, i64 %41, i64 %42, i64* %16, i64* %17)
%44 = load i64, i64* %16
%45 = load i64, i64* %18
%46 = icmp slt i64 %44, %45
br i1 %46, label %47, label %49
47: ; preds = %35
%48 = load i64, i64* %16
store i64 %48, i64* %18
br label %49
49: ; preds = %47, %35
%50 = load i64, i64* %17
%51 = load i64, i64* %19
%52 = icmp sgt i64 %50, %51
br i1 %52, label %53, label %55
53: ; preds = %49
%54 = load i64, i64* %17
store i64 %54, i64* %19
br label %55
55: ; preds = %53, %49
br label %56
56: ; preds = %55
%57 = load i32, i32* %15
%58 = add nsw i32 %57, 1
store i32 %58, i32* %15
br label %30
59: ; preds = %30
%60 = load i64, i64* %18
%61 = load i64*, i64** %13
store i64 %60, i64* %61
%62 = load i64, i64* %19
%63 = load i64*, i64** %14
store i64 %62, i64* %63
ret void
}

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