#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 */
struct stat {
  int dummy;
};
typedef int /*<<< orphan*/ path;
typedef int /*<<< orphan*/ nl_catd;

/* Variables and functions */
int EINVAL;
int ENAMETOOLONG;
int ENOENT;
int /*<<< orphan*/ LC_MESSAGES;
int NL_CAT_LOCALE;
int PATH_MAX;
int errno;
int /*<<< orphan*/ free(char *);
char *getenv(char *);
scalar_t__ issetugid();
int /*<<< orphan*/ load_msgcat(char const *);
char *setlocale(int /*<<< orphan*/, int /*<<< orphan*/ *);
scalar_t__ stat(char *, struct stat *);
char *strchr(char const *, char);
char *strdup(char *);
int strlcpy(char *, char *, int);
int strlen(char *);
char *strsep(char **, char *);
nl_catd catopen(const char *name, int type) {
  int spcleft, saverr;
  char path[PATH_MAX];
  char *nlspath, *lang, *base, *cptr, *pathP, *tmpptr;
  char *cptr1, *plang, *pter, *pcode;
  struct stat sbuf;
  if (name == NULL || *name == '\0') {
    errno = EINVAL;
    return (((nl_catd)-1));
  };
  if (strchr(name, '/') != NULL)
    return (load_msgcat(name));
  if (type == NL_CAT_LOCALE)
    lang = setlocale(LC_MESSAGES, NULL);
  else
    lang = getenv("LANG");
  if (lang == NULL || *lang == '\0' || strlen(lang) > 31 ||
      (lang[0] == '.' &&
       (lang[1] == '\0' || (lang[1] == '.' && lang[2] == '\0'))) ||
      strchr(lang, '/') != NULL)
    lang = "C";
  if ((plang = cptr1 = strdup(lang)) == NULL)
    return (((nl_catd)-1));
  if ((cptr = strchr(cptr1, '@')) != NULL)
    *cptr = '\0';
  pter = pcode = "";
  if ((cptr = strchr(cptr1, '_')) != NULL) {
    *cptr++ = '\0';
    pter = cptr1 = cptr;
  }
  if ((cptr = strchr(cptr1, '.')) != NULL) {
    *cptr++ = '\0';
    pcode = cptr;
  }
  if ((nlspath = getenv("NLSPATH")) == NULL || issetugid())
    nlspath = "/usr/share/nls/%L/%N.cat:/usr/share/nls/%N/%L:/usr/local/share/"
              "nls/%L/%N.cat:/usr/local/share/nls/%N/%L";
  if ((base = cptr = strdup(nlspath)) == NULL) {
    saverr = errno;
    free(plang);
    errno = saverr;
    return (((nl_catd)-1));
  }
  while ((nlspath = strsep(&cptr, ":")) != NULL) {
    pathP = path;
    if (*nlspath) {
      for (; *nlspath; ++nlspath) {
        if (*nlspath == '%') {
          switch (*(nlspath + 1)) {
          case 'l':
            tmpptr = plang;
            break;
          case 't':
            tmpptr = pter;
            break;
          case 'c':
            tmpptr = pcode;
            break;
          case 'L':
            tmpptr = lang;
            break;
          case 'N':
            tmpptr = (char *)name;
            break;
          case '%':
            ++nlspath;
          default:
            if (pathP - path >= sizeof(path) - 1)
              goto too_long;
            *(pathP++) = *nlspath;
            continue;
          }
          ++nlspath;
        put_tmpptr:
          spcleft = sizeof(path) - (pathP - path) - 1;
          if (strlcpy(pathP, tmpptr, spcleft) >= spcleft) {
          too_long:
            free(plang);
            free(base);
            {
              errno = ENAMETOOLONG;
              return (((nl_catd)-1));
            };
          }
          pathP += strlen(tmpptr);
        } else {
          if (pathP - path >= sizeof(path) - 1)
            goto too_long;
          *(pathP++) = *nlspath;
        }
      }
      *pathP = '\0';
      if (stat(path, &sbuf) == 0) {
        free(plang);
        free(base);
        return (load_msgcat(path));
      }
    } else {
      tmpptr = (char *)name;
      --nlspath;
      goto put_tmpptr;
    }
  }
  free(plang);
  free(base);
  {
    errno = ENOENT;
    return (((nl_catd)-1));
  };
}


