#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 char *pathbuff;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
char *getcwd(char *, int);
int /*<<< orphan*/ memmove(char *, char *, int);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
char *strchr(char *, char);
int strlen(char *);
char *strrchr(char *, char);
int strspn(char *, char *);
char *presentwd(int nsub) {
  static char pathbuff[256];
  FILE *pwd = NULL;
  char *path = NULL;
  int wdmethod = 1;
  if (wdmethod == 1) {
    if ((path = getcwd(pathbuff, 255)) == NULL)
      goto end_of_job;
    if ((pathbuff) != NULL) {
      int thislen = strlen(pathbuff);
      while (--thislen >= 0)
        if ((((pathbuff)[thislen]) != '\000' &&
             !((" \t\n\r\f\v") == NULL
                   ? 1
                   : (*(" \t\n\r\f\v") == '\000' ? 1 : 0)) &&
             strchr((" \t\n\r\f\v"), ((pathbuff)[thislen])) != (char *)NULL))
          (pathbuff)[thislen] = '\000';
        else
          break;
      if ((thislen = strspn((pathbuff), " \t\n\r\f\v")) > 0) {
        if ((thislen) != 0) {
          if (!((((pathbuff))) == NULL ? 1
                                       : (*(((pathbuff))) == '\000' ? 1 : 0))) {
            int thislen3 = strlen((pathbuff));
            if ((thislen) >= thislen3)
              *((pathbuff)) = '\000';
            else
              memmove(((pathbuff)), ((pathbuff)) + (thislen),
                      1 + thislen3 - (thislen));
          }
        } else
          ;
      }
    } else
      ;
  }
  if (wdmethod == 2) {
    if ((pwd = popen("pwd", "r")) == NULL)
      goto end_of_job;
    *pathbuff = '\000';
    while (fgets(pathbuff, 255, pwd) != NULL) {
      if ((pathbuff) != NULL) {
        int thislen = strlen(pathbuff);
        while (--thislen >= 0)
          if ((((pathbuff)[thislen]) != '\000' &&
               !((" \t\n\r\f\v") == NULL
                     ? 1
                     : (*(" \t\n\r\f\v") == '\000' ? 1 : 0)) &&
               strchr((" \t\n\r\f\v"), ((pathbuff)[thislen])) != (char *)NULL))
            (pathbuff)[thislen] = '\000';
          else
            break;
        if ((thislen = strspn((pathbuff), " \t\n\r\f\v")) > 0) {
          if ((thislen) != 0) {
            if (!((((pathbuff))) == NULL
                      ? 1
                      : (*(((pathbuff))) == '\000' ? 1 : 0))) {
              int thislen3 = strlen((pathbuff));
              if ((thislen) >= thislen3)
                *((pathbuff)) = '\000';
              else
                memmove(((pathbuff)), ((pathbuff)) + (thislen),
                        1 + thislen3 - (thislen));
            }
          } else
            ;
        }
      } else
        ;
      if (strlen(pathbuff) > 0)
        break;
    }
    pclose(pwd);
  }
  if (nsub > 0) {
    if ((((pathbuff) == NULL ? 1 : (*(pathbuff) == '\000' ? 1 : 0))
             ? '\000'
             : *((((pathbuff) == NULL ? 1 : (*(pathbuff) == '\000' ? 1 : 0))
                      ? NULL
                      : ((pathbuff) + (strlen(pathbuff) - 1))))) == '/')
      *(((pathbuff) == NULL ? 1 : (*(pathbuff) == '\000' ? 1 : 0))
            ? NULL
            : ((pathbuff) + (strlen(pathbuff) - 1))) = '\000';
    while (nsub > 0) {
      char *slash = strrchr(pathbuff, '/');
      if (slash == NULL)
        break;
      *slash = '\000';
      nsub--;
    }
  }
  if ((((pathbuff) == NULL ? 1 : (*(pathbuff) == '\000' ? 1 : 0))
           ? '\000'
           : *((((pathbuff) == NULL ? 1 : (*(pathbuff) == '\000' ? 1 : 0))
                    ? NULL
                    : ((pathbuff) + (strlen(pathbuff) - 1))))) != '/')
    strcat(pathbuff, "/");
  path = pathbuff;
end_of_job:
  return (path);
}


