#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;
};
struct dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int PATH_MAX;
int atoi(char *);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
scalar_t__ getenv(char *);
char *malloc(int);
int /*<<< orphan*/ *opendir(char const *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ snprintf(char *, size_t, char *, char const *, ...);
int sscanf(char *, char *, int *, int *);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *strchr(char *, char);
char *strdup(char const *);
char *strerror(int /*<<< orphan*/);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, size_t);
char *getPythonLibName(const char *pythonLibDir, char *pyVersionArg) {
  char *libName = NULL;
  if (pyVersionArg != NULL) {
    if (strchr(pyVersionArg, '.') != NULL) {
      size_t libNameLen = strlen("libpython.so") + strlen(&pyVersionArg[1]) + 1;
      libName = malloc(sizeof(char) * libNameLen);
      snprintf(libName, libNameLen, "libpython%s.so", &pyVersionArg[1]);
      char libFilePath[PATH_MAX];
      snprintf(libFilePath, PATH_MAX, "%s/%s", pythonLibDir, libName);
      struct stat statBuffer;
      if (stat(libFilePath, &statBuffer) != 0) {
        fprintf(
            stderr,
            "fatal: "
            "Failed to find a python version matching command line argument %s"
            "\n",
            pyVersionArg);
        free(libName);
        libName = NULL;
      }
    } else {
      char fileNameStart[32];
      size_t fileNameStartLen = 32;
      size_t libNameLen = 0, nameLen = 0;
      int minorVersion, maxMinorVersion = 0;
      snprintf(fileNameStart, fileNameStartLen, "libpython%s.",
               &pyVersionArg[1]);
      fileNameStartLen = strlen(fileNameStart);
      DIR *pyLibDir = opendir(pythonLibDir);
      struct dirent *entry;
      if (pyLibDir != NULL) {
        while ((entry = readdir(pyLibDir)) != NULL) {
          if (strncmp(entry->d_name, fileNameStart, fileNameStartLen) == 0) {
            minorVersion = atoi(&entry->d_name[strlen("libpython.") +
                                               strlen(&pyVersionArg[1])]);
            if (minorVersion > maxMinorVersion) {
              maxMinorVersion = minorVersion;
              nameLen = strlen(entry->d_name) + 1;
              if (nameLen > libNameLen) {
                if (libName != NULL)
                  free(libName);
                libName = malloc(sizeof(char) * nameLen);
                libNameLen = nameLen;
              }
              strncpy(libName, entry->d_name, libNameLen);
            }
          }
        }
        closedir(pyLibDir);
        if (libName == NULL) {
          fprintf(stderr,
                  "fatal: "
                  "Failed to find a python version matching command line "
                  "argument %s"
                  "\n",
                  pyVersionArg);
        }
      } else {
        fprintf(stderr,
                "fatal: "
                "Failed to open the Python library directory (%s): %s"
                "\n",
                pythonLibDir, strerror(errno));
      }
    }
    return libName;
  }
  const char *envLibName = (const char *)getenv("PYTHON_LIBRARY_NAME");
  if (envLibName != NULL) {
    libName = strdup(envLibName);
    if (libName != NULL) {
      return libName;
    }
    fprintf(stderr, "fatal: "
                    "Failed to copy the Python library name from the "
                    "environment: Out of memory!"
                    "\n");
  }
  size_t libNameLen = 0, nameLen = 0;
  int majorVersion, maxMajorVersion = 0;
  int minorVersion, maxMinorVersion = 0;
  DIR *pyLibDir = opendir(pythonLibDir);
  struct dirent *entry;
  if (pyLibDir != NULL) {
    while ((entry = readdir(pyLibDir)) != NULL) {
      if (strncmp(entry->d_name, "libpython", strlen("libpython")) == 0) {
        if (sscanf(entry->d_name, "libpython%d.%d.so", &majorVersion,
                   &minorVersion) != 2)
          continue;
        if (majorVersion > maxMajorVersion ||
            (majorVersion == maxMajorVersion &&
             minorVersion > maxMinorVersion)) {
          maxMajorVersion = majorVersion;
          maxMinorVersion = minorVersion;
          nameLen = strlen(entry->d_name) + 1;
          if (nameLen > libNameLen) {
            if (libName != NULL)
              free(libName);
            libName = malloc(sizeof(char) * nameLen);
            libNameLen = nameLen;
          }
          strncpy(libName, entry->d_name, libNameLen);
        }
      }
    }
    closedir(pyLibDir);
  } else {
    fprintf(stderr,
            "fatal: "
            "Failed to open the Python library directory (%s): %s"
            "\n",
            pythonLibDir, strerror(errno));
    return NULL;
  }
  if (libName == NULL) {
    fprintf(stderr, "fatal: "
                    "Failed to find any installed python version!"
                    "\n");
  }
  return libName;
}