x86 assembly (clang, -O0):
<catopen>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    0x2e27(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0xa0(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x98(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1213 <catopen+0x63>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    123b <catopen+0x8b>
mov    0x2da6(%rip),%rax
mov    (%rax),%ecx
mov    0x2dad(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x8c(%rbp)
jmp    17ae <catopen+0x5fe>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
cmp    $0x0,%rax
je     126e <catopen+0xbe>
mov    -0x10(%rbp),%rdi
call   10c0 <load_msgcat@plt>
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x8c(%rbp)
jmp    17ae <catopen+0x5fe>
mov    -0x14(%rbp),%eax
mov    0x2d60(%rip),%rcx
cmp    (%rcx),%eax
jne    129b <catopen+0xeb>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   10b0 <setlocale@plt>
mov    %rax,-0x40(%rbp)
jmp    12ab <catopen+0xfb>
lea    0xd5e(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     1333 <catopen+0x183>
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1333 <catopen+0x183>
mov    -0x40(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x1f,%eax
jg     1333 <catopen+0x183>
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    131b <catopen+0x16b>
mov    -0x40(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     1333 <catopen+0x183>
mov    -0x40(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2e,%eax
jne    131b <catopen+0x16b>
mov    -0x40(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x0,%eax
je     1333 <catopen+0x183>
mov    -0x40(%rbp),%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
cmp    $0x0,%rax
je     133e <catopen+0x18e>
lea    0xccb(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
call   10d0 <strdup@plt>
mov    %rax,-0x68(%rbp)
mov    %rax,-0x70(%rbp)
cmp    $0x0,%rax
jne    136f <catopen+0x1bf>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x8c(%rbp)
jmp    17ae <catopen+0x5fe>
mov    -0x68(%rbp),%rdi
mov    $0x40,%esi
call   1060 <strchr@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
je     1392 <catopen+0x1e2>
mov    -0x50(%rbp),%rax
movb   $0x0,(%rax)
lea    0xcdf(%rip),%rax
mov    %rax,-0x80(%rbp)
lea    0xcd4(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    -0x68(%rbp),%rdi
mov    $0x5f,%esi
call   1060 <strchr@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
je     13e2 <catopen+0x232>
mov    -0x50(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x50(%rbp)
movb   $0x0,(%rax)
mov    -0x50(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    %rax,-0x78(%rbp)
mov    -0x68(%rbp),%rdi
mov    $0x2e,%esi
call   1060 <strchr@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
je     1418 <catopen+0x268>
mov    -0x50(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x50(%rbp)
movb   $0x0,(%rax)
mov    -0x50(%rbp),%rax
mov    %rax,-0x80(%rbp)
lea    0xbe8(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
je     1443 <catopen+0x293>
mov    $0x0,%al
call   1080 <issetugid@plt>
cmp    $0x0,%rax
je     144e <catopen+0x29e>
lea    0xbc5(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   10d0 <strdup@plt>
mov    %rax,-0x50(%rbp)
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
jne    14a0 <catopen+0x2f0>
mov    0x2b60(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x70(%rbp),%rdi
call   1040 <free@plt>
mov    -0x1c(%rbp),%ecx
mov    0x2b48(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x8c(%rbp)
jmp    17ae <catopen+0x5fe>
jmp    14a5 <catopen+0x2f5>
lea    -0x50(%rbp),%rdi
lea    0xbc7(%rip),%rsi
call   1090 <strsep@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
je     1779 <catopen+0x5c9>
mov    -0x98(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x38(%rbp),%rax
cmpb   $0x0,(%rax)
je     175b <catopen+0x5ab>
jmp    14e0 <catopen+0x330>
mov    -0x38(%rbp),%rax
cmpb   $0x0,(%rax)
je     1702 <catopen+0x552>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
jne    16ae <catopen+0x4fe>
mov    -0x38(%rbp),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0xa4(%rbp)
sub    $0x25,%eax
je     15be <catopen+0x40e>
jmp    1519 <catopen+0x369>
mov    -0xa4(%rbp),%eax
sub    $0x4c,%eax
je     15a4 <catopen+0x3f4>
jmp    152d <catopen+0x37d>
mov    -0xa4(%rbp),%eax
sub    $0x4e,%eax
je     15b1 <catopen+0x401>
jmp    1541 <catopen+0x391>
mov    -0xa4(%rbp),%eax
sub    $0x63,%eax
je     1597 <catopen+0x3e7>
jmp    1555 <catopen+0x3a5>
mov    -0xa4(%rbp),%eax
sub    $0x6c,%eax
je     157d <catopen+0x3cd>
jmp    1569 <catopen+0x3b9>
mov    -0xa4(%rbp),%eax
sub    $0x74,%eax
je     158a <catopen+0x3da>
jmp    15ca <catopen+0x41a>
mov    -0x70(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    160d <catopen+0x45d>
mov    -0x78(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    160d <catopen+0x45d>
mov    -0x80(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    160d <catopen+0x45d>
mov    -0x40(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    160d <catopen+0x45d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    160d <catopen+0x45d>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0xa0(%rbp),%rcx
mov    -0x98(%rbp),%rdx
mov    -0x58(%rbp),%rax
sub    %rdx,%rax
sub    $0x1,%rcx
cmp    %rcx,%rax
jb     15f1 <catopen+0x441>
jmp    1656 <catopen+0x4a6>
mov    -0x38(%rbp),%rax
mov    (%rax),%cl
mov    -0x58(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x58(%rbp)
mov    %cl,(%rax)
jmp    16f1 <catopen+0x541>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0xa0(%rbp),%rax
mov    -0x98(%rbp),%rdx
mov    -0x58(%rbp),%rcx
sub    %rdx,%rcx
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,-0x18(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   10a0 <strlcpy@plt>
cmp    -0x18(%rbp),%eax
jl     1690 <catopen+0x4e0>
jmp    1656 <catopen+0x4a6>
mov    -0x70(%rbp),%rdi
call   1040 <free@plt>
mov    -0x48(%rbp),%rdi
call   1040 <free@plt>
mov    0x2949(%rip),%rax
mov    (%rax),%ecx
mov    0x2958(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x8c(%rbp)
jmp    17ae <catopen+0x5fe>
mov    -0x60(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x58(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x58(%rbp)
jmp    16ec <catopen+0x53c>
mov    -0xa0(%rbp),%rcx
mov    -0x98(%rbp),%rdx
mov    -0x58(%rbp),%rax
sub    %rdx,%rax
sub    $0x1,%rcx
cmp    %rcx,%rax
jb     16d5 <catopen+0x525>
jmp    1656 <catopen+0x4a6>
mov    -0x38(%rbp),%rax
mov    (%rax),%cl
mov    -0x58(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x58(%rbp)
mov    %cl,(%rax)
jmp    16f1 <catopen+0x541>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    14e0 <catopen+0x330>
mov    -0x98(%rbp),%rdi
mov    -0x58(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x88(%rbp),%rsi
call   1070 <stat@plt>
cmp    $0x0,%rax
jne    1756 <catopen+0x5a6>
mov    -0x70(%rbp),%rdi
call   1040 <free@plt>
mov    -0x48(%rbp),%rdi
call   1040 <free@plt>
mov    -0x98(%rbp),%rdi
call   10c0 <load_msgcat@plt>
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x8c(%rbp)
jmp    17ae <catopen+0x5fe>
jmp    1774 <catopen+0x5c4>
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x38(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x38(%rbp)
jmp    1619 <catopen+0x469>
jmp    14a5 <catopen+0x2f5>
mov    -0x70(%rbp),%rdi
call   1040 <free@plt>
mov    -0x48(%rbp),%rdi
call   1040 <free@plt>
mov    0x2816(%rip),%rax
mov    (%rax),%ecx
mov    0x2835(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x8c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<catopen>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    0x2e28(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%r15
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
test   %rdi,%rdi
je     1213 <catopen+0x63>
mov    %rdi,%r12
cmpb   $0x0,(%rdi)
je     1213 <catopen+0x63>
mov    %esi,%ebx
mov    %r12,%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     1239 <catopen+0x89>
mov    %r12,%rdi
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10c0 <load_msgcat@plt>
mov    0x2da6(%rip),%rax
mov    (%rax),%eax
mov    0x2dad(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffff,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d98(%rip),%rax
cmp    %ebx,(%rax)
jne    1256 <catopen+0xa6>
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   10b0 <setlocale@plt>
jmp    1262 <catopen+0xb2>
lea    0xe47(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r13
test   %rax,%rax
je     12aa <catopen+0xfa>
cmpb   $0x0,0x0(%r13)
je     12aa <catopen+0xfa>
mov    %r13,%rdi
call   1050 <strlen@plt>
cmp    $0x1f,%eax
jg     12aa <catopen+0xfa>
cmpb   $0x2e,0x0(%r13)
jne    1298 <catopen+0xe8>
mov    0x1(%r13),%al
test   %al,%al
je     12aa <catopen+0xfa>
cmp    $0x2e,%al
jne    1298 <catopen+0xe8>
cmpb   $0x0,0x2(%r13)
je     12aa <catopen+0xfa>
mov    %r13,%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     12b1 <catopen+0x101>
lea    0xdf8(%rip),%r13
mov    %r13,%rdi
call   10d0 <strdup@plt>
mov    %rax,%rdi
mov    $0xffffffff,%eax
test   %rdi,%rdi
je     122a <catopen+0x7a>
mov    %rdi,-0x30(%rbp)
mov    $0x40,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     12e0 <catopen+0x130>
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rbx
mov    %rbx,%rdi
mov    $0x5f,%esi
call   1060 <strchr@plt>
lea    0xe24(%rip),%rcx
mov    %rcx,-0x50(%rbp)
test   %rax,%rax
je     1316 <catopen+0x166>
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x38(%rbp)
movb   $0x0,(%rax)
mov    -0x38(%rbp),%rbx
mov    %rbx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %r13,-0x68(%rbp)
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     1346 <catopen+0x196>
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x38(%rbp)
movb   $0x0,(%rax)
mov    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    0xd5e(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1366 <catopen+0x1b6>
mov    %rax,%rbx
xor    %eax,%eax
call   1080 <issetugid@plt>
test   %rax,%rax
je     136d <catopen+0x1bd>
lea    0xd46(%rip),%rbx
mov    %rbx,%rdi
call   10d0 <strdup@plt>
mov    %rax,-0x38(%rbp)
test   %rax,%rax
je     14c4 <catopen+0x314>
mov    %rax,-0x40(%rbp)
lea    -0x1(%r14),%eax
mov    %eax,-0x44(%rbp)
add    $0xffffffffffffffff,%r14
mov    %r14,-0x58(%rbp)
mov    %r12,-0x70(%rbp)
jmp    13b8 <catopen+0x208>
nopl   0x0(%rax,%rax,1)
movb   $0x0,(%rbx)
mov    %r15,%rdi
lea    -0x78(%rbp),%rsi
call   1070 <stat@plt>
test   %rax,%rax
je     14f0 <catopen+0x340>
lea    -0x38(%rbp),%rdi
lea    0xd58(%rip),%rsi
call   1090 <strsep@plt>
test   %rax,%rax
je     14d2 <catopen+0x322>
movzbl (%rax),%ecx
mov    %r15,%rbx
test   %cl,%cl
je     13e1 <catopen+0x231>
test   %cl,%cl
jne    13f0 <catopen+0x240>
jmp    13a0 <catopen+0x1f0>
add    $0xffffffffffffffff,%rax
mov    %rax,%r14
mov    %r15,%rbx
mov    %r12,%r13
jmp    1460 <catopen+0x2b0>
cmp    $0x25,%cl
jne    1420 <catopen+0x270>
lea    0x1(%rax),%r14
movsbl 0x1(%rax),%ecx
lea    -0x4c(%rcx),%edx
cmp    $0x28,%edx
ja     142e <catopen+0x27e>
lea    0xbf4(%rip),%rsi
movslq (%rsi,%rdx,4),%rcx
add    %rsi,%rcx
mov    -0x30(%rbp),%r13
jmp    *%rcx
mov    -0x68(%rbp),%r13
jmp    1460 <catopen+0x2b0>
nop
mov    %rbx,%rdx
sub    %r15,%rdx
cmp    -0x58(%rbp),%rdx
jb     1445 <catopen+0x295>
jmp    14a6 <catopen+0x2f6>
cmp    $0x25,%ecx
jne    1436 <catopen+0x286>
mov    %r14,%rax
mov    %rbx,%rcx
sub    %r15,%rcx
cmp    -0x58(%rbp),%rcx
jae    14a6 <catopen+0x2f6>
movzbl (%rax),%ecx
mov    %cl,(%rbx)
add    $0x1,%rbx
jmp    1491 <catopen+0x2e1>
mov    %r12,%r13
jmp    1460 <catopen+0x2b0>
mov    -0x50(%rbp),%r13
jmp    1460 <catopen+0x2b0>
mov    -0x60(%rbp),%r13
nopl   0x0(%rax)
mov    %r15d,%r12d
sub    %ebx,%r12d
add    -0x44(%rbp),%r12d
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12d,%edx
call   10a0 <strlcpy@plt>
cmp    %r12d,%eax
mov    -0x70(%rbp),%r12
jge    14a6 <catopen+0x2f6>
mov    %r13,%rdi
call   1050 <strlen@plt>
cltq
add    %rax,%rbx
mov    %r14,%rax
movzbl 0x1(%rax),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    13f0 <catopen+0x240>
jmp    13a0 <catopen+0x1f0>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
mov    0x2af9(%rip),%rax
jmp    121a <catopen+0x6a>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
jmp    1225 <catopen+0x75>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
mov    0x2abd(%rip),%rax
jmp    121a <catopen+0x6a>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
mov    %r15,%rdi
call   10c0 <load_msgcat@plt>
jmp    122a <catopen+0x7a>

LLVM IR (-O0):
%struct.stat = type { i32 }
@PATH_MAX = global i32 0
@EINVAL = global i32 0
@errno = global i32 0
@NL_CAT_LOCALE = global i32 0
@LC_MESSAGES = global i32 0
@.str = [5 x i8] c"LANG\00"
@.str.1 = [2 x i8] c"C\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [8 x i8] c"NLSPATH\00"
@.str.4 = [104 x i8] c"/usr/share/nls/%L/%N.cat:/usr/share/nls/%N/%L:/usr/local/share/nls/%L/%N.cat:/usr/local/share/nls/%N/%L\00"
@.str.5 = [2 x i8] c":\00"
@ENAMETOOLONG = global i32 0
@ENOENT = global i32 0
define i32 @catopen(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca %struct.stat
%21 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%22 = load i32, i32* @PATH_MAX
%23 = zext i32 %22 to i64
%24 = call i8* @llvm.stacksave()
store i8* %24, i8** %8
%25 = alloca i8, i64 %23
store i64 %23, i64* %9
%26 = load i8*, i8** %4
%27 = icmp eq i8* %26, null
br i1 %27, label %33, label %28
28: ; preds = %2
%29 = load i8*, i8** %4
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %28, %2
%34 = load i32, i32* @EINVAL
store i32 %34, i32* @errno
store i32 -1, i32* %3
store i32 1, i32* %21
br label %253
35: ; preds = %28
%36 = load i8*, i8** %4
%37 = call i8* @strchr(i8* %36, i8 signext 47)
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %42
39: ; preds = %35
%40 = load i8*, i8** %4
%41 = call i32 @load_msgcat(i8* %40)
store i32 %41, i32* %3
store i32 1, i32* %21
br label %253
42: ; preds = %35
%43 = load i32, i32* %5
%44 = load i32, i32* @NL_CAT_LOCALE
%45 = icmp eq i32 %43, %44
br i1 %45, label %46, label %49
46: ; preds = %42
%47 = load i32, i32* @LC_MESSAGES
%48 = call i8* @setlocale(i32 %47, i32* null)
store i8* %48, i8** %11
br label %51
49: ; preds = %42
%50 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %50, i8** %11
br label %51
51: ; preds = %49, %46
%52 = load i8*, i8** %11
%53 = icmp eq i8* %52, null
br i1 %53, label %91, label %54
54: ; preds = %51
%55 = load i8*, i8** %11
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 0
br i1 %58, label %91, label %59
59: ; preds = %54
%60 = load i8*, i8** %11
%61 = call i32 @strlen(i8* %60)
%62 = icmp sgt i32 %61, 31
br i1 %62, label %91, label %63
63: ; preds = %59
%64 = load i8*, i8** %11
%65 = getelementptr inbounds i8, i8* %64, i64 0
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %67, 46
br i1 %68, label %69, label %87
69: ; preds = %63
%70 = load i8*, i8** %11
%71 = getelementptr inbounds i8, i8* %70, i64 1
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp eq i32 %73, 0
br i1 %74, label %91, label %75
75: ; preds = %69
%76 = load i8*, i8** %11
%77 = getelementptr inbounds i8, i8* %76, i64 1
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = icmp eq i32 %79, 46
br i1 %80, label %81, label %87
81: ; preds = %75
%82 = load i8*, i8** %11
%83 = getelementptr inbounds i8, i8* %82, i64 2
%84 = load i8, i8* %83
%85 = sext i8 %84 to i32
%86 = icmp eq i32 %85, 0
br i1 %86, label %91, label %87
87: ; preds = %81, %75, %63
%88 = load i8*, i8** %11
%89 = call i8* @strchr(i8* %88, i8 signext 47)
%90 = icmp ne i8* %89, null
br i1 %90, label %91, label %92
91: ; preds = %87, %81, %69, %59, %54, %51
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %11
br label %92
92: ; preds = %91, %87
%93 = load i8*, i8** %11
%94 = call i8* @strdup(i8* %93)
store i8* %94, i8** %16
store i8* %94, i8** %17
%95 = icmp eq i8* %94, null
br i1 %95, label %96, label %97
96: ; preds = %92
store i32 -1, i32* %3
store i32 1, i32* %21
br label %253
97: ; preds = %92
%98 = load i8*, i8** %16
%99 = call i8* @strchr(i8* %98, i8 signext 64)
store i8* %99, i8** %13
%100 = icmp ne i8* %99, null
br i1 %100, label %101, label %103
101: ; preds = %97
%102 = load i8*, i8** %13
store i8 0, i8* %102
br label %103
103: ; preds = %101, %97
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %19
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %18
%104 = load i8*, i8** %16
%105 = call i8* @strchr(i8* %104, i8 signext 95)
store i8* %105, i8** %13
%106 = icmp ne i8* %105, null
br i1 %106, label %107, label %111
107: ; preds = %103
%108 = load i8*, i8** %13
%109 = getelementptr inbounds i8, i8* %108, i32 1
store i8* %109, i8** %13
store i8 0, i8* %108
%110 = load i8*, i8** %13
store i8* %110, i8** %16
store i8* %110, i8** %18
br label %111
111: ; preds = %107, %103
%112 = load i8*, i8** %16
%113 = call i8* @strchr(i8* %112, i8 signext 46)
store i8* %113, i8** %13
%114 = icmp ne i8* %113, null
br i1 %114, label %115, label %119
115: ; preds = %111
%116 = load i8*, i8** %13
%117 = getelementptr inbounds i8, i8* %116, i32 1
store i8* %117, i8** %13
store i8 0, i8* %116
%118 = load i8*, i8** %13
store i8* %118, i8** %19
br label %119
119: ; preds = %115, %111
%120 = call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
store i8* %120, i8** %10
%121 = icmp eq i8* %120, null
br i1 %121, label %125, label %122
122: ; preds = %119
%123 = call i64 (...) @issetugid()
%124 = icmp ne i64 %123, 0
br i1 %124, label %125, label %126
125: ; preds = %122, %119
store i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str.4, i64 0, i64 0), i8** %10
br label %126
126: ; preds = %125, %122
%127 = load i8*, i8** %10
%128 = call i8* @strdup(i8* %127)
store i8* %128, i8** %13
store i8* %128, i8** %12
%129 = icmp eq i8* %128, null
br i1 %129, label %130, label %135
130: ; preds = %126
%131 = load i32, i32* @errno
store i32 %131, i32* %7
%132 = load i8*, i8** %17
%133 = call i32 @free(i8* %132)
%134 = load i32, i32* %7
store i32 %134, i32* @errno
store i32 -1, i32* %3
store i32 1, i32* %21
br label %253
135: ; preds = %126
br label %136
136: ; preds = %246, %135
%137 = call i8* @strsep(i8** %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i8* %137, i8** %10
%138 = icmp ne i8* %137, null
br i1 %138, label %139, label %247
139: ; preds = %136
store i8* %25, i8** %14
%140 = load i8*, i8** %10
%141 = load i8, i8* %140
%142 = icmp ne i8 %141, 0
br i1 %142, label %143, label %242
143: ; preds = %139
br label %144
144: ; preds = %228, %143
%145 = load i8*, i8** %10
%146 = load i8, i8* %145
%147 = icmp ne i8 %146, 0
br i1 %147, label %148, label %231
148: ; preds = %144
%149 = load i8*, i8** %10
%150 = load i8, i8* %149
%151 = sext i8 %150 to i32
%152 = icmp eq i32 %151, 37
br i1 %152, label %153, label %214
153: ; preds = %148
%154 = load i8*, i8** %10
%155 = getelementptr inbounds i8, i8* %154, i64 1
%156 = load i8, i8* %155
%157 = sext i8 %156 to i32
switch i32 %157, label %171 [
i32 108, label %158
i32 116, label %160
i32 99, label %162
i32 76, label %164
i32 78, label %166
i32 37, label %168
]
158: ; preds = %153
%159 = load i8*, i8** %17
store i8* %159, i8** %15
br label %184
160: ; preds = %153
%161 = load i8*, i8** %18
store i8* %161, i8** %15
br label %184
162: ; preds = %153
%163 = load i8*, i8** %19
store i8* %163, i8** %15
br label %184
164: ; preds = %153
%165 = load i8*, i8** %11
store i8* %165, i8** %15
br label %184
166: ; preds = %153
%167 = load i8*, i8** %4
store i8* %167, i8** %15
br label %184
168: ; preds = %153
%169 = load i8*, i8** %10
%170 = getelementptr inbounds i8, i8* %169, i32 1
store i8* %170, i8** %10
br label %171
171: ; preds = %153, %168
%172 = load i8*, i8** %14
%173 = ptrtoint i8* %172 to i64
%174 = ptrtoint i8* %25 to i64
%175 = sub i64 %173, %174
%176 = sub i64 %23, 1
%177 = icmp uge i64 %175, %176
br i1 %177, label %178, label %179
178: ; preds = %171
br label %202
179: ; preds = %171
%180 = load i8*, i8** %10
%181 = load i8, i8* %180
%182 = load i8*, i8** %14
%183 = getelementptr inbounds i8, i8* %182, i32 1
store i8* %183, i8** %14
store i8 %181, i8* %182
br label %228
184: ; preds = %166, %164, %162, %160, %158
%185 = load i8*, i8** %10
%186 = getelementptr inbounds i8, i8* %185, i32 1
store i8* %186, i8** %10
br label %187
187: ; preds = %242, %184
%188 = load i8*, i8** %14
%189 = ptrtoint i8* %188 to i64
%190 = ptrtoint i8* %25 to i64
%191 = sub i64 %189, %190
%192 = sub i64 %23, %191
%193 = sub i64 %192, 1
%194 = trunc i64 %193 to i32
store i32 %194, i32* %6
%195 = load i8*, i8** %14
%196 = load i8*, i8** %15
%197 = load i32, i32* %6
%198 = call i32 @strlcpy(i8* %195, i8* %196, i32 %197)
%199 = load i32, i32* %6
%200 = icmp sge i32 %198, %199
br i1 %200, label %201, label %208
201: ; preds = %187
br label %202
202: ; preds = %221, %201, %178
%203 = load i8*, i8** %17
%204 = call i32 @free(i8* %203)
%205 = load i8*, i8** %12
%206 = call i32 @free(i8* %205)
%207 = load i32, i32* @ENAMETOOLONG
store i32 %207, i32* @errno
store i32 -1, i32* %3
store i32 1, i32* %21
br label %253
208: ; preds = %187
%209 = load i8*, i8** %15
%210 = call i32 @strlen(i8* %209)
%211 = load i8*, i8** %14
%212 = sext i32 %210 to i64
%213 = getelementptr inbounds i8, i8* %211, i64 %212
store i8* %213, i8** %14
br label %227
214: ; preds = %148
%215 = load i8*, i8** %14
%216 = ptrtoint i8* %215 to i64
%217 = ptrtoint i8* %25 to i64
%218 = sub i64 %216, %217
%219 = sub i64 %23, 1
%220 = icmp uge i64 %218, %219
br i1 %220, label %221, label %222
221: ; preds = %214
br label %202
222: ; preds = %214
%223 = load i8*, i8** %10
%224 = load i8, i8* %223
%225 = load i8*, i8** %14
%226 = getelementptr inbounds i8, i8* %225, i32 1
store i8* %226, i8** %14
store i8 %224, i8* %225
br label %227
227: ; preds = %222, %208
br label %228
228: ; preds = %227, %179
%229 = load i8*, i8** %10
%230 = getelementptr inbounds i8, i8* %229, i32 1
store i8* %230, i8** %10
br label %144
231: ; preds = %144
%232 = load i8*, i8** %14
store i8 0, i8* %232
%233 = call i64 @stat(i8* %25, %struct.stat* %20)
%234 = icmp eq i64 %233, 0
br i1 %234, label %235, label %241
235: ; preds = %231
%236 = load i8*, i8** %17
%237 = call i32 @free(i8* %236)
%238 = load i8*, i8** %12
%239 = call i32 @free(i8* %238)
%240 = call i32 @load_msgcat(i8* %25)
store i32 %240, i32* %3
store i32 1, i32* %21
br label %253
241: ; preds = %231
br label %246
242: ; preds = %139
%243 = load i8*, i8** %4
store i8* %243, i8** %15
%244 = load i8*, i8** %10
%245 = getelementptr inbounds i8, i8* %244, i32 -1
store i8* %245, i8** %10
br label %187
246: ; preds = %241
br label %136
247: ; preds = %136
%248 = load i8*, i8** %17
%249 = call i32 @free(i8* %248)
%250 = load i8*, i8** %12
%251 = call i32 @free(i8* %250)
%252 = load i32, i32* @ENOENT
store i32 %252, i32* @errno
store i32 -1, i32* %3
store i32 1, i32* %21
br label %253
253: ; preds = %247, %235, %202, %130, %96, %39, %33
%254 = load i8*, i8** %8
%255 = load i32, i32* %3
ret i32 %255
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@PATH_MAX = global i32 0
@EINVAL = global i32 0
@errno = global i32 0
@NL_CAT_LOCALE = global i32 0
@LC_MESSAGES = global i32 0
@.str = [5 x i8] c"LANG\00"
@.str.1 = [2 x i8] c"C\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [8 x i8] c"NLSPATH\00"
@.str.4 = [104 x i8] c"/usr/share/nls/%L/%N.cat:/usr/share/nls/%N/%L:/usr/local/share/nls/%L/%N.cat:/usr/local/share/nls/%N/%L\00"
@.str.5 = [2 x i8] c":\00"
@ENAMETOOLONG = global i32 0
@ENOENT = global i32 0
define i32 @catopen(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca %struct.stat
%5 = load i32, i32* @PATH_MAX
%6 = zext i32 %5 to i64
%7 = alloca i8, i64 %6
%8 = bitcast i8** %3 to i8*
%9 = bitcast %struct.stat* %4 to i8*
%10 = icmp eq i8* %0, null
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load i8, i8* %0
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11, %2
%15 = load i32, i32* @EINVAL
store i32 %15, i32* @errno
br label %161
16: ; preds = %11
%17 = tail call i8* @strchr(i8* %0, i8 signext 47)
%18 = icmp eq i8* %17, null
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = tail call i32 @load_msgcat(i8* %0)
br label %161
21: ; preds = %16
%22 = load i32, i32* @NL_CAT_LOCALE
%23 = icmp eq i32 %22, %1
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i32, i32* @LC_MESSAGES
%26 = tail call i8* @setlocale(i32 %25, i32* null)
br label %29
27: ; preds = %21
%28 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %29
29: ; preds = %27, %24
%30 = phi i8* [ %26, %24 ], [ %28, %27 ]
%31 = icmp eq i8* %30, null
br i1 %31, label %51, label %32
32: ; preds = %29
%33 = load i8, i8* %30
%34 = icmp eq i8 %33, 0
br i1 %34, label %51, label %35
35: ; preds = %32
%36 = tail call i32 @strlen(i8* %30)
%37 = icmp sgt i32 %36, 31
br i1 %37, label %51, label %38
38: ; preds = %35
%39 = load i8, i8* %30
%40 = icmp eq i8 %39, 46
br i1 %40, label %41, label %48
41: ; preds = %38
%42 = getelementptr inbounds i8, i8* %30, i64 1
%43 = load i8, i8* %42
switch i8 %43, label %48 [
i8 0, label %51
i8 46, label %44
]
44: ; preds = %41
%45 = getelementptr inbounds i8, i8* %30, i64 2
%46 = load i8, i8* %45
%47 = icmp eq i8 %46, 0
br i1 %47, label %51, label %48
48: ; preds = %41, %44, %38
%49 = tail call i8* @strchr(i8* %30, i8 signext 47)
%50 = icmp eq i8* %49, null
br i1 %50, label %52, label %51
51: ; preds = %41, %48, %44, %35, %32, %29
br label %52
52: ; preds = %51, %48
%53 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %51 ], [ %30, %48 ]
%54 = tail call i8* @strdup(i8* %53)
%55 = icmp eq i8* %54, null
br i1 %55, label %161, label %56
56: ; preds = %52
%57 = tail call i8* @strchr(i8* %54, i8 signext 64)
%58 = icmp eq i8* %57, null
br i1 %58, label %60, label %59
59: ; preds = %56
store i8 0, i8* %57
br label %60
60: ; preds = %59, %56
%61 = tail call i8* @strchr(i8* %54, i8 signext 95)
%62 = icmp eq i8* %61, null
br i1 %62, label %66, label %63
63: ; preds = %60
%64 = getelementptr inbounds i8, i8* %61, i64 1
store i8* %64, i8** %3
store i8 0, i8* %61
%65 = load i8*, i8** %3
br label %66
66: ; preds = %63, %60
%67 = phi i8* [ %65, %63 ], [ %54, %60 ]
%68 = phi i8* [ %65, %63 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %60 ]
%69 = tail call i8* @strchr(i8* dereferenceable(1) %67, i8 signext 46)
%70 = icmp eq i8* %69, null
br i1 %70, label %74, label %71
71: ; preds = %66
%72 = getelementptr inbounds i8, i8* %69, i64 1
store i8* %72, i8** %3
store i8 0, i8* %69
%73 = load i8*, i8** %3
br label %74
74: ; preds = %71, %66
%75 = phi i8* [ %73, %71 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %66 ]
%76 = tail call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%77 = icmp eq i8* %76, null
br i1 %77, label %81, label %78
78: ; preds = %74
%79 = tail call i64 (...) @issetugid()
%80 = icmp eq i64 %79, 0
br i1 %80, label %82, label %81
81: ; preds = %78, %74
br label %82
82: ; preds = %81, %78
%83 = phi i8* [ getelementptr inbounds ([104 x i8], [104 x i8]* @.str.4, i64 0, i64 0), %81 ], [ %76, %78 ]
%84 = tail call i8* @strdup(i8* %83)
store i8* %84, i8** %3
%85 = icmp eq i8* %84, null
br i1 %85, label %90, label %86
86: ; preds = %82
%87 = ptrtoint i8* %7 to i64
%88 = add i32 %5, -1
%89 = add nsw i64 %6, -1
br label %92
90: ; preds = %82
%91 = tail call i32 @free(i8* %54)
br label %161
92: ; preds = %86, %148
%93 = call i8* @strsep(i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%94 = icmp eq i8* %93, null
br i1 %94, label %157, label %95
95: ; preds = %92
%96 = load i8, i8* %93
%97 = icmp eq i8 %96, 0
br i1 %97, label %155, label %98
98: ; preds = %95, %143
%99 = phi i8 [ %96, %95 ], [ %147, %143 ]
%100 = phi i8* [ %93, %95 ], [ %146, %143 ]
%101 = phi i8* [ %7, %95 ], [ %145, %143 ]
switch i8 %99, label %137 [
i8 0, label %148
i8 37, label %102
]
102: ; preds = %98
%103 = getelementptr inbounds i8, i8* %100, i64 1
%104 = load i8, i8* %103
%105 = sext i8 %104 to i32
switch i32 %105, label %111 [
i32 108, label %119
i32 116, label %106
i32 99, label %107
i32 76, label %108
i32 78, label %109
i32 37, label %110
]
106: ; preds = %102
br label %119
107: ; preds = %102
br label %119
108: ; preds = %102
br label %119
109: ; preds = %102
br label %119
110: ; preds = %102
br label %111
111: ; preds = %102, %110
%112 = phi i8* [ %100, %102 ], [ %103, %110 ]
%113 = ptrtoint i8* %101 to i64
%114 = sub i64 %113, %87
%115 = icmp ult i64 %114, %89
br i1 %115, label %116, label %129
116: ; preds = %111
%117 = load i8, i8* %112
%118 = getelementptr inbounds i8, i8* %101, i64 1
store i8 %117, i8* %101
br label %143
119: ; preds = %106, %107, %108, %109, %102, %155
%120 = phi i8* [ %156, %155 ], [ %103, %102 ], [ %103, %109 ], [ %103, %108 ], [ %103, %107 ], [ %103, %106 ]
%121 = phi i8* [ %7, %155 ], [ %101, %102 ], [ %101, %109 ], [ %101, %108 ], [ %101, %107 ], [ %101, %106 ]
%122 = phi i8* [ %0, %155 ], [ %54, %102 ], [ %0, %109 ], [ %53, %108 ], [ %75, %107 ], [ %68, %106 ]
%123 = ptrtoint i8* %121 to i64
%124 = sub i64 %87, %123
%125 = trunc i64 %124 to i32
%126 = add i32 %88, %125
%127 = call i32 @strlcpy(i8* %121, i8* %122, i32 %126)
%128 = icmp slt i32 %127, %126
br i1 %128, label %133, label %129
129: ; preds = %137, %119, %111
%130 = call i32 @free(i8* %54)
%131 = call i32 @free(i8* %84)
%132 = load i32, i32* @ENAMETOOLONG
store i32 %132, i32* @errno
br label %161
133: ; preds = %119
%134 = call i32 @strlen(i8* %122)
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds i8, i8* %121, i64 %135
br label %143
137: ; preds = %98
%138 = ptrtoint i8* %101 to i64
%139 = sub i64 %138, %87
%140 = icmp ult i64 %139, %89
br i1 %140, label %141, label %129
141: ; preds = %137
%142 = getelementptr inbounds i8, i8* %101, i64 1
store i8 %99, i8* %101
br label %143
143: ; preds = %133, %141, %116
%144 = phi i8* [ %112, %116 ], [ %120, %133 ], [ %100, %141 ]
%145 = phi i8* [ %118, %116 ], [ %136, %133 ], [ %142, %141 ]
%146 = getelementptr inbounds i8, i8* %144, i64 1
%147 = load i8, i8* %146
br label %98
148: ; preds = %98
store i8 0, i8* %101
%149 = call i64 @stat(i8* %7, %struct.stat* %4)
%150 = icmp eq i64 %149, 0
br i1 %150, label %151, label %92
151: ; preds = %148
%152 = call i32 @free(i8* %54)
%153 = call i32 @free(i8* %84)
%154 = call i32 @load_msgcat(i8* %7)
br label %161
155: ; preds = %95
%156 = getelementptr inbounds i8, i8* %93, i64 -1
br label %119
157: ; preds = %92
%158 = call i32 @free(i8* %54)
%159 = call i32 @free(i8* %84)
%160 = load i32, i32* @ENOENT
store i32 %160, i32* @errno
br label %161
161: ; preds = %52, %157, %151, %129, %90, %19, %14
%162 = phi i32 [ -1, %14 ], [ %20, %19 ], [ -1, %90 ], [ -1, %129 ], [ %154, %151 ], [ -1, %157 ], [ -1, %52 ]
ret i32 %162
}