#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 ssize_t;

/* Variables and functions */
scalar_t__ EINTR;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ close(int);
scalar_t__ errno;
int getpid();
int /*<<< orphan*/ memmove(char *, char *, int);
int open(char *, int /*<<< orphan*/);
int read(int, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int sscanf(char *, char *, void **, void **, char *, int *, int *, int *, int *,
           char *);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int gsegbounds(void *sample, void **start, void **end) {
  int success = 0, fd = -1;
  void *localStart = NULL, *localEnd = NULL;
  char buf[256] = {0}, localPathname[256] = {0}, localPerms[16] = {0};
  int localOffset = 0, localDevMinor = 0, localDevMajor = 0;
  int localInode = 0;
  assert(start && end);
  *start = *end = NULL;
  sprintf(buf, "/proc/%d/maps", getpid());
  fd = open(buf, O_RDONLY);
  if (fd != -1) {
    char *bufGetCursor = buf, *bufPutCursor = buf;
    char *bufEolCursor = NULL;
    ssize_t readSz = 0, availSz = 0;
    int numParsed = 0;
    while (1) {
      if (bufGetCursor != buf) {
        readSz = bufPutCursor - bufGetCursor;
        memmove(buf, bufGetCursor, readSz);
        bufGetCursor = buf;
        bufPutCursor = buf + readSz;
      }
      availSz = sizeof buf - 1 - (bufPutCursor - buf);
      readSz = read(fd, bufPutCursor, availSz);
      if (readSz == -1) {
        if (errno == EINTR)
          continue;
        break;
      }
      0 [bufPutCursor += readSz] = 0;
      if (readSz == 0 && bufGetCursor >= bufPutCursor)
        break;
      bufEolCursor = strchr(buf, '\n');
      if (!bufEolCursor) {
        if (readSz == 0)
          bufEolCursor = bufPutCursor;
        else
          break;
      }
      *bufEolCursor = 0;
      strcpy(localPathname, "");
      numParsed =
          sscanf(bufGetCursor, "%p-%p %15s %x %x:%x %d %255s", &localStart,
                 &localEnd, localPerms, &localOffset, &localDevMajor,
                 &localDevMinor, &localInode, localPathname);
      if (numParsed != 7 && numParsed != 8)
        break;
      bufGetCursor = bufEolCursor + 1;
      if (localStart <= sample && sample < localEnd) {
        success = 1;
        if (strchr(localPerms, 'r') == NULL) {
          localStart = localEnd = NULL;
        }
        break;
      }
    }
  }
  close(fd);
  fd = -1;
  if (success) {
    *start = localStart;
    *end = localEnd;
  }
  return success;
}


x86 assembly (clang, -O0):
<gsegbounds>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x2a8,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0xffffffff,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
lea    -0x140(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
lea    -0x240(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
lea    -0x250(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
movl   $0x0,-0x254(%rbp)
movl   $0x0,-0x258(%rbp)
movl   $0x0,-0x25c(%rbp)
movl   $0x0,-0x260(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x285(%rbp)
je     1268 <gsegbounds+0xb8>
cmpq   $0x0,-0x20(%rbp)
setne  %al
mov    %al,-0x285(%rbp)
mov    -0x285(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
lea    -0x140(%rbp),%rax
mov    %rax,-0x290(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x290(%rbp),%rdi
mov    %eax,%edx
lea    0xd4d(%rip),%rsi
call   10d0 <sprintf@plt>
lea    -0x140(%rbp),%rdi
mov    0x2d22(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
je     1597 <gsegbounds+0x3e7>
lea    -0x140(%rbp),%rax
mov    %rax,-0x268(%rbp)
lea    -0x140(%rbp),%rax
mov    %rax,-0x270(%rbp)
movq   $0x0,-0x278(%rbp)
movl   $0x0,-0x27c(%rbp)
movl   $0x0,-0x280(%rbp)
movl   $0x0,-0x284(%rbp)
mov    -0x268(%rbp),%rax
lea    -0x140(%rbp),%rcx
cmp    %rcx,%rax
je     138c <gsegbounds+0x1dc>
mov    -0x270(%rbp),%rax
mov    -0x268(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x27c(%rbp)
lea    -0x140(%rbp),%rdi
mov    -0x268(%rbp),%rsi
mov    -0x27c(%rbp),%edx
call   10b0 <memmove@plt>
lea    -0x140(%rbp),%rax
mov    %rax,-0x268(%rbp)
lea    -0x140(%rbp),%rax
movslq -0x27c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x270(%rbp)
mov    -0x270(%rbp),%rcx
lea    -0x140(%rbp),%rax
sub    %rax,%rcx
mov    $0xff,%eax
sub    %rcx,%rax
mov    %eax,-0x280(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x270(%rbp),%rsi
mov    -0x280(%rbp),%edx
call   1080 <read@plt>
mov    %eax,-0x27c(%rbp)
cmpl   $0xffffffff,-0x27c(%rbp)
jne    13f7 <gsegbounds+0x247>
mov    0x2bfe(%rip),%rax
mov    (%rax),%rax
mov    0x2bec(%rip),%rcx
cmp    (%rcx),%rax
jne    13f2 <gsegbounds+0x242>
jmp    131f <gsegbounds+0x16f>
jmp    1592 <gsegbounds+0x3e2>
mov    -0x27c(%rbp),%ecx
mov    -0x270(%rbp),%rax
movslq %ecx,%rcx
mov    %rax,%rdx
add    %rcx,%rdx
mov    %rdx,-0x270(%rbp)
movb   $0x0,(%rax,%rcx,1)
cmpl   $0x0,-0x27c(%rbp)
jne    143e <gsegbounds+0x28e>
mov    -0x268(%rbp),%rax
cmp    -0x270(%rbp),%rax
jb     143e <gsegbounds+0x28e>
jmp    1592 <gsegbounds+0x3e2>
lea    -0x140(%rbp),%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
mov    %rax,-0x278(%rbp)
cmpq   $0x0,-0x278(%rbp)
jne    148e <gsegbounds+0x2de>
cmpl   $0x0,-0x27c(%rbp)
jne    1484 <gsegbounds+0x2d4>
mov    -0x270(%rbp),%rax
mov    %rax,-0x278(%rbp)
jmp    1489 <gsegbounds+0x2d9>
jmp    1592 <gsegbounds+0x3e2>
jmp    148e <gsegbounds+0x2de>
mov    -0x278(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x240(%rbp),%rdi
lea    0xb84(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x268(%rbp),%rdi
lea    -0x250(%rbp),%r8
lea    -0x240(%rbp),%rax
lea    0xb47(%rip),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x254(%rbp),%r9
lea    -0x25c(%rbp),%rbx
lea    -0x258(%rbp),%r11
lea    -0x260(%rbp),%r10
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   10a0 <sscanf@plt>
mov    %eax,-0x284(%rbp)
cmpl   $0x7,-0x284(%rbp)
je     1528 <gsegbounds+0x378>
cmpl   $0x8,-0x284(%rbp)
je     1528 <gsegbounds+0x378>
jmp    1592 <gsegbounds+0x3e2>
mov    -0x278(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x268(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x10(%rbp),%rax
ja     158d <gsegbounds+0x3dd>
mov    -0x10(%rbp),%rax
cmp    -0x38(%rbp),%rax
jae    158d <gsegbounds+0x3dd>
movl   $0x1,-0x24(%rbp)
lea    -0x250(%rbp),%rdi
mov    $0x72,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
jne    1588 <gsegbounds+0x3d8>
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x30(%rbp)
jmp    1592 <gsegbounds+0x3e2>
jmp    131f <gsegbounds+0x16f>
jmp    1597 <gsegbounds+0x3e7>
mov    -0x28(%rbp),%edi
call   1070 <close@plt>
movl   $0xffffffff,-0x28(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     15c6 <gsegbounds+0x416>
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x38(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x24(%rbp),%eax
add    $0x2a8,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<gsegbounds>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x258,%rsp
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %rdi,0x28(%rsp)
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x240(%rsp)
movaps %xmm0,0x230(%rsp)
movaps %xmm0,0x220(%rsp)
movaps %xmm0,0x210(%rsp)
movaps %xmm0,0x200(%rsp)
movaps %xmm0,0x1f0(%rsp)
movaps %xmm0,0x1e0(%rsp)
movaps %xmm0,0x1d0(%rsp)
movaps %xmm0,0x1c0(%rsp)
movaps %xmm0,0x1b0(%rsp)
movaps %xmm0,0x1a0(%rsp)
movaps %xmm0,0x190(%rsp)
movaps %xmm0,0x180(%rsp)
movaps %xmm0,0x170(%rsp)
movaps %xmm0,0x160(%rsp)
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x40(%rsp)
movl   $0x0,0x24(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x0,0x1c(%rsp)
movl   $0x0,0x18(%rsp)
test   %rsi,%rsi
setne  %al
test   %rdx,%rdx
setne  %cl
and    %al,%cl
movzbl %cl,%edi
call   1080 <assert@plt>
mov    %rbx,0x38(%rsp)
movq   $0x0,(%rbx)
mov    %rbp,0x30(%rsp)
movq   $0x0,0x0(%rbp)
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xcd6(%rip),%rsi
lea    0x50(%rsp),%r15
mov    %r15,%rdi
mov    %eax,%edx
call   10c0 <sprintf@plt>
mov    0x2ca8(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
call   10b0 <open@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
je     14de <gsegbounds+0x33e>
mov    %r15,%rbx
mov    %r15,%r12
jmp    137d <gsegbounds+0x1dd>
nopl   (%rax)
mov    0x2c71(%rip),%rax
mov    (%rax),%rax
mov    %r15,%rbx
mov    0x2c5c(%rip),%rcx
cmp    (%rcx),%rax
jne    14de <gsegbounds+0x33e>
cmp    %r15,%rbx
je     139e <gsegbounds+0x1fe>
sub    %rbx,%r12
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   10a0 <memmove@plt>
movslq %r12d,%rax
lea    (%rsp,%rax,1),%r12
add    $0x50,%r12
mov    %r15d,%edx
sub    %r12d,%edx
add    $0xff,%edx
mov    %ebp,%edi
mov    %r12,%rsi
call   1070 <read@plt>
cmp    $0xffffffff,%eax
je     1360 <gsegbounds+0x1c0>
mov    %eax,%r14d
cltq
lea    (%r12,%rax,1),%r13
movb   $0x0,(%r12,%rax,1)
test   %r14d,%r14d
jne    13d5 <gsegbounds+0x235>
cmp    %r13,%r15
jae    14de <gsegbounds+0x33e>
mov    %r15,%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
mov    %rax,%rbx
test   %r14d,%r14d
je     13f3 <gsegbounds+0x253>
test   %rbx,%rbx
je     14de <gsegbounds+0x33e>
test   %rbx,%rbx
mov    %r13,%rax
cmovne %rbx,%rax
movb   $0x0,(%rax)
mov    %ebp,%r14d
lea    0x150(%rsp),%rbp
mov    %rbp,%rdi
lea    0xc15(%rip),%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
lea    0xbea(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x40(%rsp),%r8
lea    0x24(%rsp),%r9
push   %rbp
mov    %r14d,%ebp
lea    0x20(%rsp),%rax
push   %rax
lea    0x30(%rsp),%rax
push   %rax
lea    0x34(%rsp),%rax
push   %rax
call   1090 <sscanf@plt>
add    $0x20,%rsp
add    $0xfffffff7,%eax
cmp    $0xfffffffe,%eax
jb     14de <gsegbounds+0x33e>
test   %rbx,%rbx
cmove  %r13,%rbx
add    $0x1,%rbx
mov    %r13,%r12
mov    0x28(%rsp),%rax
cmp    %rax,0x10(%rsp)
ja     137d <gsegbounds+0x1dd>
mov    %r13,%r12
mov    0x28(%rsp),%rax
cmp    %rax,0x8(%rsp)
jbe    137d <gsegbounds+0x1dd>
lea    0x40(%rsp),%rdi
mov    $0x72,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    14b6 <gsegbounds+0x316>
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    %ebp,%edi
call   1060 <close@plt>
mov    0x10(%rsp),%rax
mov    0x30(%rsp),%rcx
mov    %rax,(%rcx)
mov    0x8(%rsp),%rax
mov    0x38(%rsp),%rcx
mov    %rax,(%rcx)
mov    $0x1,%eax
jmp    14e7 <gsegbounds+0x347>
mov    %ebp,%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x258,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"/proc/%d/maps\00"
@O_RDONLY = global i32 0
@errno = global i64 0
@EINTR = global i64 0
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [29 x i8] c"%p-%p %15s %x %x:%x %d %255s\00"
define i32 @gsegbounds(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [256 x i8]
%12 = alloca [256 x i8]
%13 = alloca [16 x i8]
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i8*
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
store i32 0, i32* %7
store i32 -1, i32* %8
store i8* null, i8** %9
store i8* null, i8** %10
%24 = bitcast [256 x i8]* %11 to i8*
%25 = bitcast [256 x i8]* %12 to i8*
%26 = bitcast [16 x i8]* %13 to i8*
store i32 0, i32* %14
store i32 0, i32* %15
store i32 0, i32* %16
store i32 0, i32* %17
%27 = load i8**, i8*** %5
%28 = icmp ne i8** %27, null
br i1 %28, label %29, label %32
29: ; preds = %3
%30 = load i8**, i8*** %6
%31 = icmp ne i8** %30, null
br label %32
32: ; preds = %29, %3
%33 = phi i1 [ false, %3 ], [ %31, %29 ]
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
%36 = load i8**, i8*** %6
store i8* null, i8** %36
%37 = load i8**, i8*** %5
store i8* null, i8** %37
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%39 = call i32 (...) @getpid()
%40 = call i32 @sprintf(i8* %38, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %39)
%41 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%42 = load i32, i32* @O_RDONLY
%43 = call i32 @open(i8* %41, i32 %42)
store i32 %43, i32* %8
%44 = load i32, i32* %8
%45 = icmp ne i32 %44, -1
br i1 %45, label %46, label %146
46: ; preds = %32
%47 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
store i8* %47, i8** %18
%48 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
store i8* %48, i8** %19
store i8* null, i8** %20
store i32 0, i32* %21
store i32 0, i32* %22
store i32 0, i32* %23
br label %49
49: ; preds = %46, %87, %144
%50 = load i8*, i8** %18
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%52 = icmp ne i8* %50, %51
br i1 %52, label %53, label %69
53: ; preds = %49
%54 = load i8*, i8** %19
%55 = load i8*, i8** %18
%56 = ptrtoint i8* %54 to i64
%57 = ptrtoint i8* %55 to i64
%58 = sub i64 %56, %57
%59 = trunc i64 %58 to i32
store i32 %59, i32* %21
%60 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%61 = load i8*, i8** %18
%62 = load i32, i32* %21
%63 = call i32 @memmove(i8* %60, i8* %61, i32 %62)
%64 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
store i8* %64, i8** %18
%65 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%66 = load i32, i32* %21
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8, i8* %65, i64 %67
store i8* %68, i8** %19
br label %69
69: ; preds = %53, %49
%70 = load i8*, i8** %19
%71 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%72 = ptrtoint i8* %70 to i64
%73 = ptrtoint i8* %71 to i64
%74 = sub i64 %72, %73
%75 = sub i64 255, %74
%76 = trunc i64 %75 to i32
store i32 %76, i32* %22
%77 = load i32, i32* %8
%78 = load i8*, i8** %19
%79 = load i32, i32* %22
%80 = call i32 @read(i32 %77, i8* %78, i32 %79)
store i32 %80, i32* %21
%81 = load i32, i32* %21
%82 = icmp eq i32 %81, -1
br i1 %82, label %83, label %89
83: ; preds = %69
%84 = load i64, i64* @errno
%85 = load i64, i64* @EINTR
%86 = icmp eq i64 %84, %85
br i1 %86, label %87, label %88
87: ; preds = %83
br label %49
88: ; preds = %83
br label %145
89: ; preds = %69
%90 = load i32, i32* %21
%91 = load i8*, i8** %19
%92 = sext i32 %90 to i64
%93 = getelementptr inbounds i8, i8* %91, i64 %92
store i8* %93, i8** %19
%94 = getelementptr inbounds i8, i8* %93, i64 0
store i8 0, i8* %94
%95 = load i32, i32* %21
%96 = icmp eq i32 %95, 0
br i1 %96, label %97, label %102
97: ; preds = %89
%98 = load i8*, i8** %18
%99 = load i8*, i8** %19
%100 = icmp uge i8* %98, %99
br i1 %100, label %101, label %102
101: ; preds = %97
br label %145
102: ; preds = %97, %89
%103 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%104 = call i8* @strchr(i8* %103, i8 signext 10)
store i8* %104, i8** %20
%105 = load i8*, i8** %20
%106 = icmp ne i8* %105, null
br i1 %106, label %114, label %107
107: ; preds = %102
%108 = load i32, i32* %21
%109 = icmp eq i32 %108, 0
br i1 %109, label %110, label %112
110: ; preds = %107
%111 = load i8*, i8** %19
store i8* %111, i8** %20
br label %113
112: ; preds = %107
br label %145
113: ; preds = %110
br label %114
114: ; preds = %113, %102
%115 = load i8*, i8** %20
store i8 0, i8* %115
%116 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%117 = call i32 @strcpy(i8* %116, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%118 = load i8*, i8** %18
%119 = getelementptr inbounds [16 x i8], [16 x i8]* %13, i64 0, i64 0
%120 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%121 = call i32 @sscanf(i8* %118, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8** %9, i8** %10, i8* %119, i32* %14, i32* %16, i32* %15, i32* %17, i8* %120)
store i32 %121, i32* %23
%122 = load i32, i32* %23
%123 = icmp ne i32 %122, 7
br i1 %123, label %124, label %128
124: ; preds = %114
%125 = load i32, i32* %23
%126 = icmp ne i32 %125, 8
br i1 %126, label %127, label %128
127: ; preds = %124
br label %145
128: ; preds = %124, %114
%129 = load i8*, i8** %20
%130 = getelementptr inbounds i8, i8* %129, i64 1
store i8* %130, i8** %18
%131 = load i8*, i8** %9
%132 = load i8*, i8** %4
%133 = icmp ule i8* %131, %132
br i1 %133, label %134, label %144
134: ; preds = %128
%135 = load i8*, i8** %4
%136 = load i8*, i8** %10
%137 = icmp ult i8* %135, %136
br i1 %137, label %138, label %144
138: ; preds = %134
store i32 1, i32* %7
%139 = getelementptr inbounds [16 x i8], [16 x i8]* %13, i64 0, i64 0
%140 = call i8* @strchr(i8* %139, i8 signext 114)
%141 = icmp eq i8* %140, null
br i1 %141, label %142, label %143
142: ; preds = %138
store i8* null, i8** %10
store i8* null, i8** %9
br label %143
143: ; preds = %142, %138
br label %145
144: ; preds = %134, %128
br label %49
145: ; preds = %143, %127, %112, %101, %88
br label %146
146: ; preds = %145, %32
%147 = load i32, i32* %8
%148 = call i32 @close(i32 %147)
store i32 -1, i32* %8
%149 = load i32, i32* %7
%150 = icmp ne i32 %149, 0
br i1 %150, label %151, label %156
151: ; preds = %146
%152 = load i8*, i8** %9
%153 = load i8**, i8*** %5
store i8* %152, i8** %153
%154 = load i8*, i8** %10
%155 = load i8**, i8*** %6
store i8* %154, i8** %155
br label %156
156: ; preds = %151, %146
%157 = load i32, i32* %7
ret i32 %157
}

LLVM IR (-O2):
@.str = [14 x i8] c"/proc/%d/maps\00"
@O_RDONLY = global i32 0
@errno = global i64 0
@EINTR = global i64 0
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [29 x i8] c"%p-%p %15s %x %x:%x %d %255s\00"
define i32 @gsegbounds(i8* readnone %0, i8** writeonly %1, i8** writeonly %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [256 x i8]
%7 = alloca [256 x i8]
%8 = alloca [16 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%14 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%17 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%18 = bitcast i32* %9 to i8*
store i32 0, i32* %9
%19 = bitcast i32* %10 to i8*
store i32 0, i32* %10
%20 = bitcast i32* %11 to i8*
store i32 0, i32* %11
%21 = bitcast i32* %12 to i8*
store i32 0, i32* %12
%22 = icmp ne i8** %1, null
%23 = icmp ne i8** %2, null
%24 = and i1 %22, %23
%25 = zext i1 %24 to i32
%26 = tail call i32 @assert(i32 %25)
store i8* null, i8** %2
store i8* null, i8** %1
%27 = tail call i32 (...) @getpid()
%28 = call i32 @sprintf(i8* %15, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = load i32, i32* @O_RDONLY
%30 = call i32 @open(i8* %15, i32 %29)
%31 = icmp eq i32 %30, -1
br i1 %31, label %90, label %32
32: ; preds = %3
%33 = ptrtoint [256 x i8]* %6 to i64
br label %34
34: ; preds = %59, %32
%35 = phi i8* [ %15, %32 ], [ %60, %59 ]
%36 = phi i8* [ %15, %32 ], [ %61, %59 ]
%37 = icmp eq i8* %35, %15
br i1 %37, label %47, label %38
38: ; preds = %34
%39 = ptrtoint i8* %36 to i64
%40 = ptrtoint i8* %35 to i64
%41 = sub i64 %39, %40
%42 = trunc i64 %41 to i32
%43 = call i32 @memmove(i8* %15, i8* %35, i32 %42)
%44 = shl i64 %41, 32
%45 = ashr exact i64 %44, 32
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %45
br label %47
47: ; preds = %38, %34
%48 = phi i8* [ %46, %38 ], [ %36, %34 ]
%49 = ptrtoint i8* %48 to i64
%50 = sub i64 %33, %49
%51 = trunc i64 %50 to i32
%52 = add i32 %51, 255
%53 = call i32 @read(i32 %30, i8* %48, i32 %52)
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %62
55: ; preds = %47
%56 = load i64, i64* @errno
%57 = load i64, i64* @EINTR
%58 = icmp eq i64 %56, %57
br i1 %58, label %59, label %90
59: ; preds = %55, %78
%60 = phi i8* [ %15, %55 ], [ %80, %78 ]
%61 = phi i8* [ %48, %55 ], [ %64, %78 ]
br label %34
62: ; preds = %47
%63 = sext i32 %53 to i64
%64 = getelementptr inbounds i8, i8* %48, i64 %63
store i8 0, i8* %64
%65 = icmp eq i32 %53, 0
%66 = icmp uge i8* %15, %64
%67 = and i1 %65, %66
br i1 %67, label %90, label %68
68: ; preds = %62
%69 = call i8* @strchr(i8* %15, i8 signext 10)
%70 = icmp ne i8* %69, null
%71 = or i1 %65, %70
br i1 %71, label %72, label %90
72: ; preds = %68
%73 = select i1 %70, i8* %69, i8* %64
store i8 0, i8* %73
%74 = call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%75 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8** %4, i8** %5, i8* %17, i32* %9, i32* %11, i32* %10, i32* %12, i8* %16)
%76 = add i32 %75, -9
%77 = icmp ult i32 %76, -2
br i1 %77, label %90, label %78
78: ; preds = %72
%79 = select i1 %70, i8* %69, i8* %64
%80 = getelementptr inbounds i8, i8* %79, i64 1
%81 = load i8*, i8** %4
%82 = icmp ule i8* %81, %0
%83 = load i8*, i8** %5
%84 = icmp ugt i8* %83, %0
%85 = select i1 %82, i1 %84, i1 false
br i1 %85, label %86, label %59
86: ; preds = %78
%87 = call i8* @strchr(i8* %17, i8 signext 114)
%88 = icmp eq i8* %87, null
br i1 %88, label %89, label %92
89: ; preds = %86
store i8* null, i8** %5
store i8* null, i8** %4
br label %92
90: ; preds = %55, %72, %62, %68, %3
%91 = call i32 @close(i32 %30)
br label %96
92: ; preds = %86, %89
%93 = call i32 @close(i32 %30)
%94 = load i8*, i8** %4
store i8* %94, i8** %1
%95 = load i8*, i8** %5
store i8* %95, i8** %2
br label %96
96: ; preds = %90, %92
%97 = phi i32 [ 0, %90 ], [ 1, %92 ]
ret i32 %97
}