x86 assembly (clang, -O0):
<presentwd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    1344 <presentwd+0x1a4>
lea    0x2ead(%rip),%rdi
mov    $0xff,%esi
call   1070 <getcwd@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11f0 <presentwd+0x50>
jmp    17cb <presentwd+0x62b>
lea    0x2e89(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jl     126c <presentwd+0xcc>
movslq -0x20(%rbp),%rcx
lea    0x2e64(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1262 <presentwd+0xc2>
movslq -0x20(%rbp),%rcx
lea    0xdcc(%rip),%rdi
lea    0x2e45(%rip),%rax
movsbl (%rax,%rcx,1),%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     1262 <presentwd+0xc2>
movslq -0x20(%rbp),%rcx
lea    0x2e27(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
jmp    1267 <presentwd+0xc7>
jmp    126c <presentwd+0xcc>
jmp    11ff <presentwd+0x5f>
lea    0x2e0d(%rip),%rdi
lea    0xd86(%rip),%rsi
call   1080 <strspn@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jle    133f <presentwd+0x19f>
cmpl   $0x0,-0x20(%rbp)
je     1335 <presentwd+0x195>
xor    %eax,%eax
test   $0x1,%al
jne    12a4 <presentwd+0x104>
jmp    12b3 <presentwd+0x113>
mov    $0x1,%al
test   $0x1,%al
jne    1330 <presentwd+0x190>
jmp    12e1 <presentwd+0x141>
movsbl 0x2dc6(%rip),%eax
cmp    $0x0,%eax
jne    12d2 <presentwd+0x132>
mov    $0x1,%al
test   $0x1,%al
jne    1330 <presentwd+0x190>
jmp    12e1 <presentwd+0x141>
xor    %eax,%eax
test   $0x1,%al
jne    1330 <presentwd+0x190>
jmp    12e1 <presentwd+0x141>
lea    0x2d98(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jl     1308 <presentwd+0x168>
movb   $0x0,0x2d7d(%rip)
jmp    132b <presentwd+0x18b>
movslq -0x20(%rbp),%rax
lea    0x2d6d(%rip),%rsi
add    %rax,%rsi
mov    -0x24(%rbp),%edx
add    $0x1,%edx
sub    -0x20(%rbp),%edx
lea    0x2d5a(%rip),%rdi
call   10a0 <memmove@plt>
jmp    1330 <presentwd+0x190>
jmp    133a <presentwd+0x19a>
jmp    133a <presentwd+0x19a>
jmp    133f <presentwd+0x19f>
jmp    1344 <presentwd+0x1a4>
cmpl   $0x2,-0x1c(%rbp)
jne    1511 <presentwd+0x371>
lea    0xcb2(%rip),%rdi
lea    0xcaf(%rip),%rsi
call   10b0 <popen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1374 <presentwd+0x1d4>
jmp    17cb <presentwd+0x62b>
movb   $0x0,0x2d05(%rip)
mov    -0x10(%rbp),%rdx
lea    0x2cfa(%rip),%rdi
mov    $0xff,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     1508 <presentwd+0x368>
lea    0x2cdf(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jl     1416 <presentwd+0x276>
movslq -0x28(%rbp),%rcx
lea    0x2cba(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     140c <presentwd+0x26c>
movslq -0x28(%rbp),%rcx
lea    0xc22(%rip),%rdi
lea    0x2c9b(%rip),%rax
movsbl (%rax,%rcx,1),%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     140c <presentwd+0x26c>
movslq -0x28(%rbp),%rcx
lea    0x2c7d(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
jmp    1411 <presentwd+0x271>
jmp    1416 <presentwd+0x276>
jmp    13a9 <presentwd+0x209>
lea    0x2c63(%rip),%rdi
lea    0xbdc(%rip),%rsi
call   1080 <strspn@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jle    14e9 <presentwd+0x349>
cmpl   $0x0,-0x28(%rbp)
je     14df <presentwd+0x33f>
xor    %eax,%eax
test   $0x1,%al
jne    144e <presentwd+0x2ae>
jmp    145d <presentwd+0x2bd>
mov    $0x1,%al
test   $0x1,%al
jne    14da <presentwd+0x33a>
jmp    148b <presentwd+0x2eb>
movsbl 0x2c1c(%rip),%eax
cmp    $0x0,%eax
jne    147c <presentwd+0x2dc>
mov    $0x1,%al
test   $0x1,%al
jne    14da <presentwd+0x33a>
jmp    148b <presentwd+0x2eb>
xor    %eax,%eax
test   $0x1,%al
jne    14da <presentwd+0x33a>
jmp    148b <presentwd+0x2eb>
lea    0x2bee(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jl     14b2 <presentwd+0x312>
movb   $0x0,0x2bd3(%rip)
jmp    14d5 <presentwd+0x335>
movslq -0x28(%rbp),%rax
lea    0x2bc3(%rip),%rsi
add    %rax,%rsi
mov    -0x2c(%rbp),%edx
add    $0x1,%edx
sub    -0x28(%rbp),%edx
lea    0x2bb0(%rip),%rdi
call   10a0 <memmove@plt>
jmp    14da <presentwd+0x33a>
jmp    14e4 <presentwd+0x344>
jmp    14e4 <presentwd+0x344>
jmp    14e9 <presentwd+0x349>
lea    0x2b90(%rip),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jle    1503 <presentwd+0x363>
jmp    1508 <presentwd+0x368>
jmp    137b <presentwd+0x1db>
mov    -0x10(%rbp),%rdi
call   1050 <pclose@plt>
cmpl   $0x0,-0x4(%rbp)
jle    16ca <presentwd+0x52a>
xor    %eax,%eax
test   $0x1,%al
jne    152a <presentwd+0x38a>
jmp    1539 <presentwd+0x399>
mov    $0x1,%al
test   $0x1,%al
jne    1567 <presentwd+0x3c7>
jmp    1571 <presentwd+0x3d1>
movsbl 0x2b40(%rip),%eax
cmp    $0x0,%eax
jne    1558 <presentwd+0x3b8>
mov    $0x1,%al
test   $0x1,%al
jne    1567 <presentwd+0x3c7>
jmp    1571 <presentwd+0x3d1>
xor    %eax,%eax
test   $0x1,%al
jne    1567 <presentwd+0x3c7>
jmp    1571 <presentwd+0x3d1>
xor    %eax,%eax
mov    %eax,-0x3c(%rbp)
jmp    15f2 <presentwd+0x452>
xor    %eax,%eax
test   $0x1,%al
jne    1580 <presentwd+0x3e0>
jmp    158f <presentwd+0x3ef>
mov    $0x1,%al
test   $0x1,%al
jne    15bd <presentwd+0x41d>
jmp    15c8 <presentwd+0x428>
movsbl 0x2aea(%rip),%eax
cmp    $0x0,%eax
jne    15ae <presentwd+0x40e>
mov    $0x1,%al
test   $0x1,%al
jne    15bd <presentwd+0x41d>
jmp    15c8 <presentwd+0x428>
xor    %eax,%eax
test   $0x1,%al
jne    15bd <presentwd+0x41d>
jmp    15c8 <presentwd+0x428>
xor    %eax,%eax
mov    %rax,-0x48(%rbp)
jmp    15e8 <presentwd+0x448>
lea    0x2ab1(%rip),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
movslq %eax,%rcx
lea    0x2a9f(%rip),%rax
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    $0x2f,%eax
jne    167c <presentwd+0x4dc>
xor    %eax,%eax
test   $0x1,%al
jne    160d <presentwd+0x46d>
jmp    161c <presentwd+0x47c>
mov    $0x1,%al
test   $0x1,%al
jne    164a <presentwd+0x4aa>
jmp    1655 <presentwd+0x4b5>
movsbl 0x2a5d(%rip),%eax
cmp    $0x0,%eax
jne    163b <presentwd+0x49b>
mov    $0x1,%al
test   $0x1,%al
jne    164a <presentwd+0x4aa>
jmp    1655 <presentwd+0x4b5>
xor    %eax,%eax
test   $0x1,%al
jne    164a <presentwd+0x4aa>
jmp    1655 <presentwd+0x4b5>
xor    %eax,%eax
mov    %rax,-0x50(%rbp)
jmp    1675 <presentwd+0x4d5>
lea    0x2a24(%rip),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
movslq %eax,%rcx
lea    0x2a12(%rip),%rax
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
movb   $0x0,(%rax)
jmp    1681 <presentwd+0x4e1>
cmpl   $0x0,-0x4(%rbp)
jle    16c5 <presentwd+0x525>
lea    0x29ee(%rip),%rdi
mov    $0x2f,%esi
call   1060 <strrchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    16b0 <presentwd+0x510>
jmp    16c5 <presentwd+0x525>
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1681 <presentwd+0x4e1>
jmp    16ca <presentwd+0x52a>
xor    %eax,%eax
test   $0x1,%al
jne    16d9 <presentwd+0x539>
jmp    16e8 <presentwd+0x548>
mov    $0x1,%al
test   $0x1,%al
jne    1716 <presentwd+0x576>
jmp    1720 <presentwd+0x580>
movsbl 0x2991(%rip),%eax
cmp    $0x0,%eax
jne    1707 <presentwd+0x567>
mov    $0x1,%al
test   $0x1,%al
jne    1716 <presentwd+0x576>
jmp    1720 <presentwd+0x580>
xor    %eax,%eax
test   $0x1,%al
jne    1716 <presentwd+0x576>
jmp    1720 <presentwd+0x580>
xor    %eax,%eax
mov    %eax,-0x54(%rbp)
jmp    17a1 <presentwd+0x601>
xor    %eax,%eax
test   $0x1,%al
jne    172f <presentwd+0x58f>
jmp    173e <presentwd+0x59e>
mov    $0x1,%al
test   $0x1,%al
jne    176c <presentwd+0x5cc>
jmp    1777 <presentwd+0x5d7>
movsbl 0x293b(%rip),%eax
cmp    $0x0,%eax
jne    175d <presentwd+0x5bd>
mov    $0x1,%al
test   $0x1,%al
jne    176c <presentwd+0x5cc>
jmp    1777 <presentwd+0x5d7>
xor    %eax,%eax
test   $0x1,%al
jne    176c <presentwd+0x5cc>
jmp    1777 <presentwd+0x5d7>
xor    %eax,%eax
mov    %rax,-0x60(%rbp)
jmp    1797 <presentwd+0x5f7>
lea    0x2902(%rip),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
movslq %eax,%rcx
lea    0x28f0(%rip),%rax
add    %rcx,%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    $0x2f,%eax
je     17c0 <presentwd+0x620>
lea    0x28cc(%rip),%rdi
lea    0x852(%rip),%rsi
call   10c0 <strcat@plt>
lea    0x28b9(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<presentwd>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r12d
lea    0x2eee(%rip),%rdi
mov    $0xff,%esi
call   1060 <getcwd@plt>
test   %rax,%rax
je     12a1 <presentwd+0x131>
lea    0x2ed4(%rip),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11eb <presentwd+0x7b>
mov    %eax,%ebp
add    $0x1,%rbp
lea    0xe4b(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
lea    -0x2(%rbp),%ebx
movzbl (%rbx,%r14,1),%eax
test   %al,%al
je     11eb <presentwd+0x7b>
movsbl %al,%esi
mov    %r15,%rdi
call   1040 <strchr@plt>
test   %rax,%rax
je     11eb <presentwd+0x7b>
movb   $0x0,(%rbx,%r14,1)
add    $0xffffffffffffffff,%rbp
cmp    $0x1,%rbp
ja     11c0 <presentwd+0x50>
lea    0x2e7e(%rip),%r14
lea    0xe07(%rip),%rsi
mov    %r14,%rdi
call   1070 <strspn@plt>
test   %eax,%eax
jle    123b <presentwd+0xcb>
cmpb   $0x0,0x2e64(%rip)
je     123b <presentwd+0xcb>
mov    %eax,%ebp
lea    0x2e59(%rip),%r15
mov    %r15,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebp
jge    12a6 <presentwd+0x136>
mov    %ebp,%esi
add    %r15,%rsi
sub    %ebp,%eax
add    $0x1,%eax
mov    %r15,%rdi
mov    %eax,%edx
call   1080 <memmove@plt>
test   %r12d,%r12d
jle    12b2 <presentwd+0x142>
cmpb   $0x0,0x2e29(%rip)
je     1270 <presentwd+0x100>
lea    0x2e20(%rip),%rbp
mov    %rbp,%rdi
call   1030 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%rbp,1)
jne    1270 <presentwd+0x100>
mov    %rbp,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbp,1)
add    $0x1,%r12d
lea    0x2df5(%rip),%rbp
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
je     12b2 <presentwd+0x142>
movb   $0x0,(%rax)
add    $0xffffffff,%r12d
cmp    $0x1,%r12d
jg     1280 <presentwd+0x110>
jmp    12b2 <presentwd+0x142>
xor    %r14d,%r14d
jmp    12e3 <presentwd+0x173>
movb   $0x0,0x2dc3(%rip)
test   %r12d,%r12d
jg     1240 <presentwd+0xd0>
cmpb   $0x0,0x2db7(%rip)
je     12cd <presentwd+0x15d>
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%r14,1)
je     12e3 <presentwd+0x173>
lea    0x2d9c(%rip),%r14
lea    0xd2c(%rip),%rsi
mov    %r14,%rdi
call   1090 <strcat@plt>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@presentwd.pathbuff = internal global [256 x i8] zeroinitializer
@.str = [7 x i8] c" \09\0A\0D\0C\0B\00"
@.str.3 = [2 x i8] c"/\00"
define i8* @presentwd(i32 %0) {
%2 = tail call i8* @getcwd(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @presentwd.pathbuff, i64 0, i64 0), i32 255)
%3 = icmp eq i8* %2, null
br i1 %3, label %76, label %4
4: ; preds = %1
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @presentwd.pathbuff, i64 0, i64 0))
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %21
7: ; preds = %4
%8 = zext i32 %5 to i64
br label %9
9: ; preds = %7, %19
%10 = phi i64 [ %8, %7 ], [ %11, %19 ]
%11 = add nsw i64 %10, -1
%12 = and i64 %11, 4294967295
%13 = getelementptr inbounds [256 x i8], [256 x i8]* @presentwd.pathbuff, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %21, label %16
16: ; preds = %9
%17 = tail call i8* @strchr(i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %14)
%18 = icmp eq i8* %17, null
br i1 %18, label %21, label %19
19: ; preds = %16
store i8 0, i8* %13
%20 = icmp ugt i64 %10, 1
br i1 %20, label %9, label %21
21: ; preds = %19, %16, %9, %4
%22 = tail call i32 @strspn(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @presentwd.pathbuff, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%23 = icmp slt i32 %22, 1
%24 = load i8, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @presentwd.pathbuff, i64 0, i64 0)
%25 = icmp eq i8 %24, 0
%26 = select i1 %23, i1 true, i1 %25
br i1 %26, label %37, label %27
27: ; preds = %21
%28 = tail call i32 @strlen(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @presentwd.pathbuff, i64 0, i64 0))
%29 = icmp slt i32 %22, %28
br i1 %29, label %31, label %30
30: ; preds = %27
store i8 0, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @presentwd.pathbuff, i64 0, i64 0)
br label %37
31: ; preds = %27
%32 = zext i32 %22 to i64
%33 = getelementptr inbounds [256 x i8], [256 x i8]* @presentwd.pathbuff, i64 0, i64 %32
%34 = sub nsw i32 1, %22
%35 = add i32 %34, %28
%36 = tail call i32 @memmove(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @presentwd.pathbuff, i64 0, i64 0), i8* %33, i32 %35)
br label %37
37: ; preds = %30, %31, %21
%38 = icmp sgt i32 %0, 0
br i1 %38, label %39, label %64
39: ; preds = %37
%40 = load i8, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @presentwd.pathbuff, i64 0, i64 0)
%41 = icmp eq i8 %40, 0
br i1 %41, label %56, label %42
42: ; preds = %39
%43 = tail call i32 @strlen(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @presentwd.pathbuff, i64 0, i64 0))
%44 = add nsw i32 %43, -1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [256 x i8], [256 x i8]* @presentwd.pathbuff, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = icmp eq i8 %47, 47
br i1 %48, label %49, label %56
49: ; preds = %42
%50 = load i8, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @presentwd.pathbuff, i64 0, i64 0)
%51 = icmp ne i8 %50, 0
tail call void @llvm.assume(i1 %51)
%52 = tail call i32 @strlen(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @presentwd.pathbuff, i64 0, i64 0))
%53 = add nsw i32 %52, -1
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [256 x i8], [256 x i8]* @presentwd.pathbuff, i64 0, i64 %54
store i8 0, i8* %55
br label %56
56: ; preds = %42, %49, %39
br label %57
57: ; preds = %56, %61
%58 = phi i32 [ %62, %61 ], [ %0, %56 ]
%59 = tail call i8* @strrchr(i8* dereferenceable(1) getelementptr inbounds ([256 x i8], [256 x i8]* @presentwd.pathbuff, i64 0, i64 0), i8 signext 47)
%60 = icmp eq i8* %59, null
br i1 %60, label %64, label %61
61: ; preds = %57
store i8 0, i8* %59
%62 = add nsw i32 %58, -1
%63 = icmp sgt i32 %58, 1
br i1 %63, label %57, label %64
64: ; preds = %61, %57, %37
%65 = load i8, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @presentwd.pathbuff, i64 0, i64 0)
%66 = icmp eq i8 %65, 0
br i1 %66, label %74, label %67
67: ; preds = %64
%68 = tail call i32 @strlen(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @presentwd.pathbuff, i64 0, i64 0))
%69 = add nsw i32 %68, -1
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [256 x i8], [256 x i8]* @presentwd.pathbuff, i64 0, i64 %70
%72 = load i8, i8* %71
%73 = icmp eq i8 %72, 47
br i1 %73, label %76, label %74
74: ; preds = %64, %67
%75 = tail call i32 @strcat(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @presentwd.pathbuff, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %76
76: ; preds = %67, %74, %1
%77 = phi i8* [ null, %1 ], [ getelementptr inbounds ([256 x i8], [256 x i8]* @presentwd.pathbuff, i64 0, i64 0), %74 ], [ getelementptr inbounds ([256 x i8], [256 x i8]* @presentwd.pathbuff, i64 0, i64 0), %67 ]
ret i8* %77
}