#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ wdir;
typedef int /*<<< orphan*/ tmp_buf;
struct stat {
  int /*<<< orphan*/ st_mode;
};

/* Variables and functions */
int PATH_MAX;
scalar_t__ S_ISDIR(int /*<<< orphan*/);
int do_choose_file(unsigned char const *, unsigned char *, int *, int);
int /*<<< orphan*/ ncurses_errbox(char *);
int /*<<< orphan*/ os_normalize_path(unsigned char *);
int /*<<< orphan*/ os_rGetWorkingDir(unsigned char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(unsigned char *, size_t, char *, unsigned char *,
                            ...);
scalar_t__ stat(unsigned char *, struct stat *);
int ncurses_choose_file(const unsigned char *header, unsigned char *buf,
                        size_t buf_size, int utf8_mode) {
  unsigned char tmp_buf[PATH_MAX], wdir[PATH_MAX];
  size_t si, di;
  struct stat stbuf;
  int res;
  int view_hidden_flag = 0;
  if (!buf[0]) {
    os_rGetWorkingDir(tmp_buf, sizeof(tmp_buf), 0);
  } else if (buf[0] != '/') {
    os_rGetWorkingDir(wdir, sizeof(wdir), 0);
    snprintf(tmp_buf, sizeof(tmp_buf), "%s/%s", wdir, buf);
  } else {
    snprintf(tmp_buf, sizeof(tmp_buf), "%s", buf);
  }
  os_normalize_path(tmp_buf);
  si = di = 0;
  while (tmp_buf[si]) {
    if (tmp_buf[si] == '/' && tmp_buf[si + 1] == '.' &&
        (!tmp_buf[si + 2] || tmp_buf[si + 2] == '/')) {
      si += 2;
    } else if (tmp_buf[si] == '/' && tmp_buf[si + 1] == '.' &&
               tmp_buf[si + 2] == '.' &&
               (!tmp_buf[si + 3] || tmp_buf[si + 3] == '/')) {
      if (!di || (di == 1 && tmp_buf[0] == '/')) {
        si += 3;
        di = 0;
      } else {
        while (di > 0 && tmp_buf[di - 1] == '/')
          di--;
        while (di > 0 && tmp_buf[di - 1] != '/')
          di--;
        if (di > 0)
          di--;
      }
    } else {
      if (si != di)
        tmp_buf[di] = tmp_buf[si];
      di++, si++;
    }
  }
  tmp_buf[di] = 0;
  while (1) {
    if (stat(tmp_buf, &stbuf) >= 0)
      break;
    while (di > 0 && tmp_buf[di - 1] == '/')
      di--;
    while (di > 0 && tmp_buf[di - 1] != '/')
      di--;
    if (di > 0)
      di--;
    tmp_buf[di] = 0;
    if (!di) {
      ncurses_errbox("\\begin{center}\nERROR!\n\nCannot stat / "
                     "directory!\n\\end{center}\n");
      return -1;
    }
  }
  while (di > 0 && tmp_buf[di - 1] == '/')
    di--;
  if (!di)
    tmp_buf[di++] = '/';
  tmp_buf[di] = 0;
  if (S_ISDIR(stbuf.st_mode)) {
    tmp_buf[di++] = '/';
    tmp_buf[di] = 0;
  }
  while (1) {
    res = do_choose_file(header, tmp_buf, &view_hidden_flag, utf8_mode);
    if (res >= -1)
      break;
  }
  if (res >= 0) {
    snprintf(buf, buf_size, "%s", tmp_buf);
  }
  return res;
}


x86 assembly (clang, -O0):
<ncurses_choose_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    0x2e5f(%rip),%rax
mov    (%rax),%ecx
mov    %rcx,-0x88(%rbp)
mov    %rsp,%rdx
mov    %rdx,-0x30(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x80(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x38(%rbp)
mov    (%rax),%eax
mov    %rax,-0x78(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x60(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    120c <ncurses_choose_file+0x9c>
mov    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%rax
mov    %eax,%esi
xor    %edx,%edx
call   1060 <os_rGetWorkingDir@plt>
jmp    1275 <ncurses_choose_file+0x105>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x2f,%eax
je     1253 <ncurses_choose_file+0xe3>
mov    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rax
mov    %eax,%esi
xor    %edx,%edx
call   1060 <os_rGetWorkingDir@plt>
mov    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%rsi
mov    -0x70(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0xdb9(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
jmp    1270 <ncurses_choose_file+0x100>
mov    -0x88(%rbp),%rsi
mov    -0x80(%rbp),%rdi
mov    -0x18(%rbp),%rcx
lea    0xd9a(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
jmp    1275 <ncurses_choose_file+0x105>
mov    -0x80(%rbp),%rdi
call   1090 <os_normalize_path@plt>
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x80(%rbp),%rax
mov    -0x48(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     14c1 <ncurses_choose_file+0x351>
mov    -0x80(%rbp),%rax
mov    -0x48(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    1305 <ncurses_choose_file+0x195>
mov    -0x80(%rbp),%rax
mov    -0x48(%rbp),%rcx
movzbl 0x1(%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    1305 <ncurses_choose_file+0x195>
mov    -0x80(%rbp),%rax
mov    -0x48(%rbp),%rcx
cmpb   $0x0,0x2(%rax,%rcx,1)
je     12f4 <ncurses_choose_file+0x184>
mov    -0x80(%rbp),%rax
mov    -0x48(%rbp),%rcx
movzbl 0x2(%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    1305 <ncurses_choose_file+0x195>
mov    -0x48(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x48(%rbp)
jmp    14bc <ncurses_choose_file+0x34c>
mov    -0x80(%rbp),%rax
mov    -0x48(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    147f <ncurses_choose_file+0x30f>
mov    -0x80(%rbp),%rax
mov    -0x48(%rbp),%rcx
movzbl 0x1(%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    147f <ncurses_choose_file+0x30f>
mov    -0x80(%rbp),%rax
mov    -0x48(%rbp),%rcx
movzbl 0x2(%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    147f <ncurses_choose_file+0x30f>
mov    -0x80(%rbp),%rax
mov    -0x48(%rbp),%rcx
cmpb   $0x0,0x3(%rax,%rcx,1)
je     136f <ncurses_choose_file+0x1ff>
mov    -0x80(%rbp),%rax
mov    -0x48(%rbp),%rcx
movzbl 0x3(%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    147f <ncurses_choose_file+0x30f>
cmpq   $0x0,-0x50(%rbp)
je     1395 <ncurses_choose_file+0x225>
cmpq   $0x1,-0x50(%rbp)
jne    13ae <ncurses_choose_file+0x23e>
mov    -0x80(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x2f,%eax
jne    13ae <ncurses_choose_file+0x23e>
mov    -0x48(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
jmp    147a <ncurses_choose_file+0x30a>
jmp    13b3 <ncurses_choose_file+0x243>
xor    %eax,%eax
cmpq   $0x0,-0x50(%rbp)
mov    %al,-0x89(%rbp)
jbe    13e2 <ncurses_choose_file+0x272>
mov    -0x80(%rbp),%rax
mov    -0x50(%rbp),%rcx
sub    $0x1,%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
sete   %al
mov    %al,-0x89(%rbp)
mov    -0x89(%rbp),%al
test   $0x1,%al
jne    13f5 <ncurses_choose_file+0x285>
jmp    1406 <ncurses_choose_file+0x296>
mov    -0x50(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x50(%rbp)
jmp    13b3 <ncurses_choose_file+0x243>
jmp    140b <ncurses_choose_file+0x29b>
xor    %eax,%eax
cmpq   $0x0,-0x50(%rbp)
mov    %al,-0x8a(%rbp)
jbe    143a <ncurses_choose_file+0x2ca>
mov    -0x80(%rbp),%rax
mov    -0x50(%rbp),%rcx
sub    $0x1,%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
setne  %al
mov    %al,-0x8a(%rbp)
mov    -0x8a(%rbp),%al
test   $0x1,%al
jne    144d <ncurses_choose_file+0x2dd>
jmp    145e <ncurses_choose_file+0x2ee>
mov    -0x50(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x50(%rbp)
jmp    140b <ncurses_choose_file+0x29b>
cmpq   $0x0,-0x50(%rbp)
jbe    1475 <ncurses_choose_file+0x305>
mov    -0x50(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x50(%rbp)
jmp    147a <ncurses_choose_file+0x30a>
jmp    14b7 <ncurses_choose_file+0x347>
mov    -0x48(%rbp),%rax
cmp    -0x50(%rbp),%rax
je     149f <ncurses_choose_file+0x32f>
mov    -0x80(%rbp),%rax
mov    -0x48(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x50(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    14bc <ncurses_choose_file+0x34c>
jmp    128e <ncurses_choose_file+0x11e>
mov    -0x80(%rbp),%rax
mov    -0x50(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    14d2 <ncurses_choose_file+0x362>
mov    -0x80(%rbp),%rdi
lea    -0x58(%rbp),%rsi
call   1070 <stat@plt>
cmp    $0x0,%rax
jl     14ee <ncurses_choose_file+0x37e>
jmp    15f0 <ncurses_choose_file+0x480>
jmp    14f3 <ncurses_choose_file+0x383>
xor    %eax,%eax
cmpq   $0x0,-0x50(%rbp)
mov    %al,-0x8b(%rbp)
jbe    1522 <ncurses_choose_file+0x3b2>
mov    -0x80(%rbp),%rax
mov    -0x50(%rbp),%rcx
sub    $0x1,%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
sete   %al
mov    %al,-0x8b(%rbp)
mov    -0x8b(%rbp),%al
test   $0x1,%al
jne    1535 <ncurses_choose_file+0x3c5>
jmp    1546 <ncurses_choose_file+0x3d6>
mov    -0x50(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x50(%rbp)
jmp    14f3 <ncurses_choose_file+0x383>
jmp    154b <ncurses_choose_file+0x3db>
xor    %eax,%eax
cmpq   $0x0,-0x50(%rbp)
mov    %al,-0x8c(%rbp)
jbe    157a <ncurses_choose_file+0x40a>
mov    -0x80(%rbp),%rax
mov    -0x50(%rbp),%rcx
sub    $0x1,%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
setne  %al
mov    %al,-0x8c(%rbp)
mov    -0x8c(%rbp),%al
test   $0x1,%al
jne    158d <ncurses_choose_file+0x41d>
jmp    159e <ncurses_choose_file+0x42e>
mov    -0x50(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x50(%rbp)
jmp    154b <ncurses_choose_file+0x3db>
cmpq   $0x0,-0x50(%rbp)
jbe    15b5 <ncurses_choose_file+0x445>
mov    -0x50(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x50(%rbp)
mov    -0x80(%rbp),%rax
mov    -0x50(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
cmpq   $0x0,-0x50(%rbp)
jne    15eb <ncurses_choose_file+0x47b>
lea    0xa33(%rip),%rdi
call   1080 <ncurses_errbox@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x64(%rbp)
jmp    170d <ncurses_choose_file+0x59d>
jmp    14cd <ncurses_choose_file+0x35d>
jmp    15f5 <ncurses_choose_file+0x485>
xor    %eax,%eax
cmpq   $0x0,-0x50(%rbp)
mov    %al,-0x8d(%rbp)
jbe    1624 <ncurses_choose_file+0x4b4>
mov    -0x80(%rbp),%rax
mov    -0x50(%rbp),%rcx
sub    $0x1,%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
sete   %al
mov    %al,-0x8d(%rbp)
mov    -0x8d(%rbp),%al
test   $0x1,%al
jne    1637 <ncurses_choose_file+0x4c7>
jmp    1648 <ncurses_choose_file+0x4d8>
mov    -0x50(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x50(%rbp)
jmp    15f5 <ncurses_choose_file+0x485>
cmpq   $0x0,-0x50(%rbp)
jne    166a <ncurses_choose_file+0x4fa>
mov    -0x80(%rbp),%rax
mov    -0x50(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x50(%rbp)
movb   $0x2f,(%rax,%rcx,1)
mov    -0x80(%rbp),%rax
mov    -0x50(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x58(%rbp),%edi
call   1040 <S_ISDIR@plt>
cmp    $0x0,%rax
je     16a7 <ncurses_choose_file+0x537>
mov    -0x80(%rbp),%rax
mov    -0x50(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x50(%rbp)
movb   $0x2f,(%rax,%rcx,1)
mov    -0x50(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    16ac <ncurses_choose_file+0x53c>
jmp    16b1 <ncurses_choose_file+0x541>
mov    -0x80(%rbp),%rsi
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%ecx
lea    -0x60(%rbp),%rdx
call   1030 <do_choose_file@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0xffffffff,-0x5c(%rbp)
jl     16d7 <ncurses_choose_file+0x567>
jmp    16dc <ncurses_choose_file+0x56c>
jmp    16ac <ncurses_choose_file+0x53c>
cmpl   $0x0,-0x5c(%rbp)
jl     1700 <ncurses_choose_file+0x590>
mov    -0x80(%rbp),%rcx
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    0x90a(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x64(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ncurses_choose_file>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%r13
mov    0x2e65(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%r12
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    %rsp,%r15
sub    %rax,%r15
mov    %r15,%rsp
movl   $0x0,-0x38(%rbp)
mov    (%rsi),%al
cmp    $0x2f,%al
mov    %rdx,-0x48(%rbp)
mov    %rsi,-0x40(%rbp)
mov    %ecx,-0x34(%rbp)
je     11d3 <ncurses_choose_file+0x63>
test   %al,%al
jne    11ef <ncurses_choose_file+0x7f>
mov    %r12,%rdi
mov    %r14d,%esi
xor    %edx,%edx
call   1060 <os_rGetWorkingDir@plt>
jmp    1217 <ncurses_choose_file+0xa7>
mov    %rsi,%rbx
lea    0xe26(%rip),%rdx
mov    %r12,%rdi
mov    %r14,%rsi
mov    %rbx,%rcx
xor    %eax,%eax
call   1050 <snprintf@plt>
jmp    1217 <ncurses_choose_file+0xa7>
mov    %r15,%rdi
mov    %r14d,%esi
xor    %edx,%edx
call   1060 <os_rGetWorkingDir@plt>
lea    0xdfd(%rip),%rdx
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rcx
mov    -0x40(%rbp),%r8
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    %r12,%rdi
call   1090 <os_normalize_path@plt>
xor    %eax,%eax
xor    %r15d,%r15d
jmp    1238 <ncurses_choose_file+0xc8>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r15
add    $0x1,%rax
mov    (%r12,%rax,1),%cl
lea    0x2(%rax),%rdx
lea    0x3(%rax),%r8
jmp    125e <ncurses_choose_file+0xee>
cs nopw 0x0(%rax,%rax,1)
cmp    $0xffffffffffffffff,%rbx
mov    $0x0,%r15d
cmovne %rbx,%r15
cmp    $0x2f,%cl
jne    1300 <ncurses_choose_file+0x190>
cmpb   $0x2e,0x1(%r12,%rax,1)
jne    1304 <ncurses_choose_file+0x194>
mov    (%r12,%rdx,1),%bl
test   %bl,%bl
je     1316 <ncurses_choose_file+0x1a6>
cmp    $0x2f,%bl
je     131e <ncurses_choose_file+0x1ae>
cmpb   $0x2e,0x2(%r12,%rax,1)
jne    1304 <ncurses_choose_file+0x194>
mov    (%r12,%r8,1),%bl
cmp    $0x2f,%bl
je     129d <ncurses_choose_file+0x12d>
test   %bl,%bl
jne    1304 <ncurses_choose_file+0x194>
cmp    $0x1,%r15
je     12b0 <ncurses_choose_file+0x140>
test   %r15,%r15
jne    12b7 <ncurses_choose_file+0x147>
jmp    1326 <ncurses_choose_file+0x1b6>
nopw   0x0(%rax,%rax,1)
cmpb   $0x2f,(%r12)
je     1330 <ncurses_choose_file+0x1c0>
lea    -0x1(%r15),%rsi
mov    %r15,%rbx
xchg   %ax,%ax
mov    %rsi,%rdi
sub    $0x1,%rbx
jb     12e0 <ncurses_choose_file+0x170>
lea    -0x1(%rdi),%rsi
cmpb   $0x2f,-0x1(%r12,%r15,1)
mov    %rbx,%r15
je     12c0 <ncurses_choose_file+0x150>
nopl   0x0(%rax,%rax,1)
mov    %rdi,%rbx
cmp    $0xffffffffffffffff,%rdi
je     1250 <ncurses_choose_file+0xe0>
lea    -0x1(%rbx),%rdi
cmpb   $0x2f,(%r12,%rbx,1)
jne    12e0 <ncurses_choose_file+0x170>
jmp    1250 <ncurses_choose_file+0xe0>
nopl   (%rax)
test   %cl,%cl
je     1338 <ncurses_choose_file+0x1c8>
cmp    %r15,%rax
je     1230 <ncurses_choose_file+0xc0>
mov    %cl,(%r12,%r15,1)
jmp    1230 <ncurses_choose_file+0xc0>
mov    %rdx,%rax
jmp    1238 <ncurses_choose_file+0xc8>
mov    %rdx,%rax
jmp    1238 <ncurses_choose_file+0xc8>
mov    %r8,%rax
jmp    1238 <ncurses_choose_file+0xc8>
xchg   %ax,%ax
mov    %r8,%rax
jmp    1221 <ncurses_choose_file+0xb1>
movb   $0x0,(%r12,%r15,1)
lea    -0x30(%rbp),%r14
mov    %r12,%rdi
mov    %r14,%rsi
call   1070 <stat@plt>
test   %rax,%rax
jns    13c6 <ncurses_choose_file+0x256>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rax
sub    $0x1,%r15
jb     1371 <ncurses_choose_file+0x201>
cmpb   $0x2f,-0x1(%r12,%rax,1)
je     1360 <ncurses_choose_file+0x1f0>
mov    %rax,%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
sub    $0x1,%r15
jb     139d <ncurses_choose_file+0x22d>
cmpb   $0x2f,-0x1(%r12,%rax,1)
mov    %r15,%rax
jne    1380 <ncurses_choose_file+0x210>
movb   $0x0,(%r12,%r15,1)
test   %r15,%r15
jne    1341 <ncurses_choose_file+0x1d1>
jmp    13a2 <ncurses_choose_file+0x232>
movb   $0x0,(%r12)
lea    0xc5d(%rip),%rdi
call   1080 <ncurses_errbox@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0x1,%r15
nopw   0x0(%rax,%rax,1)
cmp    $0x1,%r15
je     13e7 <ncurses_choose_file+0x277>
lea    -0x1(%r15),%r14
cmpb   $0x2f,-0x2(%r12,%r15,1)
mov    %r14,%r15
je     13d0 <ncurses_choose_file+0x260>
jmp    13f2 <ncurses_choose_file+0x282>
movb   $0x2f,(%r12)
mov    $0x1,%r14d
movb   $0x0,(%r12,%r14,1)
mov    -0x30(%rbp),%edi
call   1040 <S_ISDIR@plt>
test   %rax,%rax
je     140b <ncurses_choose_file+0x29b>
movw   $0x2f,(%r12,%r14,1)
lea    -0x38(%rbp),%r15
mov    -0x34(%rbp),%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %ebx,%ecx
call   1030 <do_choose_file@plt>
cmp    $0xffffffff,%eax
jl     1420 <ncurses_choose_file+0x2b0>
mov    %eax,%r14d
test   %eax,%eax
js     13ae <ncurses_choose_file+0x23e>
lea    0xbbc(%rip),%rdx
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    %r12,%rcx
xor    %eax,%eax
call   1050 <snprintf@plt>
jmp    13b4 <ncurses_choose_file+0x244>

LLVM IR (-O0):
%struct.stat = type { i32 }
@PATH_MAX = global i32 0
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [62 x i8] c"\\begin{center}\0AERROR!\0A\0ACannot stat / directory!\0A\\end{center}\0A\00"
define i32 @ncurses_choose_file(i8* %0, i8* %1, i64 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca %struct.stat
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i32 %3, i32* %9
%19 = load i32, i32* @PATH_MAX
%20 = zext i32 %19 to i64
%21 = call i8* @llvm.stacksave()
store i8* %21, i8** %10
%22 = alloca i8, i64 %20
store i64 %20, i64* %11
%23 = load i32, i32* @PATH_MAX
%24 = zext i32 %23 to i64
%25 = alloca i8, i64 %24
store i64 %24, i64* %12
store i32 0, i32* %17
%26 = load i8*, i8** %7
%27 = getelementptr inbounds i8, i8* %26, i64 0
%28 = load i8, i8* %27
%29 = icmp ne i8 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %4
%31 = trunc i64 %20 to i32
%32 = call i32 @os_rGetWorkingDir(i8* %22, i32 %31, i32 0)
br label %48
33: ; preds = %4
%34 = load i8*, i8** %7
%35 = getelementptr inbounds i8, i8* %34, i64 0
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = icmp ne i32 %37, 47
br i1 %38, label %39, label %44
39: ; preds = %33
%40 = trunc i64 %24 to i32
%41 = call i32 @os_rGetWorkingDir(i8* %25, i32 %40, i32 0)
%42 = load i8*, i8** %7
%43 = call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %22, i64 %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %25, i8* %42)
br label %47
44: ; preds = %33
%45 = load i8*, i8** %7
%46 = call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %22, i64 %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %44, %39
br label %48
48: ; preds = %47, %30
%49 = call i32 @os_normalize_path(i8* %22)
store i64 0, i64* %14
store i64 0, i64* %13
br label %50
50: ; preds = %187, %48
%51 = load i64, i64* %13
%52 = getelementptr inbounds i8, i8* %22, i64 %51
%53 = load i8, i8* %52
%54 = icmp ne i8 %53, 0
br i1 %54, label %55, label %188
55: ; preds = %50
%56 = load i64, i64* %13
%57 = getelementptr inbounds i8, i8* %22, i64 %56
%58 = load i8, i8* %57
%59 = zext i8 %58 to i32
%60 = icmp eq i32 %59, 47
br i1 %60, label %61, label %84
61: ; preds = %55
%62 = load i64, i64* %13
%63 = add i64 %62, 1
%64 = getelementptr inbounds i8, i8* %22, i64 %63
%65 = load i8, i8* %64
%66 = zext i8 %65 to i32
%67 = icmp eq i32 %66, 46
br i1 %67, label %68, label %84
68: ; preds = %61
%69 = load i64, i64* %13
%70 = add i64 %69, 2
%71 = getelementptr inbounds i8, i8* %22, i64 %70
%72 = load i8, i8* %71
%73 = icmp ne i8 %72, 0
br i1 %73, label %74, label %81
74: ; preds = %68
%75 = load i64, i64* %13
%76 = add i64 %75, 2
%77 = getelementptr inbounds i8, i8* %22, i64 %76
%78 = load i8, i8* %77
%79 = zext i8 %78 to i32
%80 = icmp eq i32 %79, 47
br i1 %80, label %81, label %84
81: ; preds = %74, %68
%82 = load i64, i64* %13
%83 = add i64 %82, 2
store i64 %83, i64* %13
br label %187
84: ; preds = %74, %61, %55
%85 = load i64, i64* %13
%86 = getelementptr inbounds i8, i8* %22, i64 %85
%87 = load i8, i8* %86
%88 = zext i8 %87 to i32
%89 = icmp eq i32 %88, 47
br i1 %89, label %90, label %171
90: ; preds = %84
%91 = load i64, i64* %13
%92 = add i64 %91, 1
%93 = getelementptr inbounds i8, i8* %22, i64 %92
%94 = load i8, i8* %93
%95 = zext i8 %94 to i32
%96 = icmp eq i32 %95, 46
br i1 %96, label %97, label %171
97: ; preds = %90
%98 = load i64, i64* %13
%99 = add i64 %98, 2
%100 = getelementptr inbounds i8, i8* %22, i64 %99
%101 = load i8, i8* %100
%102 = zext i8 %101 to i32
%103 = icmp eq i32 %102, 46
br i1 %103, label %104, label %171
104: ; preds = %97
%105 = load i64, i64* %13
%106 = add i64 %105, 3
%107 = getelementptr inbounds i8, i8* %22, i64 %106
%108 = load i8, i8* %107
%109 = icmp ne i8 %108, 0
br i1 %109, label %110, label %117
110: ; preds = %104
%111 = load i64, i64* %13
%112 = add i64 %111, 3
%113 = getelementptr inbounds i8, i8* %22, i64 %112
%114 = load i8, i8* %113
%115 = zext i8 %114 to i32
%116 = icmp eq i32 %115, 47
br i1 %116, label %117, label %171
117: ; preds = %110, %104
%118 = load i64, i64* %14
%119 = icmp ne i64 %118, 0
br i1 %119, label %120, label %128
120: ; preds = %117
%121 = load i64, i64* %14
%122 = icmp eq i64 %121, 1
br i1 %122, label %123, label %131
123: ; preds = %120
%124 = getelementptr inbounds i8, i8* %22, i64 0
%125 = load i8, i8* %124
%126 = zext i8 %125 to i32
%127 = icmp eq i32 %126, 47
br i1 %127, label %128, label %131
128: ; preds = %123, %117
%129 = load i64, i64* %13
%130 = add i64 %129, 3
store i64 %130, i64* %13
store i64 0, i64* %14
br label %170
131: ; preds = %123, %120
br label %132
132: ; preds = %144, %131
%133 = load i64, i64* %14
%134 = icmp ugt i64 %133, 0
br i1 %134, label %135, label %142
135: ; preds = %132
%136 = load i64, i64* %14
%137 = sub i64 %136, 1
%138 = getelementptr inbounds i8, i8* %22, i64 %137
%139 = load i8, i8* %138
%140 = zext i8 %139 to i32
%141 = icmp eq i32 %140, 47
br label %142
142: ; preds = %135, %132
%143 = phi i1 [ false, %132 ], [ %141, %135 ]
br i1 %143, label %144, label %147
144: ; preds = %142
%145 = load i64, i64* %14
%146 = add i64 %145, -1
store i64 %146, i64* %14
br label %132
147: ; preds = %142
br label %148
148: ; preds = %160, %147
%149 = load i64, i64* %14
%150 = icmp ugt i64 %149, 0
br i1 %150, label %151, label %158
151: ; preds = %148
%152 = load i64, i64* %14
%153 = sub i64 %152, 1
%154 = getelementptr inbounds i8, i8* %22, i64 %153
%155 = load i8, i8* %154
%156 = zext i8 %155 to i32
%157 = icmp ne i32 %156, 47
br label %158
158: ; preds = %151, %148
%159 = phi i1 [ false, %148 ], [ %157, %151 ]
br i1 %159, label %160, label %163
160: ; preds = %158
%161 = load i64, i64* %14
%162 = add i64 %161, -1
store i64 %162, i64* %14
br label %148
163: ; preds = %158
%164 = load i64, i64* %14
%165 = icmp ugt i64 %164, 0
br i1 %165, label %166, label %169
166: ; preds = %163
%167 = load i64, i64* %14
%168 = add i64 %167, -1
store i64 %168, i64* %14
br label %169
169: ; preds = %166, %163
br label %170
170: ; preds = %169, %128
br label %186
171: ; preds = %110, %97, %90, %84
%172 = load i64, i64* %13
%173 = load i64, i64* %14
%174 = icmp ne i64 %172, %173
br i1 %174, label %175, label %181
175: ; preds = %171
%176 = load i64, i64* %13
%177 = getelementptr inbounds i8, i8* %22, i64 %176
%178 = load i8, i8* %177
%179 = load i64, i64* %14
%180 = getelementptr inbounds i8, i8* %22, i64 %179
store i8 %178, i8* %180
br label %181
181: ; preds = %175, %171
%182 = load i64, i64* %14
%183 = add i64 %182, 1
store i64 %183, i64* %14
%184 = load i64, i64* %13
%185 = add i64 %184, 1
store i64 %185, i64* %13
br label %186
186: ; preds = %181, %170
br label %187
187: ; preds = %186, %81
br label %50
188: ; preds = %50
%189 = load i64, i64* %14
%190 = getelementptr inbounds i8, i8* %22, i64 %189
store i8 0, i8* %190
br label %191
191: ; preds = %241, %188
br label %192
192: ; preds = %191
%193 = call i64 @stat(i8* %22, %struct.stat* %15)
%194 = icmp sge i64 %193, 0
br i1 %194, label %195, label %196
195: ; preds = %192
br label %242
196: ; preds = %192
br label %197
197: ; preds = %209, %196
%198 = load i64, i64* %14
%199 = icmp ugt i64 %198, 0
br i1 %199, label %200, label %207
200: ; preds = %197
%201 = load i64, i64* %14
%202 = sub i64 %201, 1
%203 = getelementptr inbounds i8, i8* %22, i64 %202
%204 = load i8, i8* %203
%205 = zext i8 %204 to i32
%206 = icmp eq i32 %205, 47
br label %207
207: ; preds = %200, %197
%208 = phi i1 [ false, %197 ], [ %206, %200 ]
br i1 %208, label %209, label %212
209: ; preds = %207
%210 = load i64, i64* %14
%211 = add i64 %210, -1
store i64 %211, i64* %14
br label %197
212: ; preds = %207
br label %213
213: ; preds = %225, %212
%214 = load i64, i64* %14
%215 = icmp ugt i64 %214, 0
br i1 %215, label %216, label %223
216: ; preds = %213
%217 = load i64, i64* %14
%218 = sub i64 %217, 1
%219 = getelementptr inbounds i8, i8* %22, i64 %218
%220 = load i8, i8* %219
%221 = zext i8 %220 to i32
%222 = icmp ne i32 %221, 47
br label %223
223: ; preds = %216, %213
%224 = phi i1 [ false, %213 ], [ %222, %216 ]
br i1 %224, label %225, label %228
225: ; preds = %223
%226 = load i64, i64* %14
%227 = add i64 %226, -1
store i64 %227, i64* %14
br label %213
228: ; preds = %223
%229 = load i64, i64* %14
%230 = icmp ugt i64 %229, 0
br i1 %230, label %231, label %234
231: ; preds = %228
%232 = load i64, i64* %14
%233 = add i64 %232, -1
store i64 %233, i64* %14
br label %234
234: ; preds = %231, %228
%235 = load i64, i64* %14
%236 = getelementptr inbounds i8, i8* %22, i64 %235
store i8 0, i8* %236
%237 = load i64, i64* %14
%238 = icmp ne i64 %237, 0
br i1 %238, label %241, label %239
239: ; preds = %234
%240 = call i32 @ncurses_errbox(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %5
store i32 1, i32* %18
br label %297
241: ; preds = %234
br label %191
242: ; preds = %195
br label %243
243: ; preds = %255, %242
%244 = load i64, i64* %14
%245 = icmp ugt i64 %244, 0
br i1 %245, label %246, label %253
246: ; preds = %243
%247 = load i64, i64* %14
%248 = sub i64 %247, 1
%249 = getelementptr inbounds i8, i8* %22, i64 %248
%250 = load i8, i8* %249
%251 = zext i8 %250 to i32
%252 = icmp eq i32 %251, 47
br label %253
253: ; preds = %246, %243
%254 = phi i1 [ false, %243 ], [ %252, %246 ]
br i1 %254, label %255, label %258
255: ; preds = %253
%256 = load i64, i64* %14
%257 = add i64 %256, -1
store i64 %257, i64* %14
br label %243
258: ; preds = %253
%259 = load i64, i64* %14
%260 = icmp ne i64 %259, 0
br i1 %260, label %265, label %261
261: ; preds = %258
%262 = load i64, i64* %14
%263 = add i64 %262, 1
store i64 %263, i64* %14
%264 = getelementptr inbounds i8, i8* %22, i64 %262
store i8 47, i8* %264
br label %265
265: ; preds = %261, %258
%266 = load i64, i64* %14
%267 = getelementptr inbounds i8, i8* %22, i64 %266
store i8 0, i8* %267
%268 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 0
%269 = load i32, i32* %268
%270 = call i64 @S_ISDIR(i32 %269)
%271 = icmp ne i64 %270, 0
br i1 %271, label %272, label %278
272: ; preds = %265
%273 = load i64, i64* %14
%274 = add i64 %273, 1
store i64 %274, i64* %14
%275 = getelementptr inbounds i8, i8* %22, i64 %273
store i8 47, i8* %275
%276 = load i64, i64* %14
%277 = getelementptr inbounds i8, i8* %22, i64 %276
store i8 0, i8* %277
br label %278
278: ; preds = %272, %265
br label %279
279: ; preds = %287, %278
br label %280
280: ; preds = %279
%281 = load i8*, i8** %6
%282 = load i32, i32* %9
%283 = call i32 @do_choose_file(i8* %281, i8* %22, i32* %17, i32 %282)
store i32 %283, i32* %16
%284 = load i32, i32* %16
%285 = icmp sge i32 %284, -1
br i1 %285, label %286, label %287
286: ; preds = %280
br label %288
287: ; preds = %280
br label %279
288: ; preds = %286
%289 = load i32, i32* %16
%290 = icmp sge i32 %289, 0
br i1 %290, label %291, label %295
291: ; preds = %288
%292 = load i8*, i8** %7
%293 = load i64, i64* %8
%294 = call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %292, i64 %293, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %22)
br label %295
295: ; preds = %291, %288
%296 = load i32, i32* %16
store i32 %296, i32* %5
store i32 1, i32* %18
br label %297
297: ; preds = %295, %239
%298 = load i8*, i8** %10
%299 = load i32, i32* %5
ret i32 %299
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@PATH_MAX = global i32 0
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [62 x i8] c"\\begin{center}\0AERROR!\0A\0ACannot stat / directory!\0A\\end{center}\0A\00"
define i32 @ncurses_choose_file(i8* %0, i8* %1, i64 %2, i32 %3) {
%5 = alloca %struct.stat
%6 = alloca i32
%7 = load i32, i32* @PATH_MAX
%8 = zext i32 %7 to i64
%9 = alloca i8, i64 %8
%10 = alloca i8, i64 %8
%11 = bitcast %struct.stat* %5 to i8*
%12 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%13 = load i8, i8* %1
switch i8 %13, label %16 [
i8 0, label %14
i8 47, label %19
]
14: ; preds = %4
%15 = call i32 @os_rGetWorkingDir(i8* %9, i32 %7, i32 0)
br label %21
16: ; preds = %4
%17 = call i32 @os_rGetWorkingDir(i8* %10, i32 %7, i32 0)
%18 = call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %9, i64 %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %1)
br label %21
19: ; preds = %4
%20 = call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %9, i64 %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %21
21: ; preds = %16, %19, %14
%22 = call i32 @os_normalize_path(i8* %9)
br label %23
23: ; preds = %80, %21
%24 = phi i64 [ 0, %21 ], [ %81, %80 ]
%25 = phi i64 [ 0, %21 ], [ %82, %80 ]
%26 = getelementptr inbounds i8, i8* %9, i64 %24
%27 = load i8, i8* %26
%28 = add i64 %24, 1
%29 = getelementptr inbounds i8, i8* %9, i64 %28
%30 = add i64 %24, 2
%31 = getelementptr inbounds i8, i8* %9, i64 %30
%32 = add i64 %24, 2
%33 = getelementptr inbounds i8, i8* %9, i64 %32
%34 = add i64 %24, 3
%35 = getelementptr inbounds i8, i8* %9, i64 %34
br label %36
36: ; preds = %23, %70
%37 = phi i64 [ %72, %70 ], [ %25, %23 ]
switch i8 %27, label %73 [
i8 0, label %83
i8 47, label %38
]
38: ; preds = %36
%39 = load i8, i8* %29
%40 = icmp eq i8 %39, 46
br i1 %40, label %41, label %73
41: ; preds = %38
%42 = load i8, i8* %31
switch i8 %42, label %43 [
i8 0, label %80
i8 47, label %80
]
43: ; preds = %41
%44 = load i8, i8* %33
%45 = icmp eq i8 %44, 46
br i1 %45, label %46, label %73
46: ; preds = %43
%47 = load i8, i8* %35
switch i8 %47, label %73 [
i8 0, label %48
i8 47, label %48
]
48: ; preds = %46, %46
switch i64 %37, label %52 [
i64 0, label %80
i64 1, label %49
]
49: ; preds = %48
%50 = load i8, i8* %9
%51 = icmp eq i8 %50, 47
br i1 %51, label %80, label %52
52: ; preds = %48, %49
br label %53
53: ; preds = %52, %56
%54 = phi i64 [ %57, %56 ], [ %37, %52 ]
%55 = icmp eq i64 %54, 0
br i1 %55, label %61, label %56
56: ; preds = %53
%57 = add i64 %54, -1
%58 = getelementptr inbounds i8, i8* %9, i64 %57
%59 = load i8, i8* %58
%60 = icmp eq i8 %59, 47
br i1 %60, label %53, label %61
61: ; preds = %53, %56
br label %62
62: ; preds = %61, %65
%63 = phi i64 [ %66, %65 ], [ %54, %61 ]
%64 = icmp eq i64 %63, 0
br i1 %64, label %70, label %65
65: ; preds = %62
%66 = add i64 %63, -1
%67 = getelementptr inbounds i8, i8* %9, i64 %66
%68 = load i8, i8* %67
%69 = icmp eq i8 %68, 47
br i1 %69, label %70, label %62
70: ; preds = %65, %62
%71 = add i64 %63, -1
%72 = select i1 %64, i64 0, i64 %71
br label %36
73: ; preds = %38, %36, %46, %43
%74 = icmp eq i64 %24, %37
br i1 %74, label %77, label %75
75: ; preds = %73
%76 = getelementptr inbounds i8, i8* %9, i64 %37
store i8 %27, i8* %76
br label %77
77: ; preds = %75, %73
%78 = add i64 %37, 1
%79 = add i64 %24, 1
br label %80
80: ; preds = %49, %48, %41, %41, %77
%81 = phi i64 [ %79, %77 ], [ %30, %41 ], [ %30, %41 ], [ %34, %48 ], [ %34, %49 ]
%82 = phi i64 [ %78, %77 ], [ %37, %41 ], [ %37, %41 ], [ %37, %48 ], [ 0, %49 ]
br label %23
83: ; preds = %36
%84 = getelementptr inbounds i8, i8* %9, i64 %37
store i8 0, i8* %84
br label %85
85: ; preds = %107, %83
%86 = phi i64 [ %37, %83 ], [ %103, %107 ]
%87 = call i64 @stat(i8* %9, %struct.stat* %5)
%88 = icmp sgt i64 %87, -1
br i1 %88, label %112, label %89
89: ; preds = %85, %92
%90 = phi i64 [ %93, %92 ], [ %86, %85 ]
%91 = icmp eq i64 %90, 0
br i1 %91, label %97, label %92
92: ; preds = %89
%93 = add i64 %90, -1
%94 = getelementptr inbounds i8, i8* %9, i64 %93
%95 = load i8, i8* %94
%96 = icmp eq i8 %95, 47
br i1 %96, label %89, label %97
97: ; preds = %89, %92
br label %98
98: ; preds = %97, %102
%99 = phi i64 [ %103, %102 ], [ %90, %97 ]
%100 = icmp eq i64 %99, 0
br i1 %100, label %101, label %102
101: ; preds = %98
store i8 0, i8* %9
br label %110
102: ; preds = %98
%103 = add i64 %99, -1
%104 = getelementptr inbounds i8, i8* %9, i64 %103
%105 = load i8, i8* %104
%106 = icmp eq i8 %105, 47
br i1 %106, label %107, label %98
107: ; preds = %102
%108 = getelementptr inbounds i8, i8* %9, i64 %103
store i8 0, i8* %108
%109 = icmp eq i64 %103, 0
br i1 %109, label %110, label %85
110: ; preds = %107, %101
%111 = call i32 @ncurses_errbox(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0))
br label %139
112: ; preds = %85, %115
%113 = phi i64 [ %116, %115 ], [ %86, %85 ]
%114 = icmp eq i64 %113, 0
br i1 %114, label %120, label %115
115: ; preds = %112
%116 = add i64 %113, -1
%117 = getelementptr inbounds i8, i8* %9, i64 %116
%118 = load i8, i8* %117
%119 = icmp eq i8 %118, 47
br i1 %119, label %112, label %121
120: ; preds = %112
store i8 47, i8* %9
br label %121
121: ; preds = %115, %120
%122 = phi i64 [ 1, %120 ], [ %113, %115 ]
%123 = getelementptr inbounds i8, i8* %9, i64 %122
store i8 0, i8* %123
%124 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 0
%125 = load i32, i32* %124
%126 = call i64 @S_ISDIR(i32 %125)
%127 = icmp eq i64 %126, 0
br i1 %127, label %131, label %128
128: ; preds = %121
%129 = add i64 %122, 1
store i8 47, i8* %123
%130 = getelementptr inbounds i8, i8* %9, i64 %129
store i8 0, i8* %130
br label %131
131: ; preds = %128, %121
br label %132
132: ; preds = %131, %132
%133 = call i32 @do_choose_file(i8* %0, i8* %9, i32* %6, i32 %3)
%134 = icmp sgt i32 %133, -2
br i1 %134, label %135, label %132
135: ; preds = %132
%136 = icmp sgt i32 %133, -1
br i1 %136, label %137, label %139
137: ; preds = %135
%138 = call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %1, i64 %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %139
139: ; preds = %135, %137, %110
%140 = phi i32 [ -1, %110 ], [ %133, %137 ], [ -1, %135 ]
ret i32 %140
}