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

/* Variables and functions */
int COLS;
int LINES;
int /*<<< orphan*/ clear();
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int getint();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ keypad(int /*<<< orphan*/, int);
int /*<<< orphan*/ mvprintw(int, int, char *, ...);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ stdscr;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  DIR *dp;
  struct dirent *ep;
  char envvar[255];
  char prompt[255];
  char files[1000][255];
  int numfiles;
  int longest, numcols, maxonscreen;
  int c, page;
  if (argc < 2) {
    perror(
        "dirtoenv\n-------\n"
        "A utility to display a list of all files and directories and assign "
        "the selected\n"
        "directory or file to the environment variable passed to it.\n\n"
        "Usage:\n"
        "dirtoenv EnvironmentVariable [Prompt]\n"
        "EnvironmentVariable - The environment variable you want to assign.\n"
        "Prompt - An optional prompt to display.\n\n");
    return (1);
  }
  strcpy(envvar, "SET ");
  strcat(envvar, argv[1]);
  if (argc > 2) {
    strcpy(prompt, argv[2]);
    for (c = 3; c < argc; c++) {
      strcat(prompt, " ");
      strcat(prompt, argv[c]);
    }
  } else
    strcpy(prompt, "Choose a file/directory:");
  dp = opendir("./");
  if (dp != NULL) {
    numfiles = 0;
    longest = 0;
    while ((ep = readdir(dp)) && (numfiles < 1000)) {
      strcpy(files[numfiles], ep->d_name);
      if (strlen(files[numfiles]) > longest)
        longest = strlen(files[numfiles]);
      numfiles++;
    }
    (void)closedir(dp);
  } else {
    perror("Couldn't open the directory");
    return (1);
  }
  initscr();
  keypad(stdscr, 1);
  noecho();
  longest += 6;
  numcols = COLS / longest;
  maxonscreen = (LINES - 5) * numcols;
  page = 0;
  while (1) {
    clear();
    mvprintw(0, 0, prompt);
    for (c = 0; (c < maxonscreen) && ((c + page * maxonscreen) < numfiles); c++)
      mvprintw(c % (LINES - 5) + 2, (COLS / numcols) * (c / (LINES - 5)),
               "%d) %s", c + 1, files[c + page * maxonscreen]);
    if (page > 0) {
      mvprintw(LINES - 2, 0, "%d) First Page", maxonscreen + 1);
      mvprintw(LINES - 2, 20, "%d) Previous Page", maxonscreen + 2);
    }
    if (page < (numfiles / maxonscreen)) {
      mvprintw(LINES - 2, 40, "%d) Next Page", maxonscreen + 3);
      mvprintw(LINES - 2, 60, "%d) Last Page", maxonscreen + 4);
    }
    mvprintw(LINES - 1, 0, "Type the number of your selection : ");
    refresh();
    c = getint();
    if ((c > 0) && (c <= maxonscreen) &&
        ((c - 1 + page * maxonscreen) < numfiles)) {
      endwin();
      strcat(envvar, "=");
      strcat(envvar, files[c - 1 + page * maxonscreen]);
      FILE *fp;
      fp = fopen("c:\\temp.bat", "w");
      if (fp != NULL) {
        fprintf(fp, "%s\n", envvar);
        fclose(fp);
      }
      printf(
          "You must not run c:\\temp.bat to set the environment variable.\n");
      return (0);
    }
    if ((c == maxonscreen + 1) && (page > 0))
      page = 0;
    if ((c == maxonscreen + 2) && (page > 0))
      page--;
    if ((c == maxonscreen + 3) && ((page + 1) * maxonscreen) < numfiles)
      page++;
    if ((c == maxonscreen + 4) && ((page + 1) * maxonscreen) < numfiles)
      page = numfiles / maxonscreen;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3e670,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    126b <main+0x3b>
lea    0xda6(%rip),%rdi
call   1110 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    18a3 <main+0x673>
lea    -0x120(%rbp),%rdi
lea    0xec0(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1130 <strcat@plt>
cmpl   $0x2,-0x8(%rbp)
jle    1310 <main+0xe0>
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1030 <strcpy@plt>
movl   $0x3,-0x3e654(%rbp)
mov    -0x3e654(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    130b <main+0xdb>
lea    -0x220(%rbp),%rdi
lea    0xf06(%rip),%rsi
call   1130 <strcat@plt>
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x3e654(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1130 <strcat@plt>
mov    -0x3e654(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3e654(%rbp)
jmp    12ba <main+0x8a>
jmp    1323 <main+0xf3>
lea    -0x220(%rbp),%rdi
lea    0xe20(%rip),%rsi
call   1030 <strcpy@plt>
lea    0xe2d(%rip),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     142c <main+0x1fc>
movl   $0x0,-0x3e644(%rbp)
movl   $0x0,-0x3e648(%rbp)
mov    -0x18(%rbp),%rdi
call   10d0 <readdir@plt>
mov    %rax,%rcx
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x3e661(%rbp)
je     1387 <main+0x157>
cmpl   $0x3e8,-0x3e644(%rbp)
setl   %al
mov    %al,-0x3e661(%rbp)
mov    -0x3e661(%rbp),%al
test   $0x1,%al
jne    139a <main+0x16a>
jmp    141e <main+0x1ee>
movslq -0x3e644(%rbp),%rax
lea    -0x3e640(%rbp),%rdi
imul   $0xff,%rax,%rax
add    %rax,%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
call   1030 <strcpy@plt>
movslq -0x3e644(%rbp),%rax
lea    -0x3e640(%rbp),%rdi
imul   $0xff,%rax,%rax
add    %rax,%rdi
call   1060 <strlen@plt>
cmp    -0x3e648(%rbp),%eax
jle    140a <main+0x1da>
movslq -0x3e644(%rbp),%rax
lea    -0x3e640(%rbp),%rdi
imul   $0xff,%rax,%rax
add    %rax,%rdi
call   1060 <strlen@plt>
mov    %eax,-0x3e648(%rbp)
mov    -0x3e644(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3e644(%rbp)
jmp    1352 <main+0x122>
mov    -0x18(%rbp),%rdi
call   10b0 <closedir@plt>
jmp    1444 <main+0x214>
lea    0xd27(%rip),%rdi
call   1110 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    18a3 <main+0x673>
mov    $0x0,%al
call   1090 <initscr@plt>
mov    0x2b8e(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1080 <keypad@plt>
mov    $0x0,%al
call   1120 <noecho@plt>
mov    -0x3e648(%rbp),%eax
add    $0x6,%eax
mov    %eax,-0x3e648(%rbp)
mov    0x2b5d(%rip),%rax
mov    (%rax),%eax
cltd
idivl  -0x3e648(%rbp)
mov    %eax,-0x3e64c(%rbp)
mov    0x2b57(%rip),%rax
mov    (%rax),%eax
sub    $0x5,%eax
imul   -0x3e64c(%rbp),%eax
mov    %eax,-0x3e650(%rbp)
movl   $0x0,-0x3e658(%rbp)
mov    $0x0,%al
call   1140 <clear@plt>
lea    -0x220(%rbp),%rdx
xor    %esi,%esi
mov    %esi,%edi
mov    $0x0,%al
call   1150 <mvprintw@plt>
movl   $0x0,-0x3e654(%rbp)
mov    -0x3e654(%rbp),%ecx
xor    %eax,%eax
cmp    -0x3e650(%rbp),%ecx
mov    %al,-0x3e662(%rbp)
jge    150e <main+0x2de>
mov    -0x3e654(%rbp),%eax
mov    -0x3e658(%rbp),%ecx
imul   -0x3e650(%rbp),%ecx
add    %ecx,%eax
cmp    -0x3e644(%rbp),%eax
setl   %al
mov    %al,-0x3e662(%rbp)
mov    -0x3e662(%rbp),%al
test   $0x1,%al
jne    1521 <main+0x2f1>
jmp    15b8 <main+0x388>
mov    -0x3e654(%rbp),%eax
mov    0x2aba(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x5,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x2,%edi
mov    0x2a96(%rip),%rax
mov    (%rax),%eax
cltd
idivl  -0x3e64c(%rbp)
mov    %eax,%esi
mov    -0x3e654(%rbp),%eax
mov    0x2a8e(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x5,%ecx
cltd
idiv   %ecx
imul   %eax,%esi
mov    -0x3e654(%rbp),%ecx
add    $0x1,%ecx
mov    -0x3e654(%rbp),%eax
mov    -0x3e658(%rbp),%edx
imul   -0x3e650(%rbp),%edx
add    %edx,%eax
cltq
lea    -0x3e640(%rbp),%r8
imul   $0xff,%rax,%rax
add    %rax,%r8
lea    0xbd9(%rip),%rdx
mov    $0x0,%al
call   1150 <mvprintw@plt>
mov    -0x3e654(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3e654(%rbp)
jmp    14d0 <main+0x2a0>
cmpl   $0x0,-0x3e658(%rbp)
jle    1612 <main+0x3e2>
mov    0x2a1c(%rip),%rax
mov    (%rax),%edi
sub    $0x2,%edi
mov    -0x3e650(%rbp),%ecx
add    $0x1,%ecx
xor    %esi,%esi
lea    0xb9a(%rip),%rdx
mov    $0x0,%al
call   1150 <mvprintw@plt>
mov    0x29f7(%rip),%rax
mov    (%rax),%edi
sub    $0x2,%edi
mov    -0x3e650(%rbp),%ecx
add    $0x2,%ecx
mov    $0x14,%esi
lea    0xb81(%rip),%rdx
mov    $0x0,%al
call   1150 <mvprintw@plt>
mov    -0x3e658(%rbp),%eax
mov    %eax,-0x3e668(%rbp)
mov    -0x3e644(%rbp),%eax
cltd
idivl  -0x3e650(%rbp)
mov    %eax,%ecx
mov    -0x3e668(%rbp),%eax
cmp    %ecx,%eax
jge    168b <main+0x45b>
mov    0x29a6(%rip),%rax
mov    (%rax),%edi
sub    $0x2,%edi
mov    -0x3e650(%rbp),%ecx
add    $0x3,%ecx
mov    $0x28,%esi
lea    0xb42(%rip),%rdx
mov    $0x0,%al
call   1150 <mvprintw@plt>
mov    0x297e(%rip),%rax
mov    (%rax),%edi
sub    $0x2,%edi
mov    -0x3e650(%rbp),%ecx
add    $0x4,%ecx
mov    $0x3c,%esi
lea    0xb28(%rip),%rdx
mov    $0x0,%al
call   1150 <mvprintw@plt>
mov    0x2956(%rip),%rax
mov    (%rax),%edi
sub    $0x1,%edi
xor    %esi,%esi
lea    0xb1a(%rip),%rdx
mov    $0x0,%al
call   1150 <mvprintw@plt>
mov    $0x0,%al
call   10e0 <refresh@plt>
mov    $0x0,%al
call   10a0 <getint@plt>
mov    %eax,-0x3e654(%rbp)
cmpl   $0x0,-0x3e654(%rbp)
jle    17b5 <main+0x585>
mov    -0x3e654(%rbp),%eax
cmp    -0x3e650(%rbp),%eax
jg     17b5 <main+0x585>
mov    -0x3e654(%rbp),%eax
sub    $0x1,%eax
mov    -0x3e658(%rbp),%ecx
imul   -0x3e650(%rbp),%ecx
add    %ecx,%eax
cmp    -0x3e644(%rbp),%eax
jge    17b5 <main+0x585>
mov    $0x0,%al
call   10f0 <endwin@plt>
lea    -0x120(%rbp),%rdi
lea    0xacc(%rip),%rsi
call   1130 <strcat@plt>
lea    -0x120(%rbp),%rdi
mov    -0x3e654(%rbp),%eax
sub    $0x1,%eax
mov    -0x3e658(%rbp),%ecx
imul   -0x3e650(%rbp),%ecx
add    %ecx,%eax
cltq
lea    -0x3e640(%rbp),%rsi
imul   $0xff,%rax,%rax
add    %rax,%rsi
call   1130 <strcat@plt>
lea    0xa8b(%rip),%rdi
lea    0xa90(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x3e660(%rbp)
cmpq   $0x0,-0x3e660(%rbp)
je     179d <main+0x56d>
mov    -0x3e660(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xa63(%rip),%rsi
call   10c0 <fprintf@plt>
mov    -0x3e660(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xa4f(%rip),%rdi
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    18a3 <main+0x673>
mov    -0x3e654(%rbp),%eax
mov    -0x3e650(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jne    17e3 <main+0x5b3>
cmpl   $0x0,-0x3e658(%rbp)
jle    17e3 <main+0x5b3>
movl   $0x0,-0x3e658(%rbp)
mov    -0x3e654(%rbp),%eax
mov    -0x3e650(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jne    1816 <main+0x5e6>
cmpl   $0x0,-0x3e658(%rbp)
jle    1816 <main+0x5e6>
mov    -0x3e658(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3e658(%rbp)
mov    -0x3e654(%rbp),%eax
mov    -0x3e650(%rbp),%ecx
add    $0x3,%ecx
cmp    %ecx,%eax
jne    1858 <main+0x628>
mov    -0x3e658(%rbp),%eax
add    $0x1,%eax
imul   -0x3e650(%rbp),%eax
cmp    -0x3e644(%rbp),%eax
jge    1858 <main+0x628>
mov    -0x3e658(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3e658(%rbp)
mov    -0x3e654(%rbp),%eax
mov    -0x3e650(%rbp),%ecx
add    $0x4,%ecx
cmp    %ecx,%eax
jne    189e <main+0x66e>
mov    -0x3e658(%rbp),%eax
add    $0x1,%eax
imul   -0x3e650(%rbp),%eax
cmp    -0x3e644(%rbp),%eax
jge    189e <main+0x66e>
mov    -0x3e644(%rbp),%eax
cltd
idivl  -0x3e650(%rbp)
mov    %eax,-0x3e658(%rbp)
jmp    14ad <main+0x27d>
mov    -0x4(%rbp),%eax
add    $0x3e670,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3e648,%rsp
cmp    $0x1,%edi
jle    1677 <main+0x447>
mov    %rsi,%r15
mov    %edi,%ebp
lea    0xee3(%rip),%rsi
lea    0x130(%rsp),%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    0x8(%r15),%rsi
mov    %r14,%rdi
call   1130 <strcat@plt>
cmp    $0x2,%ebp
jne    128a <main+0x5a>
lea    0xec0(%rip),%rsi
lea    0x30(%rsp),%rdi
call   1030 <strcpy@plt>
jmp    12e0 <main+0xb0>
mov    0x10(%r15),%rsi
lea    0x30(%rsp),%rdi
call   1030 <strcpy@plt>
cmp    $0x4,%ebp
jb     12e0 <main+0xb0>
mov    %ebp,%r12d
mov    $0x3,%ebx
lea    0xf31(%rip),%r14
lea    0x30(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %r14,%rsi
call   1130 <strcat@plt>
mov    (%r15,%rbx,8),%rsi
mov    %rbp,%rdi
call   1130 <strcat@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    12c0 <main+0x90>
lea    0xe70(%rip),%rdi
call   1060 <opendir@plt>
test   %rax,%rax
je     1680 <main+0x450>
mov    %rax,%r14
mov    %rax,%rdi
call   10d0 <readdir@plt>
mov    $0x0,%r15d
mov    $0x0,%ebx
test   %rax,%rax
je     1368 <main+0x138>
xor    %r12d,%r12d
lea    0x230(%rsp),%rbp
xor    %r15d,%r15d
xchg   %ax,%ax
mov    (%rax),%rsi
mov    %rbp,%rdi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
call   1070 <strlen@plt>
cmp    %r15d,%eax
jle    1343 <main+0x113>
mov    %rbp,%rdi
call   1070 <strlen@plt>
mov    %eax,%r15d
lea    0x1(%r12),%rbx
mov    %r14,%rdi
call   10d0 <readdir@plt>
test   %rax,%rax
je     1368 <main+0x138>
add    $0xff,%rbp
cmp    $0x3e7,%r12
mov    %rbx,%r12
jb     1320 <main+0xf0>
mov    %r14,%rdi
call   10b0 <closedir@plt>
xor    %eax,%eax
call   1090 <initscr@plt>
mov    0x2c62(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1080 <keypad@plt>
xor    %eax,%eax
call   1120 <noecho@plt>
add    $0x6,%r15d
mov    0x2c3c(%rip),%rax
mov    (%rax),%eax
cltd
idiv   %r15d
mov    %eax,%r15d
mov    0x2c3c(%rip),%rax
mov    (%rax),%r12d
add    $0xfffffffb,%r12d
imul   %r15d,%r12d
lea    0x1(%r12),%eax
mov    %eax,0x1c(%rsp)
lea    0x2(%r12),%eax
mov    %eax,0x18(%rsp)
lea    0x3(%r12),%eax
mov    %eax,0x14(%rsp)
lea    0x4(%r12),%eax
mov    %eax,0x10(%rsp)
mov    %rbx,0x28(%rsp)
movslq %ebx,%r14
xor    %r13d,%r13d
jmp    144a <main+0x21a>
nopl   0x0(%rax,%rax,1)
mov    0xc(%rsp),%esi
test   %esi,%esi
mov    %esi,%ecx
mov    $0x0,%edx
cmovg  %edx,%ecx
cmp    0x1c(%rsp),%eax
cmovne %esi,%ecx
cmp    0x18(%rsp),%eax
sete   %dl
test   %ecx,%ecx
setg   %bl
and    %dl,%bl
movzbl %bl,%edx
mov    %ecx,%esi
sub    %edx,%esi
neg    %edx
add    %edx,%ecx
add    $0x1,%ecx
mov    %ecx,%edx
imul   %r12d,%edx
cmp    %ebp,%edx
cmovge %esi,%ecx
cmp    0x14(%rsp),%eax
cmovne %esi,%ecx
lea    0x1(%rcx),%edx
imul   %r12d,%edx
cmp    %ebp,%edx
cmovge %ecx,%r13d
cmp    0x10(%rsp),%eax
cmovne %ecx,%r13d
xor    %eax,%eax
call   1140 <clear@plt>
xor    %edi,%edi
xor    %esi,%esi
lea    0x30(%rsp),%rdx
xor    %eax,%eax
call   1150 <mvprintw@plt>
mov    %r13d,0xc(%rsp)
mov    %r13d,%eax
imul   %r12d,%eax
mov    %rax,0x20(%rsp)
test   %r12d,%r12d
jle    14f4 <main+0x2c4>
movslq 0x20(%rsp),%r13
mov    %r13,%rax
shl    $0x8,%rax
sub    %r13,%rax
lea    (%rsp,%rax,1),%rbx
add    $0x230,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rax
add    %rbp,%rax
cmp    %r14,%rax
jge    14f4 <main+0x2c4>
mov    0x2b36(%rip),%rax
mov    (%rax),%ecx
add    $0xfffffffb,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %eax,%esi
lea    0x2(%rdx),%edi
mov    0x2b10(%rip),%rax
mov    (%rax),%eax
cltd
idiv   %r15d
imul   %eax,%esi
add    $0x1,%rbp
lea    0xc9a(%rip),%rdx
mov    %ebp,%ecx
mov    %rbx,%r8
xor    %eax,%eax
call   1150 <mvprintw@plt>
add    $0xff,%rbx
cmp    %rbp,%r12
jne    14a0 <main+0x270>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
jle    153c <main+0x30c>
mov    0x2ae5(%rip),%rbx
mov    (%rbx),%edi
add    $0xfffffffe,%edi
xor    %esi,%esi
lea    0xc6c(%rip),%rdx
mov    0x1c(%rsp),%ecx
xor    %eax,%eax
call   1150 <mvprintw@plt>
mov    (%rbx),%edi
mov    0xc(%rsp),%ebx
add    $0xfffffffe,%edi
mov    $0x14,%esi
lea    0xc5b(%rip),%rdx
mov    0x18(%rsp),%ecx
xor    %eax,%eax
call   1150 <mvprintw@plt>
mov    0x28(%rsp),%rbp
mov    %ebp,%eax
cltd
idiv   %r12d
mov    %eax,%r13d
cmp    %eax,%ebx
jge    158d <main+0x35d>
mov    0x2a93(%rip),%rbx
mov    (%rbx),%edi
add    $0xfffffffe,%edi
mov    $0x28,%esi
lea    0xc38(%rip),%rdx
mov    0x14(%rsp),%ecx
xor    %eax,%eax
call   1150 <mvprintw@plt>
mov    (%rbx),%edi
add    $0xfffffffe,%edi
mov    $0x3c,%esi
lea    0xc2a(%rip),%rdx
mov    0x10(%rsp),%ecx
xor    %eax,%eax
call   1150 <mvprintw@plt>
mov    0x2a54(%rip),%rax
mov    (%rax),%edi
add    $0xffffffff,%edi
xor    %esi,%esi
lea    0xc18(%rip),%rdx
xor    %eax,%eax
call   1150 <mvprintw@plt>
xor    %eax,%eax
call   10e0 <refresh@plt>
xor    %eax,%eax
call   10a0 <getint@plt>
test   %eax,%eax
jle    13f0 <main+0x1c0>
cmp    %r12d,%eax
jg     13f0 <main+0x1c0>
mov    0x20(%rsp),%rcx
lea    (%rcx,%rax,1),%ebx
add    $0xffffffff,%ebx
cmp    %ebp,%ebx
jge    13f0 <main+0x1c0>
xor    %r14d,%r14d
xor    %eax,%eax
call   10f0 <endwin@plt>
lea    0xbf3(%rip),%rsi
lea    0x130(%rsp),%rbp
mov    %rbp,%rdi
call   1130 <strcat@plt>
movslq %ebx,%rax
mov    %rax,%rcx
shl    $0x8,%rcx
sub    %rax,%rcx
lea    (%rsp,%rcx,1),%rsi
add    $0x230,%rsi
mov    %rbp,%rdi
call   1130 <strcat@plt>
lea    0xbbe(%rip),%rdi
lea    0xbc3(%rip),%rsi
call   1100 <fopen@plt>
test   %rax,%rax
je     1656 <main+0x426>
mov    %rax,%rbp
lea    0xbb1(%rip),%rsi
lea    0x130(%rsp),%rdx
mov    %rax,%rdi
call   10c0 <fprintf@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
lea    0xb96(%rip),%rdi
call   1040 <puts@plt>
mov    %r14d,%eax
add    $0x3e648,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x982(%rip),%rdi
jmp    1687 <main+0x457>
lea    0xad3(%rip),%rdi
call   1110 <perror@plt>
mov    $0x1,%r14d
jmp    1662 <main+0x432>

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [313 x i8] c"dirtoenv\0A-------\0AA utility to display a list of all files and directories and assign the selected\0Adirectory or file to the environment variable passed to it.\0A\0AUsage:\0Adirtoenv EnvironmentVariable [Prompt]\0AEnvironmentVariable - The environment variable you want to assign.\0APrompt - An optional prompt to display.\0A\0A\00"
@.str.1 = [5 x i8] c"SET \00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [25 x i8] c"Choose a file/directory:\00"
@.str.4 = [3 x i8] c"./\00"
@.str.5 = [28 x i8] c"Couldn't open the directory\00"
@stdscr = global i32 0
@COLS = global i32 0
@LINES = global i32 0
@.str.6 = [7 x i8] c"%d) %s\00"
@.str.7 = [15 x i8] c"%d) First Page\00"
@.str.8 = [18 x i8] c"%d) Previous Page\00"
@.str.9 = [14 x i8] c"%d) Next Page\00"
@.str.10 = [14 x i8] c"%d) Last Page\00"
@.str.11 = [37 x i8] c"Type the number of your selection : \00"
@.str.12 = [2 x i8] c"=\00"
@.str.13 = [12 x i8] c"c:\\temp.bat\00"
@.str.14 = [2 x i8] c"w\00"
@.str.15 = [4 x i8] c"%s\0A\00"
@.str.16 = [63 x i8] c"You must not run c:\\temp.bat to set the environment variable.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca %struct.dirent*
%8 = alloca [255 x i8]
%9 = alloca [255 x i8]
%10 = alloca [1000 x [255 x i8]]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 2
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = call i32 @perror(i8* getelementptr inbounds ([313 x i8], [313 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %293
22: ; preds = %2
%23 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%24 = call i32 @strcpy(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%25 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @strcat(i8* %25, i8* %28)
%30 = load i32, i32* %4
%31 = icmp sgt i32 %30, 2
br i1 %31, label %32, label %56
32: ; preds = %22
%33 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i32 @strcpy(i8* %33, i8* %36)
store i32 3, i32* %15
br label %38
38: ; preds = %52, %32
%39 = load i32, i32* %15
%40 = load i32, i32* %4
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %55
42: ; preds = %38
%43 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%44 = call i32 @strcat(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%45 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%46 = load i8**, i8*** %5
%47 = load i32, i32* %15
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %46, i64 %48
%50 = load i8*, i8** %49
%51 = call i32 @strcat(i8* %45, i8* %50)
br label %52
52: ; preds = %42
%53 = load i32, i32* %15
%54 = add nsw i32 %53, 1
store i32 %54, i32* %15
br label %38
55: ; preds = %38
br label %59
56: ; preds = %22
%57 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%58 = call i32 @strcpy(i8* %57, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %59
59: ; preds = %56, %55
%60 = call i32* @opendir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %60, i32** %6
%61 = load i32*, i32** %6
%62 = icmp ne i32* %61, null
br i1 %62, label %63, label %101
63: ; preds = %59
store i32 0, i32* %11
store i32 0, i32* %12
br label %64
64: ; preds = %95, %63
%65 = load i32*, i32** %6
%66 = call %struct.dirent* @readdir(i32* %65)
store %struct.dirent* %66, %struct.dirent** %7
%67 = icmp ne %struct.dirent* %66, null
br i1 %67, label %68, label %71
68: ; preds = %64
%69 = load i32, i32* %11
%70 = icmp slt i32 %69, 1000
br label %71
71: ; preds = %68, %64
%72 = phi i1 [ false, %64 ], [ %70, %68 ]
br i1 %72, label %73, label %98
73: ; preds = %71
%74 = load i32, i32* %11
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [1000 x [255 x i8]], [1000 x [255 x i8]]* %10, i64 0, i64 %75
%77 = getelementptr inbounds [255 x i8], [255 x i8]* %76, i64 0, i64 0
%78 = load %struct.dirent*, %struct.dirent** %7
%79 = getelementptr inbounds %struct.dirent, %struct.dirent* %78, i32 0, i32 0
%80 = load i8*, i8** %79
%81 = call i32 @strcpy(i8* %77, i8* %80)
%82 = load i32, i32* %11
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [1000 x [255 x i8]], [1000 x [255 x i8]]* %10, i64 0, i64 %83
%85 = getelementptr inbounds [255 x i8], [255 x i8]* %84, i64 0, i64 0
%86 = call i32 @strlen(i8* %85)
%87 = load i32, i32* %12
%88 = icmp sgt i32 %86, %87
br i1 %88, label %89, label %95
89: ; preds = %73
%90 = load i32, i32* %11
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [1000 x [255 x i8]], [1000 x [255 x i8]]* %10, i64 0, i64 %91
%93 = getelementptr inbounds [255 x i8], [255 x i8]* %92, i64 0, i64 0
%94 = call i32 @strlen(i8* %93)
store i32 %94, i32* %12
br label %95
95: ; preds = %89, %73
%96 = load i32, i32* %11
%97 = add nsw i32 %96, 1
store i32 %97, i32* %11
br label %64
98: ; preds = %71
%99 = load i32*, i32** %6
%100 = call i32 @closedir(i32* %99)
br label %103
101: ; preds = %59
%102 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %293
103: ; preds = %98
%104 = call i32 (...) @initscr()
%105 = load i32, i32* @stdscr
%106 = call i32 @keypad(i32 %105, i32 1)
%107 = call i32 (...) @noecho()
%108 = load i32, i32* %12
%109 = add nsw i32 %108, 6
store i32 %109, i32* %12
%110 = load i32, i32* @COLS
%111 = load i32, i32* %12
%112 = sdiv i32 %110, %111
store i32 %112, i32* %13
%113 = load i32, i32* @LINES
%114 = sub nsw i32 %113, 5
%115 = load i32, i32* %13
%116 = mul nsw i32 %114, %115
store i32 %116, i32* %14
store i32 0, i32* %16
br label %117
117: ; preds = %103, %292
%118 = call i32 (...) @clear()
%119 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%120 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 0, i32 0, i8* %119)
store i32 0, i32* %15
br label %121
121: ; preds = %160, %117
%122 = load i32, i32* %15
%123 = load i32, i32* %14
%124 = icmp slt i32 %122, %123
br i1 %124, label %125, label %133
125: ; preds = %121
%126 = load i32, i32* %15
%127 = load i32, i32* %16
%128 = load i32, i32* %14
%129 = mul nsw i32 %127, %128
%130 = add nsw i32 %126, %129
%131 = load i32, i32* %11
%132 = icmp slt i32 %130, %131
br label %133
133: ; preds = %125, %121
%134 = phi i1 [ false, %121 ], [ %132, %125 ]
br i1 %134, label %135, label %163
135: ; preds = %133
%136 = load i32, i32* %15
%137 = load i32, i32* @LINES
%138 = sub nsw i32 %137, 5
%139 = srem i32 %136, %138
%140 = add nsw i32 %139, 2
%141 = load i32, i32* @COLS
%142 = load i32, i32* %13
%143 = sdiv i32 %141, %142
%144 = load i32, i32* %15
%145 = load i32, i32* @LINES
%146 = sub nsw i32 %145, 5
%147 = sdiv i32 %144, %146
%148 = mul nsw i32 %143, %147
%149 = load i32, i32* %15
%150 = add nsw i32 %149, 1
%151 = load i32, i32* %15
%152 = load i32, i32* %16
%153 = load i32, i32* %14
%154 = mul nsw i32 %152, %153
%155 = add nsw i32 %151, %154
%156 = sext i32 %155 to i64
%157 = getelementptr inbounds [1000 x [255 x i8]], [1000 x [255 x i8]]* %10, i64 0, i64 %156
%158 = getelementptr inbounds [255 x i8], [255 x i8]* %157, i64 0, i64 0
%159 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %140, i32 %148, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %150, i8* %158)
br label %160
160: ; preds = %135
%161 = load i32, i32* %15
%162 = add nsw i32 %161, 1
store i32 %162, i32* %15
br label %121
163: ; preds = %133
%164 = load i32, i32* %16
%165 = icmp sgt i32 %164, 0
br i1 %165, label %166, label %177
166: ; preds = %163
%167 = load i32, i32* @LINES
%168 = sub nsw i32 %167, 2
%169 = load i32, i32* %14
%170 = add nsw i32 %169, 1
%171 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %168, i32 0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 %170)
%172 = load i32, i32* @LINES
%173 = sub nsw i32 %172, 2
%174 = load i32, i32* %14
%175 = add nsw i32 %174, 2
%176 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %173, i32 20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i32 %175)
br label %177
177: ; preds = %166, %163
%178 = load i32, i32* %16
%179 = load i32, i32* %11
%180 = load i32, i32* %14
%181 = sdiv i32 %179, %180
%182 = icmp slt i32 %178, %181
br i1 %182, label %183, label %194
183: ; preds = %177
%184 = load i32, i32* @LINES
%185 = sub nsw i32 %184, 2
%186 = load i32, i32* %14
%187 = add nsw i32 %186, 3
%188 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %185, i32 40, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i32 %187)
%189 = load i32, i32* @LINES
%190 = sub nsw i32 %189, 2
%191 = load i32, i32* %14
%192 = add nsw i32 %191, 4
%193 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %190, i32 60, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i32 %192)
br label %194
194: ; preds = %183, %177
%195 = load i32, i32* @LINES
%196 = sub nsw i32 %195, 1
%197 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %196, i32 0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.11, i64 0, i64 0))
%198 = call i32 (...) @refresh()
%199 = call i32 (...) @getint()
store i32 %199, i32* %15
%200 = load i32, i32* %15
%201 = icmp sgt i32 %200, 0
br i1 %201, label %202, label %241
202: ; preds = %194
%203 = load i32, i32* %15
%204 = load i32, i32* %14
%205 = icmp sle i32 %203, %204
br i1 %205, label %206, label %241
206: ; preds = %202
%207 = load i32, i32* %15
%208 = sub nsw i32 %207, 1
%209 = load i32, i32* %16
%210 = load i32, i32* %14
%211 = mul nsw i32 %209, %210
%212 = add nsw i32 %208, %211
%213 = load i32, i32* %11
%214 = icmp slt i32 %212, %213
br i1 %214, label %215, label %241
215: ; preds = %206
%216 = call i32 (...) @endwin()
%217 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%218 = call i32 @strcat(i8* %217, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%219 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%220 = load i32, i32* %15
%221 = sub nsw i32 %220, 1
%222 = load i32, i32* %16
%223 = load i32, i32* %14
%224 = mul nsw i32 %222, %223
%225 = add nsw i32 %221, %224
%226 = sext i32 %225 to i64
%227 = getelementptr inbounds [1000 x [255 x i8]], [1000 x [255 x i8]]* %10, i64 0, i64 %226
%228 = getelementptr inbounds [255 x i8], [255 x i8]* %227, i64 0, i64 0
%229 = call i32 @strcat(i8* %219, i8* %228)
%230 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
store i32* %230, i32** %17
%231 = load i32*, i32** %17
%232 = icmp ne i32* %231, null
br i1 %232, label %233, label %239
233: ; preds = %215
%234 = load i32*, i32** %17
%235 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%236 = call i32 @fprintf(i32* %234, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0), i8* %235)
%237 = load i32*, i32** %17
%238 = call i32 @fclose(i32* %237)
br label %239
239: ; preds = %233, %215
%240 = call i32 @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.16, i64 0, i64 0))
store i32 0, i32* %3
br label %293
241: ; preds = %206, %202, %194
%242 = load i32, i32* %15
%243 = load i32, i32* %14
%244 = add nsw i32 %243, 1
%245 = icmp eq i32 %242, %244
br i1 %245, label %246, label %250
246: ; preds = %241
%247 = load i32, i32* %16
%248 = icmp sgt i32 %247, 0
br i1 %248, label %249, label %250
249: ; preds = %246
store i32 0, i32* %16
br label %250
250: ; preds = %249, %246, %241
%251 = load i32, i32* %15
%252 = load i32, i32* %14
%253 = add nsw i32 %252, 2
%254 = icmp eq i32 %251, %253
br i1 %254, label %255, label %261
255: ; preds = %250
%256 = load i32, i32* %16
%257 = icmp sgt i32 %256, 0
br i1 %257, label %258, label %261
258: ; preds = %255
%259 = load i32, i32* %16
%260 = add nsw i32 %259, -1
store i32 %260, i32* %16
br label %261
261: ; preds = %258, %255, %250
%262 = load i32, i32* %15
%263 = load i32, i32* %14
%264 = add nsw i32 %263, 3
%265 = icmp eq i32 %262, %264
br i1 %265, label %266, label %276
266: ; preds = %261
%267 = load i32, i32* %16
%268 = add nsw i32 %267, 1
%269 = load i32, i32* %14
%270 = mul nsw i32 %268, %269
%271 = load i32, i32* %11
%272 = icmp slt i32 %270, %271
br i1 %272, label %273, label %276
273: ; preds = %266
%274 = load i32, i32* %16
%275 = add nsw i32 %274, 1
store i32 %275, i32* %16
br label %276
276: ; preds = %273, %266, %261
%277 = load i32, i32* %15
%278 = load i32, i32* %14
%279 = add nsw i32 %278, 4
%280 = icmp eq i32 %277, %279
br i1 %280, label %281, label %292
281: ; preds = %276
%282 = load i32, i32* %16
%283 = add nsw i32 %282, 1
%284 = load i32, i32* %14
%285 = mul nsw i32 %283, %284
%286 = load i32, i32* %11
%287 = icmp slt i32 %285, %286
br i1 %287, label %288, label %292
288: ; preds = %281
%289 = load i32, i32* %11
%290 = load i32, i32* %14
%291 = sdiv i32 %289, %290
store i32 %291, i32* %16
br label %292
292: ; preds = %288, %281, %276
br label %117
293: ; preds = %239, %101, %20
%294 = load i32, i32* %3
ret i32 %294
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [313 x i8] c"dirtoenv\0A-------\0AA utility to display a list of all files and directories and assign the selected\0Adirectory or file to the environment variable passed to it.\0A\0AUsage:\0Adirtoenv EnvironmentVariable [Prompt]\0AEnvironmentVariable - The environment variable you want to assign.\0APrompt - An optional prompt to display.\0A\0A\00"
@.str.1 = [5 x i8] c"SET \00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [25 x i8] c"Choose a file/directory:\00"
@.str.4 = [3 x i8] c"./\00"
@.str.5 = [28 x i8] c"Couldn't open the directory\00"
@stdscr = global i32 0
@COLS = global i32 0
@LINES = global i32 0
@.str.6 = [7 x i8] c"%d) %s\00"
@.str.7 = [15 x i8] c"%d) First Page\00"
@.str.8 = [18 x i8] c"%d) Previous Page\00"
@.str.9 = [14 x i8] c"%d) Next Page\00"
@.str.10 = [14 x i8] c"%d) Last Page\00"
@.str.11 = [37 x i8] c"Type the number of your selection : \00"
@.str.12 = [2 x i8] c"=\00"
@.str.13 = [12 x i8] c"c:\\temp.bat\00"
@.str.14 = [2 x i8] c"w\00"
@.str.15 = [4 x i8] c"%s\0A\00"
@str = [62 x i8] c"You must not run c:\\temp.bat to set the environment variable.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [255 x i8]
%4 = alloca [255 x i8]
%5 = alloca [1000 x [255 x i8]]
%6 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [1000 x [255 x i8]], [1000 x [255 x i8]]* %5, i64 0, i64 0, i64 0
%9 = icmp slt i32 %0, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 @perror(i8* getelementptr inbounds ([313 x i8], [313 x i8]* @.str, i64 0, i64 0))
br label %177
12: ; preds = %2
%13 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @strcat(i8* %6, i8* %15)
%17 = icmp eq i32 %0, 2
br i1 %17, label %33, label %18
18: ; preds = %12
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = call i32 @strcpy(i8* %7, i8* %20)
%22 = icmp ugt i32 %0, 3
br i1 %22, label %23, label %35
23: ; preds = %18
%24 = zext i32 %0 to i64
br label %25
25: ; preds = %23, %25
%26 = phi i64 [ 3, %23 ], [ %31, %25 ]
%27 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%28 = getelementptr inbounds i8*, i8** %1, i64 %26
%29 = load i8*, i8** %28
%30 = call i32 @strcat(i8* %7, i8* %29)
%31 = add nuw nsw i64 %26, 1
%32 = icmp eq i64 %31, %24
br i1 %32, label %35, label %25
33: ; preds = %12
%34 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %35
35: ; preds = %25, %18, %33
%36 = call i32* @opendir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%37 = icmp eq i32* %36, null
br i1 %37, label %83, label %38
38: ; preds = %35
%39 = call %struct.dirent* @readdir(i32* %36)
%40 = icmp eq %struct.dirent* %39, null
br i1 %40, label %62, label %41
41: ; preds = %38, %53
%42 = phi i64 [ %55, %53 ], [ 0, %38 ]
%43 = phi %struct.dirent* [ %56, %53 ], [ %39, %38 ]
%44 = phi i32 [ %54, %53 ], [ 0, %38 ]
%45 = getelementptr inbounds [1000 x [255 x i8]], [1000 x [255 x i8]]* %5, i64 0, i64 %42, i64 0
%46 = getelementptr inbounds %struct.dirent, %struct.dirent* %43, i64 0, i32 0
%47 = load i8*, i8** %46
%48 = call i32 @strcpy(i8* %45, i8* %47)
%49 = call i32 @strlen(i8* %45)
%50 = icmp sgt i32 %49, %44
br i1 %50, label %51, label %53
51: ; preds = %41
%52 = call i32 @strlen(i8* %45)
br label %53
53: ; preds = %51, %41
%54 = phi i32 [ %52, %51 ], [ %44, %41 ]
%55 = add nuw nsw i64 %42, 1
%56 = call %struct.dirent* @readdir(i32* %36)
%57 = icmp ne %struct.dirent* %56, null
%58 = icmp ult i64 %42, 999
%59 = select i1 %57, i1 %58, i1 false
br i1 %59, label %41, label %60
60: ; preds = %53
%61 = trunc i64 %55 to i32
br label %62
62: ; preds = %60, %38
%63 = phi i32 [ 0, %38 ], [ %54, %60 ]
%64 = phi i32 [ 0, %38 ], [ %61, %60 ]
%65 = call i32 @closedir(i32* %36)
%66 = call i32 (...) @initscr()
%67 = load i32, i32* @stdscr
%68 = call i32 @keypad(i32 %67, i32 1)
%69 = call i32 (...) @noecho()
%70 = add nsw i32 %63, 6
%71 = load i32, i32* @COLS
%72 = sdiv i32 %71, %70
%73 = load i32, i32* @LINES
%74 = add nsw i32 %73, -5
%75 = mul i32 %74, %72
%76 = icmp sgt i32 %75, 0
%77 = add nsw i32 %75, 1
%78 = add nsw i32 %75, 2
%79 = add nsw i32 %75, 3
%80 = add nsw i32 %75, 4
%81 = sext i32 %64 to i64
%82 = zext i32 %75 to i64
br label %85
83: ; preds = %35
%84 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %177
85: ; preds = %156, %62
%86 = phi i32 [ 0, %62 ], [ %176, %156 ]
%87 = call i32 (...) @clear()
%88 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 0, i32 0, i8* %7)
%89 = mul nsw i32 %86, %75
br i1 %76, label %90, label %111
90: ; preds = %85
%91 = sext i32 %89 to i64
br label %92
92: ; preds = %90, %96
%93 = phi i64 [ 0, %90 ], [ %106, %96 ]
%94 = add nsw i64 %93, %91
%95 = icmp slt i64 %94, %81
br i1 %95, label %96, label %111
96: ; preds = %92
%97 = load i32, i32* @LINES
%98 = add nsw i32 %97, -5
%99 = trunc i64 %93 to i32
%100 = srem i32 %99, %98
%101 = add nuw nsw i32 %100, 2
%102 = load i32, i32* @COLS
%103 = sdiv i32 %102, %72
%104 = sdiv i32 %99, %98
%105 = mul nsw i32 %104, %103
%106 = add nuw nsw i64 %93, 1
%107 = getelementptr inbounds [1000 x [255 x i8]], [1000 x [255 x i8]]* %5, i64 0, i64 %94, i64 0
%108 = trunc i64 %106 to i32
%109 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %101, i32 %105, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %108, i8* %107)
%110 = icmp eq i64 %106, %82
br i1 %110, label %111, label %92
111: ; preds = %92, %96, %85
%112 = icmp sgt i32 %86, 0
br i1 %112, label %113, label %120
113: ; preds = %111
%114 = load i32, i32* @LINES
%115 = add nsw i32 %114, -2
%116 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %115, i32 0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 %77)
%117 = load i32, i32* @LINES
%118 = add nsw i32 %117, -2
%119 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %118, i32 20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i32 %78)
br label %120
120: ; preds = %113, %111
%121 = sdiv i32 %64, %75
%122 = icmp slt i32 %86, %121
br i1 %122, label %123, label %130
123: ; preds = %120
%124 = load i32, i32* @LINES
%125 = add nsw i32 %124, -2
%126 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %125, i32 40, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i32 %79)
%127 = load i32, i32* @LINES
%128 = add nsw i32 %127, -2
%129 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %128, i32 60, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i32 %80)
br label %130
130: ; preds = %123, %120
%131 = load i32, i32* @LINES
%132 = add nsw i32 %131, -1
%133 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %132, i32 0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.11, i64 0, i64 0))
%134 = call i32 (...) @refresh()
%135 = call i32 (...) @getint()
%136 = icmp slt i32 %135, 1
%137 = icmp sgt i32 %135, %75
%138 = select i1 %136, i1 true, i1 %137
br i1 %138, label %156, label %139
139: ; preds = %130
%140 = add i32 %89, -1
%141 = add i32 %140, %135
%142 = icmp slt i32 %141, %64
br i1 %142, label %143, label %156
143: ; preds = %139
%144 = call i32 (...) @endwin()
%145 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%146 = sext i32 %141 to i64
%147 = getelementptr inbounds [1000 x [255 x i8]], [1000 x [255 x i8]]* %5, i64 0, i64 %146, i64 0
%148 = call i32 @strcat(i8* %6, i8* %147)
%149 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
%150 = icmp eq i32* %149, null
br i1 %150, label %154, label %151
151: ; preds = %143
%152 = call i32 @fprintf(i32* %149, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0), i8* %6)
%153 = call i32 @fclose(i32* %149)
br label %154
154: ; preds = %151, %143
%155 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str, i64 0, i64 0))
br label %177
156: ; preds = %139, %130
%157 = icmp eq i32 %135, %77
%158 = select i1 %157, i1 %112, i1 false
%159 = select i1 %158, i32 0, i32 %86
%160 = icmp eq i32 %135, %78
%161 = icmp sgt i32 %159, 0
%162 = select i1 %160, i1 %161, i1 false
%163 = sext i1 %162 to i32
%164 = add nsw i32 %159, %163
%165 = icmp eq i32 %135, %79
%166 = add nsw i32 %164, 1
%167 = mul nsw i32 %166, %75
%168 = icmp slt i32 %167, %64
%169 = select i1 %165, i1 %168, i1 false
%170 = select i1 %169, i32 %166, i32 %164
%171 = icmp eq i32 %135, %80
%172 = add nsw i32 %170, 1
%173 = mul nsw i32 %172, %75
%174 = icmp slt i32 %173, %64
%175 = select i1 %171, i1 %174, i1 false
%176 = select i1 %175, i32 %121, i32 %170
br label %85
177: ; preds = %154, %83, %10
%178 = phi i32 [ 1, %10 ], [ 0, %154 ], [ 1, %83 ]
ret i32 %178
}