x86 assembly (clang, -O0):
<getPythonLibName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1562 <getPythonLibName+0x352>
mov    -0x18(%rbp),%rdi
mov    $0x2e,%esi
call   1090 <strchr@plt>
cmp    $0x0,%rax
je     134e <getPythonLibName+0x13e>
lea    0xdab(%rip),%rdi
call   1080 <strlen@plt>
mov    %eax,-0xd4(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
call   1080 <strlen@plt>
mov    -0xd4(%rbp),%ecx
mov    %eax,%edx
mov    %ecx,%eax
mov    %edx,%ecx
lea    0x1(%rax,%rcx,1),%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%edi
call   10f0 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%rcx
add    $0x1,%rcx
lea    0xd67(%rip),%rdx
xor    %eax,%eax
call   10a0 <snprintf@plt>
mov    0x2d3c(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0xd0(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x38(%rbp)
mov    0x2d0d(%rip),%rax
movslq (%rax),%rsi
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xd27(%rip),%rdx
mov    $0x0,%al
call   10a0 <snprintf@plt>
mov    -0xd0(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   10d0 <stat@plt>
cmp    $0x0,%rax
je     1342 <getPythonLibName+0x132>
mov    0x2cbb(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xcf8(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
jmp    1555 <getPythonLibName+0x345>
movq   $0x20,-0x68(%rbp)
movq   $0x0,-0x70(%rbp)
movq   $0x0,-0x78(%rbp)
movl   $0x0,-0x80(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    -0x18(%rbp),%rcx
add    $0x1,%rcx
lea    0xce8(%rip),%rdx
mov    $0x0,%al
call   10a0 <snprintf@plt>
lea    -0x60(%rbp),%rdi
call   1080 <strlen@plt>
cltq
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <opendir@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     150a <getPythonLibName+0x2fa>
jmp    13bd <getPythonLibName+0x1ad>
mov    -0x88(%rbp),%rdi
call   10e0 <readdir@plt>
mov    %rax,-0x90(%rbp)
cmp    $0x0,%rax
je     14d3 <getPythonLibName+0x2c3>
mov    -0x90(%rbp),%rax
mov    (%rax),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x68(%rbp),%rax
mov    %eax,%edx
call   1060 <strncmp@plt>
cmp    $0x0,%rax
jne    14ce <getPythonLibName+0x2be>
mov    -0x90(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0xe0(%rbp)
lea    0xc64(%rip),%rdi
call   1080 <strlen@plt>
mov    %eax,-0xd8(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
call   1080 <strlen@plt>
mov    -0xe0(%rbp),%rdi
mov    %eax,%ecx
mov    -0xd8(%rbp),%eax
add    %ecx,%eax
cltq
add    %rax,%rdi
call   1110 <atoi@plt>
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
cmp    -0x80(%rbp),%eax
jle    14c9 <getPythonLibName+0x2b9>
mov    -0x7c(%rbp),%eax
mov    %eax,-0x80(%rbp)
mov    -0x90(%rbp),%rax
mov    (%rax),%rdi
call   1080 <strlen@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
cmp    -0x70(%rbp),%rax
jbe    14b2 <getPythonLibName+0x2a2>
cmpq   $0x0,-0x20(%rbp)
je     1497 <getPythonLibName+0x287>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
mov    -0x78(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10f0 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x90(%rbp),%rax
mov    (%rax),%rsi
mov    -0x70(%rbp),%rdx
call   1050 <strncpy@plt>
jmp    14ce <getPythonLibName+0x2be>
jmp    13bd <getPythonLibName+0x1ad>
mov    -0x88(%rbp),%rdi
call   10b0 <closedir@plt>
cmpq   $0x0,-0x20(%rbp)
jne    1505 <getPythonLibName+0x2f5>
mov    0x2ae7(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xb24(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
jmp    1550 <getPythonLibName+0x340>
mov    0x2ac7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xec(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0xe8(%rbp)
mov    0x2aa5(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0xec(%rbp),%edi
mov    -0xe8(%rbp),%rdx
mov    %rax,%rcx
lea    0xb3b(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
jmp    1555 <getPythonLibName+0x345>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1801 <getPythonLibName+0x5f1>
lea    0xb58(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
je     15c2 <getPythonLibName+0x3b2>
mov    -0x98(%rbp),%rdi
call   1120 <strdup@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     15ab <getPythonLibName+0x39b>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1801 <getPythonLibName+0x5f1>
mov    0x2a26(%rip),%rax
mov    (%rax),%edi
lea    0xb1a(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
movq   $0x0,-0xa0(%rbp)
movq   $0x0,-0xa8(%rbp)
movl   $0x0,-0xb0(%rbp)
movl   $0x0,-0xb8(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <opendir@plt>
mov    %rax,-0xc0(%rbp)
cmpq   $0x0,-0xc0(%rbp)
je     1784 <getPythonLibName+0x574>
jmp    160f <getPythonLibName+0x3ff>
mov    -0xc0(%rbp),%rdi
call   10e0 <readdir@plt>
mov    %rax,-0xc8(%rbp)
cmp    $0x0,%rax
je     1773 <getPythonLibName+0x563>
mov    -0xc8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0xf8(%rbp)
lea    0xae5(%rip),%rdi
call   1080 <strlen@plt>
mov    -0xf8(%rbp),%rdi
mov    %eax,%edx
lea    0xad0(%rip),%rsi
call   1060 <strncmp@plt>
cmp    $0x0,%rax
jne    176e <getPythonLibName+0x55e>
mov    -0xc8(%rbp),%rax
mov    (%rax),%rdi
lea    0xaba(%rip),%rsi
lea    -0xac(%rbp),%rdx
lea    -0xb4(%rbp),%rcx
call   1100 <sscanf@plt>
cmp    $0x2,%eax
je     169a <getPythonLibName+0x48a>
jmp    160f <getPythonLibName+0x3ff>
mov    -0xac(%rbp),%eax
cmp    -0xb0(%rbp),%eax
jg     16d0 <getPythonLibName+0x4c0>
mov    -0xac(%rbp),%eax
cmp    -0xb0(%rbp),%eax
jne    1769 <getPythonLibName+0x559>
mov    -0xb4(%rbp),%eax
cmp    -0xb8(%rbp),%eax
jle    1769 <getPythonLibName+0x559>
mov    -0xac(%rbp),%eax
mov    %eax,-0xb0(%rbp)
mov    -0xb4(%rbp),%eax
mov    %eax,-0xb8(%rbp)
mov    -0xc8(%rbp),%rax
mov    (%rax),%rdi
call   1080 <strlen@plt>
add    $0x1,%eax
cltq
mov    %rax,-0xa8(%rbp)
mov    -0xa8(%rbp),%rax
cmp    -0xa0(%rbp),%rax
jbe    174f <getPythonLibName+0x53f>
cmpq   $0x0,-0x20(%rbp)
je     172b <getPythonLibName+0x51b>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
mov    -0xa8(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10f0 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0xa8(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0xc8(%rbp),%rax
mov    (%rax),%rsi
mov    -0xa0(%rbp),%rdx
call   1050 <strncpy@plt>
jmp    176e <getPythonLibName+0x55e>
jmp    160f <getPythonLibName+0x3ff>
mov    -0xc0(%rbp),%rdi
call   10b0 <closedir@plt>
jmp    17d7 <getPythonLibName+0x5c7>
mov    0x284d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x104(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x100(%rbp)
mov    0x282b(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x104(%rbp),%edi
mov    -0x100(%rbp),%rdx
mov    %rax,%rcx
lea    0x8c1(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1801 <getPythonLibName+0x5f1>
cmpq   $0x0,-0x20(%rbp)
jne    17f9 <getPythonLibName+0x5e9>
mov    0x27ef(%rip),%rax
mov    (%rax),%edi
lea    0x953(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getPythonLibName>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rdi,%r15
test   %rsi,%rsi
je     1306 <getPythonLibName+0xf6>
mov    %rsi,%rbx
mov    %rsi,%rdi
mov    $0x2e,%esi
call   1090 <strchr@plt>
test   %rax,%rax
je     144c <getPythonLibName+0x23c>
lea    0xdb3(%rip),%rdi
call   1080 <strlen@plt>
mov    %eax,%r14d
lea    0x1(%rbx),%r12
mov    %r12,%rdi
call   1080 <strlen@plt>
add    %r14d,%eax
add    $0x1,%eax
movslq %eax,%r14
mov    %r14d,%edi
call   10f0 <malloc@plt>
mov    %rbx,-0x58(%rbp)
mov    %rax,%r13
lea    0xd8d(%rip),%rdx
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r12,%rcx
xor    %eax,%eax
call   10a0 <snprintf@plt>
mov    %rsp,%r14
mov    0x2d56(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rbx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rbx
mov    %rbx,%rsp
movslq (%rax),%rsi
lea    0xd65(%rip),%rdx
mov    %rbx,%rdi
mov    %r15,%rcx
mov    %r13,%r8
xor    %eax,%eax
call   10a0 <snprintf@plt>
lea    -0x80(%rbp),%rsi
mov    %rbx,%rdi
call   10d0 <stat@plt>
test   %rax,%rax
je     12fe <getPythonLibName+0xee>
mov    0x2cf9(%rip),%rax
mov    (%rax),%edi
lea    0xd3a(%rip),%rsi
mov    -0x58(%rbp),%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    %r13,%rdi
call   1040 <free@plt>
xor    %r13d,%r13d
mov    %r14,%rsp
jmp    1619 <getPythonLibName+0x409>
lea    0xdb4(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1342 <getPythonLibName+0x132>
mov    %rax,%rdi
call   1120 <strdup@plt>
mov    %rax,%r13
test   %rax,%rax
jne    1619 <getPythonLibName+0x409>
mov    0x2ca6(%rip),%rax
mov    (%rax),%edi
lea    0xd9a(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    %r15,%rdi
call   1070 <opendir@plt>
test   %rax,%rax
je     1581 <getPythonLibName+0x371>
mov    %rax,%rbx
xor    %eax,%eax
mov    %rax,-0x40(%rbp)
lea    0xdc6(%rip),%r14
lea    -0x4c(%rbp),%r13
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x48(%rbp)
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   10e0 <readdir@plt>
test   %rax,%rax
je     15b3 <getPythonLibName+0x3a3>
mov    %rax,%r15
mov    (%rax),%r12
mov    %r14,%rdi
call   1080 <strlen@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1060 <strncmp@plt>
test   %rax,%rax
jne    1380 <getPythonLibName+0x170>
mov    (%r15),%rdi
lea    0xd78(%rip),%rsi
lea    -0x80(%rbp),%rdx
mov    %r13,%rcx
call   1100 <sscanf@plt>
cmp    $0x2,%eax
jne    1380 <getPythonLibName+0x170>
mov    -0x80(%rbp),%r12d
cmp    -0x38(%rbp),%r12d
jg     13e2 <getPythonLibName+0x1d2>
jne    1380 <getPythonLibName+0x170>
mov    -0x4c(%rbp),%eax
cmp    -0x48(%rbp),%eax
jle    1380 <getPythonLibName+0x170>
jmp    13e5 <getPythonLibName+0x1d5>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    (%r15),%rdi
call   1080 <strlen@plt>
mov    %eax,%edx
add    $0x1,%edx
movslq %edx,%rcx
mov    -0x40(%rbp),%rax
cmp    %rcx,%rax
jae    1430 <getPythonLibName+0x220>
mov    %rcx,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
test   %rdi,%rdi
je     1419 <getPythonLibName+0x209>
mov    %edx,-0x30(%rbp)
call   1040 <free@plt>
mov    -0x30(%rbp),%edx
mov    %edx,%edi
call   10f0 <malloc@plt>
mov    %rax,%rdi
mov    -0x38(%rbp),%rdx
mov    %rdx,%rax
mov    %rdx,-0x40(%rbp)
jmp    1437 <getPythonLibName+0x227>
mov    %rax,%rdx
mov    -0x30(%rbp),%rdi
mov    (%r15),%rsi
mov    %rdi,-0x30(%rbp)
call   1050 <strncpy@plt>
mov    %r12d,-0x38(%rbp)
jmp    1380 <getPythonLibName+0x170>
lea    0x1(%rbx),%rcx
lea    0xc15(%rip),%rdx
lea    -0x80(%rbp),%r14
mov    $0x20,%esi
mov    %r14,%rdi
mov    %rcx,-0x38(%rbp)
xor    %eax,%eax
call   10a0 <snprintf@plt>
mov    %r14,%rdi
call   1080 <strlen@plt>
mov    %eax,%r14d
mov    %r15,%rdi
call   1070 <opendir@plt>
test   %rax,%rax
je     1581 <getPythonLibName+0x371>
mov    %rax,%r12
mov    %rbx,-0x58(%rbp)
mov    %rax,%rdi
call   10e0 <readdir@plt>
test   %rax,%rax
je     15f3 <getPythonLibName+0x3e3>
mov    %rax,%rbx
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
lea    -0x80(%rbp),%r15
xor    %eax,%eax
mov    %rax,-0x40(%rbp)
xor    %r13d,%r13d
mov    %r12,-0x48(%rbp)
jmp    14f6 <getPythonLibName+0x2e6>
mov    %rax,%r14
mov    -0x30(%rbp),%rdi
mov    (%rbx),%rsi
mov    %rdi,-0x30(%rbp)
mov    %r14,%rdx
call   1050 <strncpy@plt>
mov    %r15d,%r13d
mov    %r12d,%r14d
mov    -0x48(%rbp),%r12
lea    -0x80(%rbp),%r15
mov    %r12,%rdi
call   10e0 <readdir@plt>
mov    %rax,%rbx
test   %rax,%rax
je     15e0 <getPythonLibName+0x3d0>
mov    (%rbx),%rdi
mov    %r15,%rsi
mov    %r14d,%edx
call   1060 <strncmp@plt>
test   %rax,%rax
jne    14e2 <getPythonLibName+0x2d2>
mov    %r14d,%r12d
mov    (%rbx),%r15
lea    0xb63(%rip),%rdi
call   1080 <strlen@plt>
mov    %eax,%r14d
mov    -0x38(%rbp),%rdi
call   1080 <strlen@plt>
add    %r14d,%eax
movslq %eax,%rdi
add    %r15,%rdi
call   1110 <atoi@plt>
cmp    %r13d,%eax
jle    14d7 <getPythonLibName+0x2c7>
mov    %eax,%r15d
mov    (%rbx),%rdi
call   1080 <strlen@plt>
mov    %eax,%r13d
add    $0x1,%r13d
movslq %r13d,%r14
mov    -0x40(%rbp),%rax
cmp    %r14,%rax
jae    14be <getPythonLibName+0x2ae>
mov    -0x30(%rbp),%rdi
test   %rdi,%rdi
je     156a <getPythonLibName+0x35a>
call   1040 <free@plt>
mov    %r13d,%edi
call   10f0 <malloc@plt>
mov    %rax,%rdi
mov    %r14,%rax
mov    %r14,-0x40(%rbp)
jmp    14c5 <getPythonLibName+0x2b5>
mov    0x2a50(%rip),%rax
mov    (%rax),%ebx
mov    0x2a3f(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xae5(%rip),%rsi
xor    %r13d,%r13d
mov    %ebx,%edi
mov    %r15,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    1619 <getPythonLibName+0x409>
mov    %rbx,%rdi
call   10b0 <closedir@plt>
mov    -0x30(%rbp),%r13
test   %r13,%r13
jne    1619 <getPythonLibName+0x409>
mov    0x2a0d(%rip),%rax
mov    (%rax),%edi
lea    0xb71(%rip),%rsi
xor    %r13d,%r13d
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    1619 <getPythonLibName+0x409>
mov    %r12,%rdi
call   10b0 <closedir@plt>
mov    -0x30(%rbp),%r13
test   %r13,%r13
jne    1619 <getPythonLibName+0x409>
jmp    15fb <getPythonLibName+0x3eb>
mov    %r12,%rdi
call   10b0 <closedir@plt>
mov    0x29d6(%rip),%rax
mov    (%rax),%edi
lea    0xa17(%rip),%rsi
xor    %r13d,%r13d
mov    -0x58(%rbp),%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    %r13,%rax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
%struct.dirent = type { i8* }
@.str = [13 x i8] c"libpython.so\00"
@.str.1 = [15 x i8] c"libpython%s.so\00"
@PATH_MAX = global i32 0
@.str.2 = [6 x i8] c"%s/%s\00"
@stderr = global i32 0
@.str.3 = [74 x i8] c"fatal: Failed to find a python version matching command line argument %s\0A\00"
@.str.4 = [13 x i8] c"libpython%s.\00"
@.str.5 = [11 x i8] c"libpython.\00"
@.str.6 = [61 x i8] c"fatal: Failed to open the Python library directory (%s): %s\0A\00"
@errno = global i32 0
@.str.7 = [20 x i8] c"PYTHON_LIBRARY_NAME\00"
@.str.8 = [84 x i8] c"fatal: Failed to copy the Python library name from the environment: Out of memory!\0A\00"
@.str.9 = [10 x i8] c"libpython\00"
@.str.10 = [18 x i8] c"libpython%d.%d.so\00"
@.str.11 = [53 x i8] c"fatal: Failed to find any installed python version!\0A\00"
define i8* @getPythonLibName(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64
%10 = alloca %struct.stat
%11 = alloca [32 x i8]
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32*
%18 = alloca %struct.dirent*
%19 = alloca i8*
%20 = alloca i64
%21 = alloca i64
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32*
%27 = alloca %struct.dirent*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* null, i8** %6
%28 = load i8*, i8** %5
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %163
30: ; preds = %2
%31 = load i8*, i8** %5
%32 = call i32* @strchr(i8* %31, i8 signext 46)
%33 = icmp ne i32* %32, null
br i1 %33, label %34, label %70
34: ; preds = %30
%35 = call i32 @strlen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%36 = load i8*, i8** %5
%37 = getelementptr inbounds i8, i8* %36, i64 1
%38 = call i32 @strlen(i8* %37)
%39 = add nsw i32 %35, %38
%40 = add nsw i32 %39, 1
%41 = sext i32 %40 to i64
store i64 %41, i64* %7
%42 = load i64, i64* %7
%43 = mul i64 1, %42
%44 = trunc i64 %43 to i32
%45 = call i8* @malloc(i32 %44)
store i8* %45, i8** %6
%46 = load i8*, i8** %6
%47 = load i64, i64* %7
%48 = load i8*, i8** %5
%49 = getelementptr inbounds i8, i8* %48, i64 1
%50 = call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %46, i64 %47, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %49)
%51 = load i32, i32* @PATH_MAX
%52 = zext i32 %51 to i64
%53 = call i8* @llvm.stacksave()
store i8* %53, i8** %8
%54 = alloca i8, i64 %52
store i64 %52, i64* %9
%55 = load i32, i32* @PATH_MAX
%56 = sext i32 %55 to i64
%57 = load i8*, i8** %4
%58 = load i8*, i8** %6
%59 = call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %54, i64 %56, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %57, i8* %58)
%60 = call i64 @stat(i8* %54, %struct.stat* %10)
%61 = icmp ne i64 %60, 0
br i1 %61, label %62, label %68
62: ; preds = %34
%63 = load i32, i32* @stderr
%64 = load i8*, i8** %5
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.3, i64 0, i64 0), i8* %64)
%66 = load i8*, i8** %6
%67 = call i32 @free(i8* %66)
store i8* null, i8** %6
br label %68
68: ; preds = %62, %34
%69 = load i8*, i8** %8
br label %161
70: ; preds = %30
store i64 32, i64* %12
store i64 0, i64* %13
store i64 0, i64* %14
store i32 0, i32* %16
%71 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%72 = load i64, i64* %12
%73 = load i8*, i8** %5
%74 = getelementptr inbounds i8, i8* %73, i64 1
%75 = call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %71, i64 %72, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %74)
%76 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%77 = call i32 @strlen(i8* %76)
%78 = sext i32 %77 to i64
store i64 %78, i64* %12
%79 = load i8*, i8** %4
%80 = call i32* @opendir(i8* %79)
store i32* %80, i32** %17
%81 = load i32*, i32** %17
%82 = icmp ne i32* %81, null
br i1 %82, label %83, label %154
83: ; preds = %70
br label %84
84: ; preds = %143, %83
%85 = load i32*, i32** %17
%86 = call %struct.dirent* @readdir(i32* %85)
store %struct.dirent* %86, %struct.dirent** %18
%87 = icmp ne %struct.dirent* %86, null
br i1 %87, label %88, label %144
88: ; preds = %84
%89 = load %struct.dirent*, %struct.dirent** %18
%90 = getelementptr inbounds %struct.dirent, %struct.dirent* %89, i32 0, i32 0
%91 = load i8*, i8** %90
%92 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%93 = load i64, i64* %12
%94 = trunc i64 %93 to i32
%95 = call i64 @strncmp(i8* %91, i8* %92, i32 %94)
%96 = icmp eq i64 %95, 0
br i1 %96, label %97, label %143
97: ; preds = %88
%98 = load %struct.dirent*, %struct.dirent** %18
%99 = getelementptr inbounds %struct.dirent, %struct.dirent* %98, i32 0, i32 0
%100 = load i8*, i8** %99
%101 = call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%102 = load i8*, i8** %5
%103 = getelementptr inbounds i8, i8* %102, i64 1
%104 = call i32 @strlen(i8* %103)
%105 = add nsw i32 %101, %104
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds i8, i8* %100, i64 %106
%108 = call i32 @atoi(i8* %107)
store i32 %108, i32* %15
%109 = load i32, i32* %15
%110 = load i32, i32* %16
%111 = icmp sgt i32 %109, %110
br i1 %111, label %112, label %142
112: ; preds = %97
%113 = load i32, i32* %15
store i32 %113, i32* %16
%114 = load %struct.dirent*, %struct.dirent** %18
%115 = getelementptr inbounds %struct.dirent, %struct.dirent* %114, i32 0, i32 0
%116 = load i8*, i8** %115
%117 = call i32 @strlen(i8* %116)
%118 = add nsw i32 %117, 1
%119 = sext i32 %118 to i64
store i64 %119, i64* %14
%120 = load i64, i64* %14
%121 = load i64, i64* %13
%122 = icmp ugt i64 %120, %121
br i1 %122, label %123, label %135
123: ; preds = %112
%124 = load i8*, i8** %6
%125 = icmp ne i8* %124, null
br i1 %125, label %126, label %129
126: ; preds = %123
%127 = load i8*, i8** %6
%128 = call i32 @free(i8* %127)
br label %129
129: ; preds = %126, %123
%130 = load i64, i64* %14
%131 = mul i64 1, %130
%132 = trunc i64 %131 to i32
%133 = call i8* @malloc(i32 %132)
store i8* %133, i8** %6
%134 = load i64, i64* %14
store i64 %134, i64* %13
br label %135
135: ; preds = %129, %112
%136 = load i8*, i8** %6
%137 = load %struct.dirent*, %struct.dirent** %18
%138 = getelementptr inbounds %struct.dirent, %struct.dirent* %137, i32 0, i32 0
%139 = load i8*, i8** %138
%140 = load i64, i64* %13
%141 = call i32 @strncpy(i8* %136, i8* %139, i64 %140)
br label %142
142: ; preds = %135, %97
br label %143
143: ; preds = %142, %88
br label %84
144: ; preds = %84
%145 = load i32*, i32** %17
%146 = call i32 @closedir(i32* %145)
%147 = load i8*, i8** %6
%148 = icmp eq i8* %147, null
br i1 %148, label %149, label %153
149: ; preds = %144
%150 = load i32, i32* @stderr
%151 = load i8*, i8** %5
%152 = call i32 (i32, i8*, ...) @fprintf(i32 %150, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.3, i64 0, i64 0), i8* %151)
br label %153
153: ; preds = %149, %144
br label %160
154: ; preds = %70
%155 = load i32, i32* @stderr
%156 = load i8*, i8** %4
%157 = load i32, i32* @errno
%158 = call i8* @strerror(i32 %157)
%159 = call i32 (i32, i8*, ...) @fprintf(i32 %155, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.6, i64 0, i64 0), i8* %156, i8* %158)
br label %160
160: ; preds = %154, %153
br label %161
161: ; preds = %160, %68
%162 = load i8*, i8** %6
store i8* %162, i8** %3
br label %264
163: ; preds = %2
%164 = call i64 @getenv(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%165 = inttoptr i64 %164 to i8*
store i8* %165, i8** %19
%166 = load i8*, i8** %19
%167 = icmp ne i8* %166, null
br i1 %167, label %168, label %178
168: ; preds = %163
%169 = load i8*, i8** %19
%170 = call i8* @strdup(i8* %169)
store i8* %170, i8** %6
%171 = load i8*, i8** %6
%172 = icmp ne i8* %171, null
br i1 %172, label %173, label %175
173: ; preds = %168
%174 = load i8*, i8** %6
store i8* %174, i8** %3
br label %264
175: ; preds = %168
%176 = load i32, i32* @stderr
%177 = call i32 (i32, i8*, ...) @fprintf(i32 %176, i8* getelementptr inbounds ([84 x i8], [84 x i8]* @.str.8, i64 0, i64 0))
br label %178
178: ; preds = %175, %163
store i64 0, i64* %20
store i64 0, i64* %21
store i32 0, i32* %23
store i32 0, i32* %25
%179 = load i8*, i8** %4
%180 = call i32* @opendir(i8* %179)
store i32* %180, i32** %26
%181 = load i32*, i32** %26
%182 = icmp ne i32* %181, null
br i1 %182, label %183, label %250
183: ; preds = %178
br label %184
184: ; preds = %246, %201, %183
%185 = load i32*, i32** %26
%186 = call %struct.dirent* @readdir(i32* %185)
store %struct.dirent* %186, %struct.dirent** %27
%187 = icmp ne %struct.dirent* %186, null
br i1 %187, label %188, label %247
188: ; preds = %184
%189 = load %struct.dirent*, %struct.dirent** %27
%190 = getelementptr inbounds %struct.dirent, %struct.dirent* %189, i32 0, i32 0
%191 = load i8*, i8** %190
%192 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%193 = call i64 @strncmp(i8* %191, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32 %192)
%194 = icmp eq i64 %193, 0
br i1 %194, label %195, label %246
195: ; preds = %188
%196 = load %struct.dirent*, %struct.dirent** %27
%197 = getelementptr inbounds %struct.dirent, %struct.dirent* %196, i32 0, i32 0
%198 = load i8*, i8** %197
%199 = call i32 @sscanf(i8* %198, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i32* %22, i32* %24)
%200 = icmp ne i32 %199, 2
br i1 %200, label %201, label %202
201: ; preds = %195
br label %184
202: ; preds = %195
%203 = load i32, i32* %22
%204 = load i32, i32* %23
%205 = icmp sgt i32 %203, %204
br i1 %205, label %214, label %206
206: ; preds = %202
%207 = load i32, i32* %22
%208 = load i32, i32* %23
%209 = icmp eq i32 %207, %208
br i1 %209, label %210, label %245
210: ; preds = %206
%211 = load i32, i32* %24
%212 = load i32, i32* %25
%213 = icmp sgt i32 %211, %212
br i1 %213, label %214, label %245
214: ; preds = %210, %202
%215 = load i32, i32* %22
store i32 %215, i32* %23
%216 = load i32, i32* %24
store i32 %216, i32* %25
%217 = load %struct.dirent*, %struct.dirent** %27
%218 = getelementptr inbounds %struct.dirent, %struct.dirent* %217, i32 0, i32 0
%219 = load i8*, i8** %218
%220 = call i32 @strlen(i8* %219)
%221 = add nsw i32 %220, 1
%222 = sext i32 %221 to i64
store i64 %222, i64* %21
%223 = load i64, i64* %21
%224 = load i64, i64* %20
%225 = icmp ugt i64 %223, %224
br i1 %225, label %226, label %238
226: ; preds = %214
%227 = load i8*, i8** %6
%228 = icmp ne i8* %227, null
br i1 %228, label %229, label %232
229: ; preds = %226
%230 = load i8*, i8** %6
%231 = call i32 @free(i8* %230)
br label %232
232: ; preds = %229, %226
%233 = load i64, i64* %21
%234 = mul i64 1, %233
%235 = trunc i64 %234 to i32
%236 = call i8* @malloc(i32 %235)
store i8* %236, i8** %6
%237 = load i64, i64* %21
store i64 %237, i64* %20
br label %238
238: ; preds = %232, %214
%239 = load i8*, i8** %6
%240 = load %struct.dirent*, %struct.dirent** %27
%241 = getelementptr inbounds %struct.dirent, %struct.dirent* %240, i32 0, i32 0
%242 = load i8*, i8** %241
%243 = load i64, i64* %20
%244 = call i32 @strncpy(i8* %239, i8* %242, i64 %243)
br label %245
245: ; preds = %238, %210, %206
br label %246
246: ; preds = %245, %188
br label %184
247: ; preds = %184
%248 = load i32*, i32** %26
%249 = call i32 @closedir(i32* %248)
br label %256
250: ; preds = %178
%251 = load i32, i32* @stderr
%252 = load i8*, i8** %4
%253 = load i32, i32* @errno
%254 = call i8* @strerror(i32 %253)
%255 = call i32 (i32, i8*, ...) @fprintf(i32 %251, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.6, i64 0, i64 0), i8* %252, i8* %254)
store i8* null, i8** %3
br label %264
256: ; preds = %247
%257 = load i8*, i8** %6
%258 = icmp eq i8* %257, null
br i1 %258, label %259, label %262
259: ; preds = %256
%260 = load i32, i32* @stderr
%261 = call i32 (i32, i8*, ...) @fprintf(i32 %260, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.11, i64 0, i64 0))
br label %262
262: ; preds = %259, %256
%263 = load i8*, i8** %6
store i8* %263, i8** %3
br label %264
264: ; preds = %262, %250, %173, %161
%265 = load i8*, i8** %3
ret i8* %265
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.dirent = type { i8* }
@.str = [13 x i8] c"libpython.so\00"
@.str.1 = [15 x i8] c"libpython%s.so\00"
@PATH_MAX = global i32 0
@.str.2 = [6 x i8] c"%s/%s\00"
@stderr = global i32 0
@.str.3 = [74 x i8] c"fatal: Failed to find a python version matching command line argument %s\0A\00"
@.str.4 = [13 x i8] c"libpython%s.\00"
@.str.5 = [11 x i8] c"libpython.\00"
@.str.6 = [61 x i8] c"fatal: Failed to open the Python library directory (%s): %s\0A\00"
@errno = global i32 0
@.str.7 = [20 x i8] c"PYTHON_LIBRARY_NAME\00"
@.str.8 = [84 x i8] c"fatal: Failed to copy the Python library name from the environment: Out of memory!\0A\00"
@.str.9 = [10 x i8] c"libpython\00"
@.str.10 = [18 x i8] c"libpython%d.%d.so\00"
@.str.11 = [53 x i8] c"fatal: Failed to find any installed python version!\0A\00"
define i8* @getPythonLibName(i8* %0, i8* %1) {
%3 = alloca %struct.stat
%4 = alloca [32 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = icmp eq i8* %1, null
br i1 %7, label %102, label %8
8: ; preds = %2
%9 = tail call i32* @strchr(i8* %1, i8 signext 46)
%10 = icmp eq i32* %9, null
br i1 %10, label %36, label %11
11: ; preds = %8
%12 = tail call i32 @strlen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds i8, i8* %1, i64 1
%14 = tail call i32 @strlen(i8* %13)
%15 = add i32 %12, 1
%16 = add i32 %15, %14
%17 = sext i32 %16 to i64
%18 = tail call i8* @malloc(i32 %16)
%19 = tail call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %18, i64 %17, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%20 = load i32, i32* @PATH_MAX
%21 = zext i32 %20 to i64
%22 = tail call i8* @llvm.stacksave()
%23 = alloca i8, i64 %21
%24 = load i32, i32* @PATH_MAX
%25 = sext i32 %24 to i64
%26 = call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %23, i64 %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %18)
%27 = bitcast %struct.stat* %3 to i8*
%28 = call i64 @stat(i8* %23, %struct.stat* %3)
%29 = icmp eq i64 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %11
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.3, i64 0, i64 0), i8* %1)
%33 = call i32 @free(i8* %18)
br label %34
34: ; preds = %30, %11
%35 = phi i8* [ null, %30 ], [ %18, %11 ]
br label %178
36: ; preds = %8
%37 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%38 = getelementptr inbounds i8, i8* %1, i64 1
%39 = call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %37, i64 32, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %38)
%40 = call i32 @strlen(i8* %37)
%41 = call i32* @opendir(i8* %0)
%42 = icmp eq i32* %41, null
br i1 %42, label %95, label %43
43: ; preds = %36
%44 = call %struct.dirent* @readdir(i32* %41)
%45 = icmp eq %struct.dirent* %44, null
br i1 %45, label %46, label %48
46: ; preds = %43
%47 = call i32 @closedir(i32* %41)
br label %92
48: ; preds = %43, %83
%49 = phi %struct.dirent* [ %87, %83 ], [ %44, %43 ]
%50 = phi i8* [ %86, %83 ], [ null, %43 ]
%51 = phi i64 [ %85, %83 ], [ 0, %43 ]
%52 = phi i32 [ %84, %83 ], [ 0, %43 ]
%53 = getelementptr inbounds %struct.dirent, %struct.dirent* %49, i64 0, i32 0
%54 = load i8*, i8** %53
%55 = call i64 @strncmp(i8* %54, i8* %37, i32 %40)
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %83
57: ; preds = %48
%58 = load i8*, i8** %53
%59 = call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%60 = call i32 @strlen(i8* %38)
%61 = add nsw i32 %60, %59
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %58, i64 %62
%64 = call i32 @atoi(i8* %63)
%65 = icmp sgt i32 %64, %52
br i1 %65, label %66, label %83
66: ; preds = %57
%67 = load i8*, i8** %53
%68 = call i32 @strlen(i8* %67)
%69 = add nsw i32 %68, 1
%70 = sext i32 %69 to i64
%71 = icmp ult i64 %51, %70
br i1 %71, label %72, label %78
72: ; preds = %66
%73 = icmp eq i8* %50, null
br i1 %73, label %76, label %74
74: ; preds = %72
%75 = call i32 @free(i8* %50)
br label %76
76: ; preds = %74, %72
%77 = call i8* @malloc(i32 %69)
br label %78
78: ; preds = %76, %66
%79 = phi i64 [ %70, %76 ], [ %51, %66 ]
%80 = phi i8* [ %77, %76 ], [ %50, %66 ]
%81 = load i8*, i8** %53
%82 = call i32 @strncpy(i8* %80, i8* %81, i64 %79)
br label %83
83: ; preds = %57, %78, %48
%84 = phi i32 [ %64, %78 ], [ %52, %57 ], [ %52, %48 ]
%85 = phi i64 [ %79, %78 ], [ %51, %57 ], [ %51, %48 ]
%86 = phi i8* [ %80, %78 ], [ %50, %57 ], [ %50, %48 ]
%87 = call %struct.dirent* @readdir(i32* %41)
%88 = icmp eq %struct.dirent* %87, null
br i1 %88, label %89, label %48
89: ; preds = %83
%90 = call i32 @closedir(i32* %41)
%91 = icmp eq i8* %86, null
br i1 %91, label %92, label %100
92: ; preds = %46, %89
%93 = load i32, i32* @stderr
%94 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.3, i64 0, i64 0), i8* %1)
br label %100
95: ; preds = %36
%96 = load i32, i32* @stderr
%97 = load i32, i32* @errno
%98 = call i8* @strerror(i32 %97)
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.6, i64 0, i64 0), i8* %0, i8* %98)
br label %100
100: ; preds = %89, %92, %95
%101 = phi i8* [ null, %92 ], [ %86, %89 ], [ null, %95 ]
br label %178
102: ; preds = %2
%103 = tail call i64 @getenv(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%104 = icmp eq i64 %103, 0
br i1 %104, label %112, label %105
105: ; preds = %102
%106 = inttoptr i64 %103 to i8*
%107 = tail call i8* @strdup(i8* %106)
%108 = icmp eq i8* %107, null
br i1 %108, label %109, label %178
109: ; preds = %105
%110 = load i32, i32* @stderr
%111 = tail call i32 (i32, i8*, ...) @fprintf(i32 %110, i8* getelementptr inbounds ([84 x i8], [84 x i8]* @.str.8, i64 0, i64 0))
br label %112
112: ; preds = %109, %102
%113 = bitcast i32* %5 to i8*
%114 = bitcast i32* %6 to i8*
%115 = tail call i32* @opendir(i8* %0)
%116 = icmp eq i32* %115, null
br i1 %116, label %168, label %117
117: ; preds = %112, %160
%118 = phi i64 [ %161, %160 ], [ 0, %112 ]
%119 = phi i32 [ %137, %160 ], [ 0, %112 ]
%120 = phi i32 [ %148, %160 ], [ 0, %112 ]
%121 = phi i8* [ %162, %160 ], [ null, %112 ]
br label %122
122: ; preds = %146, %117
br label %123
123: ; preds = %122, %132
%124 = call %struct.dirent* @readdir(i32* %115)
%125 = icmp eq %struct.dirent* %124, null
br i1 %125, label %165, label %126
126: ; preds = %123
%127 = getelementptr inbounds %struct.dirent, %struct.dirent* %124, i64 0, i32 0
%128 = load i8*, i8** %127
%129 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%130 = call i64 @strncmp(i8* %128, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32 %129)
%131 = icmp eq i64 %130, 0
br i1 %131, label %132, label %146
132: ; preds = %126
%133 = load i8*, i8** %127
%134 = call i32 @sscanf(i8* %133, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i32* %5, i32* %6)
%135 = icmp eq i32 %134, 2
br i1 %135, label %136, label %123
136: ; preds = %132
%137 = load i32, i32* %5
%138 = icmp sgt i32 %137, %119
br i1 %138, label %139, label %141
139: ; preds = %136
%140 = load i32, i32* %6
br label %147
141: ; preds = %136
%142 = icmp eq i32 %137, %119
%143 = load i32, i32* %6
%144 = icmp sgt i32 %143, %120
%145 = select i1 %142, i1 %144, i1 false
br i1 %145, label %147, label %146
146: ; preds = %126, %141
br label %122
147: ; preds = %141, %139
%148 = phi i32 [ %140, %139 ], [ %143, %141 ]
%149 = load i8*, i8** %127
%150 = call i32 @strlen(i8* %149)
%151 = add nsw i32 %150, 1
%152 = sext i32 %151 to i64
%153 = icmp ult i64 %118, %152
br i1 %153, label %154, label %160
154: ; preds = %147
%155 = icmp eq i8* %121, null
br i1 %155, label %158, label %156
156: ; preds = %154
%157 = call i32 @free(i8* %121)
br label %158
158: ; preds = %156, %154
%159 = call i8* @malloc(i32 %151)
br label %160
160: ; preds = %158, %147
%161 = phi i64 [ %152, %158 ], [ %118, %147 ]
%162 = phi i8* [ %159, %158 ], [ %121, %147 ]
%163 = load i8*, i8** %127
%164 = call i32 @strncpy(i8* %162, i8* %163, i64 %161)
br label %117
165: ; preds = %123
%166 = call i32 @closedir(i32* %115)
%167 = icmp eq i8* %121, null
br i1 %167, label %173, label %176
168: ; preds = %112
%169 = load i32, i32* @stderr
%170 = load i32, i32* @errno
%171 = tail call i8* @strerror(i32 %170)
%172 = tail call i32 (i32, i8*, ...) @fprintf(i32 %169, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.6, i64 0, i64 0), i8* %0, i8* %171)
br label %176
173: ; preds = %165
%174 = load i32, i32* @stderr
%175 = call i32 (i32, i8*, ...) @fprintf(i32 %174, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.11, i64 0, i64 0))
br label %176
176: ; preds = %165, %173, %168
%177 = phi i8* [ null, %168 ], [ null, %173 ], [ %121, %165 ]
br label %178
178: ; preds = %176, %105, %34, %100
%179 = phi i8* [ %35, %34 ], [ %101, %100 ], [ %177, %176 ], [ %107, %105 ]
ret i8* %179
}