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

/* Forward declarations */

/* Type definitions */
struct stat {
  int st_mode;
};

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
scalar_t__ S_ISREG(int);
int /*<<< orphan*/ abort();
int backup(char const *, int);
int chdir(char const *);
int /*<<< orphan*/ close(int);
int fchdir(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ ftpcmd(char *, int /*<<< orphan*/);
int /*<<< orphan*/ ftpcmd_pipeline(char *, char *);
int lstat(char const *, struct stat *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char const *);
int /*<<< orphan*/ stderr;
char *strchr(char const *, char);
scalar_t__ strcmp(char *, char *);
char *strdup(char const *);
int walk1(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int walk(const char *name) {
  struct stat sb;
  int r, fd, wd;
  char *s, *p, *q;
  int need_up;
  if (lstat(name, &sb) == -1) {
    perror(name);
    return 0;
  }
  if (S_ISREG(sb.st_mode)) {
    if (strchr(name, '/') == 0)
      return backup(name, sb.st_mode & 0111);
    fprintf(stderr, "Not implemented XXX\n");
    return 0;
  }
  wd = open(".", O_RDONLY);
  if (wd == -1)
    abort();
  if (chdir(name) == -1) {
    perror(name);
    return 0;
  }
  while (*name == '/')
    name++;
  need_up = 0;
  if (*name) {
    q = s = strdup(name);
    if (!q)
      abort();
    do {
      p = strchr(q, '/');
      if (p)
        *p = '\0';
      if (strcmp(q, "..") == 0) {
        need_up--;
        ftpcmd_pipeline("CDUP", 0);
      } else if (strcmp(q, ".") != 0) {
        ftpcmd_pipeline("MKD", q);
        ftpcmd_pipeline("CWD", q);
        need_up++;
      }
      if (p) {
        *p = '/';
        q = p + 1;
      }
    } while (p);
    (void)ftpcmd("PWD", 0);
  }
  fd = open(".", O_RDONLY);
  r = walk1(fd, NULL, NULL);
  (void)close(fd);
  while (need_up > 0) {
    ftpcmd_pipeline("CDUP", 0);
    need_up--;
  }
  (void)ftpcmd("PWD", 0);
  if (fchdir(wd) == -1)
    abort();
  (void)close(wd);
  return r;
}


x86 assembly (clang, -O0):
<walk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <lstat@plt>
cmp    $0xffffffff,%eax
jne    1237 <walk+0x37>
mov    -0x10(%rbp),%rdi
call   1110 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    14b9 <walk+0x2b9>
mov    -0x18(%rbp),%edi
call   10c0 <S_ISREG@plt>
cmp    $0x0,%rax
je     1299 <walk+0x99>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
jne    1278 <walk+0x78>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
and    $0x49,%esi
call   10b0 <backup@plt>
mov    %eax,-0x4(%rbp)
jmp    14b9 <walk+0x2b9>
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
lea    0xd78(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    14b9 <walk+0x2b9>
mov    0x2d48(%rip),%rax
mov    (%rax),%esi
lea    0xd6d(%rip),%rdi
call   10f0 <open@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    12c2 <walk+0xc2>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x10(%rbp),%rdi
call   1040 <chdir@plt>
cmp    $0xffffffff,%eax
jne    12e9 <walk+0xe9>
mov    -0x10(%rbp),%rdi
call   1110 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    14b9 <walk+0x2b9>
jmp    12ee <walk+0xee>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    130f <walk+0x10f>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    12ee <walk+0xee>
movl   $0x0,-0x44(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     142b <walk+0x22b>
mov    -0x10(%rbp),%rdi
call   1120 <strdup@plt>
mov    %rax,-0x30(%rbp)
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1346 <walk+0x146>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    134b <walk+0x14b>
mov    -0x40(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     136f <walk+0x16f>
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x40(%rbp),%rdi
lea    0xc9b(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    13a7 <walk+0x1a7>
mov    -0x44(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x44(%rbp)
lea    0xc7f(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10d0 <ftpcmd_pipeline@plt>
jmp    13ef <walk+0x1ef>
mov    -0x40(%rbp),%rdi
lea    0xc64(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     13ea <walk+0x1ea>
mov    -0x40(%rbp),%rsi
lea    0xc51(%rip),%rdi
call   10d0 <ftpcmd_pipeline@plt>
mov    -0x40(%rbp),%rsi
lea    0xc45(%rip),%rdi
call   10d0 <ftpcmd_pipeline@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    13ef <walk+0x1ef>
cmpq   $0x0,-0x38(%rbp)
je     140d <walk+0x20d>
mov    -0x38(%rbp),%rax
movb   $0x2f,(%rax)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1412 <walk+0x212>
cmpq   $0x0,-0x38(%rbp)
jne    134b <walk+0x14b>
lea    0xc01(%rip),%rdi
xor    %esi,%esi
call   1100 <ftpcmd@plt>
mov    0x2bb6(%rip),%rax
mov    (%rax),%esi
lea    0xbdb(%rip),%rdi
call   10f0 <open@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   10a0 <walk1@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
call   1060 <close@plt>
cmpl   $0x0,-0x44(%rbp)
jle    1485 <walk+0x285>
lea    0xbaa(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10d0 <ftpcmd_pipeline@plt>
mov    -0x44(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x44(%rbp)
jmp    145d <walk+0x25d>
lea    0xb99(%rip),%rdi
xor    %esi,%esi
call   1100 <ftpcmd@plt>
mov    -0x24(%rbp),%edi
call   10e0 <fchdir@plt>
cmp    $0xffffffff,%eax
jne    14ab <walk+0x2ab>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<walk>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    %rsp,%rsi
call   1070 <lstat@plt>
cmp    $0xffffffff,%eax
je     1287 <walk+0x87>
mov    (%rsp),%ebp
mov    %ebp,%edi
call   10c0 <S_ISREG@plt>
test   %rax,%rax
je     1258 <walk+0x58>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     12b7 <walk+0xb7>
mov    0x2d95(%rip),%rax
mov    (%rax),%edi
lea    0xdb4(%rip),%rsi
call   1090 <fprintf@plt>
xor    %ebx,%ebx
jmp    1427 <walk+0x227>
mov    0x2d89(%rip),%rbp
mov    0x0(%rbp),%esi
lea    0xdad(%rip),%rdi
call   10f0 <open@plt>
cmp    $0xffffffff,%eax
je     1438 <walk+0x238>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1040 <chdir@plt>
cmp    $0xffffffff,%eax
jne    12a4 <walk+0xa4>
mov    %rbx,%rdi
call   1110 <perror@plt>
xor    %ebx,%ebx
jmp    1427 <walk+0x227>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x2f,%al
je     12a0 <walk+0xa0>
test   %al,%al
jne    12d2 <walk+0xd2>
xor    %r12d,%r12d
jmp    13b1 <walk+0x1b1>
and    $0x49,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10b0 <backup@plt>
mov    %r14d,0x4(%rsp)
mov    %rbx,%rdi
call   1120 <strdup@plt>
test   %rax,%rax
je     1438 <walk+0x238>
mov    %rax,%r15
xor    %r12d,%r12d
lea    0xd20(%rip),%rbx
lea    0xd1a(%rip),%rbp
lea    0xd1e(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
mov    %rax,%r14
test   %rax,%rax
je     1329 <walk+0x129>
movb   $0x0,(%r14)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1370 <walk+0x170>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1367 <walk+0x167>
lea    0xccd(%rip),%rdi
mov    %r15,%rsi
call   10d0 <ftpcmd_pipeline@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   10d0 <ftpcmd_pipeline@plt>
add    $0x1,%r12d
test   %r14,%r14
jne    1387 <walk+0x187>
jmp    1397 <walk+0x197>
xchg   %ax,%ax
add    $0xffffffff,%r12d
lea    0xc9d(%rip),%rdi
xor    %esi,%esi
call   10d0 <ftpcmd_pipeline@plt>
test   %r14,%r14
je     1397 <walk+0x197>
movb   $0x2f,(%r14)
add    $0x1,%r14
mov    %r14,%r15
jmp    1310 <walk+0x110>
lea    0xc87(%rip),%rdi
xor    %esi,%esi
call   1100 <ftpcmd@plt>
mov    0x4(%rsp),%r14d
mov    0x2c37(%rip),%rbp
mov    0x0(%rbp),%esi
lea    0xc5b(%rip),%rdi
call   10f0 <open@plt>
mov    %eax,%ebp
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <walk1@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1060 <close@plt>
test   %r12d,%r12d
jle    1404 <walk+0x204>
add    $0x1,%r12d
lea    0xc32(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%rdi
xor    %esi,%esi
call   10d0 <ftpcmd_pipeline@plt>
add    $0xffffffff,%r12d
cmp    $0x1,%r12d
ja     13f0 <walk+0x1f0>
lea    0xc1a(%rip),%rdi
xor    %esi,%esi
call   1100 <ftpcmd@plt>
mov    %r14d,%edi
call   10e0 <fchdir@plt>
cmp    $0xffffffff,%eax
je     1438 <walk+0x238>
mov    %r14d,%edi
call   1060 <close@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [21 x i8] c"Not implemented XXX\0A\00"
@.str.1 = [2 x i8] c".\00"
@O_RDONLY = global i32 0
@.str.2 = [3 x i8] c"..\00"
@.str.3 = [5 x i8] c"CDUP\00"
@.str.4 = [4 x i8] c"MKD\00"
@.str.5 = [4 x i8] c"CWD\00"
@.str.6 = [4 x i8] c"PWD\00"
define i32 @walk(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.stat
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
store i8* %0, i8** %3
%12 = load i8*, i8** %3
%13 = call i32 @lstat(i8* %12, %struct.stat* %4)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %18
15: ; preds = %1
%16 = load i8*, i8** %3
%17 = call i32 @perror(i8* %16)
store i32 0, i32* %2
br label %136
18: ; preds = %1
%19 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%20 = load i32, i32* %19
%21 = call i64 @S_ISREG(i32 %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %36
23: ; preds = %18
%24 = load i8*, i8** %3
%25 = call i8* @strchr(i8* %24, i8 signext 47)
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %33
27: ; preds = %23
%28 = load i8*, i8** %3
%29 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%30 = load i32, i32* %29
%31 = and i32 %30, 73
%32 = call i32 @backup(i8* %28, i32 %31)
store i32 %32, i32* %2
br label %136
33: ; preds = %23
%34 = load i32, i32* @stderr
%35 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %136
36: ; preds = %18
%37 = load i32, i32* @O_RDONLY
%38 = call i32 @open(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %37)
store i32 %38, i32* %7
%39 = load i32, i32* %7
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %43
41: ; preds = %36
%42 = call i32 (...) @abort()
unreachable
43: ; preds = %36
%44 = load i8*, i8** %3
%45 = call i32 @chdir(i8* %44)
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %50
47: ; preds = %43
%48 = load i8*, i8** %3
%49 = call i32 @perror(i8* %48)
store i32 0, i32* %2
br label %136
50: ; preds = %43
br label %51
51: ; preds = %56, %50
%52 = load i8*, i8** %3
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 47
br i1 %55, label %56, label %59
56: ; preds = %51
%57 = load i8*, i8** %3
%58 = getelementptr inbounds i8, i8* %57, i32 1
store i8* %58, i8** %3
br label %51
59: ; preds = %51
store i32 0, i32* %11
%60 = load i8*, i8** %3
%61 = load i8, i8* %60
%62 = icmp ne i8 %61, 0
br i1 %62, label %63, label %111
63: ; preds = %59
%64 = load i8*, i8** %3
%65 = call i8* @strdup(i8* %64)
store i8* %65, i8** %8
store i8* %65, i8** %10
%66 = load i8*, i8** %10
%67 = icmp ne i8* %66, null
br i1 %67, label %70, label %68
68: ; preds = %63
%69 = call i32 (...) @abort()
unreachable
70: ; preds = %63
br label %71
71: ; preds = %106, %70
%72 = load i8*, i8** %10
%73 = call i8* @strchr(i8* %72, i8 signext 47)
store i8* %73, i8** %9
%74 = load i8*, i8** %9
%75 = icmp ne i8* %74, null
br i1 %75, label %76, label %78
76: ; preds = %71
%77 = load i8*, i8** %9
store i8 0, i8* %77
br label %78
78: ; preds = %76, %71
%79 = load i8*, i8** %10
%80 = call i64 @strcmp(i8* %79, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%81 = icmp eq i64 %80, 0
br i1 %81, label %82, label %86
82: ; preds = %78
%83 = load i32, i32* %11
%84 = add nsw i32 %83, -1
store i32 %84, i32* %11
%85 = call i32 @ftpcmd_pipeline(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* null)
br label %98
86: ; preds = %78
%87 = load i8*, i8** %10
%88 = call i64 @strcmp(i8* %87, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%89 = icmp ne i64 %88, 0
br i1 %89, label %90, label %97
90: ; preds = %86
%91 = load i8*, i8** %10
%92 = call i32 @ftpcmd_pipeline(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %91)
%93 = load i8*, i8** %10
%94 = call i32 @ftpcmd_pipeline(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %93)
%95 = load i32, i32* %11
%96 = add nsw i32 %95, 1
store i32 %96, i32* %11
br label %97
97: ; preds = %90, %86
br label %98
98: ; preds = %97, %82
%99 = load i8*, i8** %9
%100 = icmp ne i8* %99, null
br i1 %100, label %101, label %105
101: ; preds = %98
%102 = load i8*, i8** %9
store i8 47, i8* %102
%103 = load i8*, i8** %9
%104 = getelementptr inbounds i8, i8* %103, i64 1
store i8* %104, i8** %10
br label %105
105: ; preds = %101, %98
br label %106
106: ; preds = %105
%107 = load i8*, i8** %9
%108 = icmp ne i8* %107, null
br i1 %108, label %71, label %109
109: ; preds = %106
%110 = call i32 @ftpcmd(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 0)
br label %111
111: ; preds = %109, %59
%112 = load i32, i32* @O_RDONLY
%113 = call i32 @open(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %112)
store i32 %113, i32* %6
%114 = load i32, i32* %6
%115 = call i32 @walk1(i32 %114, i32* null, i32* null)
store i32 %115, i32* %5
%116 = load i32, i32* %6
%117 = call i32 @close(i32 %116)
br label %118
118: ; preds = %121, %111
%119 = load i32, i32* %11
%120 = icmp sgt i32 %119, 0
br i1 %120, label %121, label %125
121: ; preds = %118
%122 = call i32 @ftpcmd_pipeline(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* null)
%123 = load i32, i32* %11
%124 = add nsw i32 %123, -1
store i32 %124, i32* %11
br label %118
125: ; preds = %118
%126 = call i32 @ftpcmd(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 0)
%127 = load i32, i32* %7
%128 = call i32 @fchdir(i32 %127)
%129 = icmp eq i32 %128, -1
br i1 %129, label %130, label %132
130: ; preds = %125
%131 = call i32 (...) @abort()
unreachable
132: ; preds = %125
%133 = load i32, i32* %7
%134 = call i32 @close(i32 %133)
%135 = load i32, i32* %5
store i32 %135, i32* %2
br label %136
136: ; preds = %132, %47, %33, %27, %15
%137 = load i32, i32* %2
ret i32 %137
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [21 x i8] c"Not implemented XXX\0A\00"
@.str.1 = [2 x i8] c".\00"
@O_RDONLY = global i32 0
@.str.2 = [3 x i8] c"..\00"
@.str.3 = [5 x i8] c"CDUP\00"
@.str.4 = [4 x i8] c"MKD\00"
@.str.5 = [4 x i8] c"CWD\00"
@.str.6 = [4 x i8] c"PWD\00"
define i32 @walk(i8* %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
%4 = call i32 @lstat(i8* %0, %struct.stat* %2)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @perror(i8* %0)
br label %88
8: ; preds = %1
%9 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%10 = load i32, i32* %9
%11 = tail call i64 @S_ISREG(i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %22, label %13
13: ; preds = %8
%14 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 47)
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = and i32 %10, 73
%18 = tail call i32 @backup(i8* %0, i32 %17)
br label %88
19: ; preds = %13
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %88
22: ; preds = %8
%23 = load i32, i32* @O_RDONLY
%24 = tail call i32 @open(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = tail call i32 (...) @abort()
unreachable
28: ; preds = %22
%29 = tail call i32 @chdir(i8* %0)
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = tail call i32 @perror(i8* %0)
br label %88
33: ; preds = %28, %36
%34 = phi i8* [ %37, %36 ], [ %0, %28 ]
%35 = load i8, i8* %34
switch i8 %35, label %38 [
i8 47, label %36
i8 0, label %68
]
36: ; preds = %33
%37 = getelementptr inbounds i8, i8* %34, i64 1
br label %33
38: ; preds = %33
%39 = tail call i8* @strdup(i8* %34)
%40 = icmp eq i8* %39, null
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = tail call i32 (...) @abort()
unreachable
43: ; preds = %38, %64
%44 = phi i8* [ %65, %64 ], [ %39, %38 ]
%45 = phi i32 [ %63, %64 ], [ 0, %38 ]
%46 = tail call i8* @strchr(i8* dereferenceable(1) %44, i8 signext 47)
%47 = icmp eq i8* %46, null
br i1 %47, label %49, label %48
48: ; preds = %43
store i8 0, i8* %46
br label %49
49: ; preds = %48, %43
%50 = tail call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = add nsw i32 %45, -1
%54 = tail call i32 @ftpcmd_pipeline(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* null)
br label %62
55: ; preds = %49
%56 = tail call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %62, label %58
58: ; preds = %55
%59 = tail call i32 @ftpcmd_pipeline(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %44)
%60 = tail call i32 @ftpcmd_pipeline(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %44)
%61 = add nsw i32 %45, 1
br label %62
62: ; preds = %55, %58, %52
%63 = phi i32 [ %53, %52 ], [ %61, %58 ], [ %45, %55 ]
br i1 %47, label %66, label %64
64: ; preds = %62
store i8 47, i8* %46
%65 = getelementptr inbounds i8, i8* %46, i64 1
br label %43
66: ; preds = %62
%67 = tail call i32 @ftpcmd(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 0)
br label %68
68: ; preds = %33, %66
%69 = phi i32 [ %63, %66 ], [ 0, %33 ]
%70 = load i32, i32* @O_RDONLY
%71 = tail call i32 @open(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %70)
%72 = tail call i32 @walk1(i32 %71, i32* null, i32* null)
%73 = tail call i32 @close(i32 %71)
%74 = icmp sgt i32 %69, 0
br i1 %74, label %75, label %80
75: ; preds = %68, %75
%76 = phi i32 [ %78, %75 ], [ %69, %68 ]
%77 = tail call i32 @ftpcmd_pipeline(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* null)
%78 = add nsw i32 %76, -1
%79 = icmp ugt i32 %76, 1
br i1 %79, label %75, label %80
80: ; preds = %75, %68
%81 = tail call i32 @ftpcmd(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 0)
%82 = tail call i32 @fchdir(i32 %24)
%83 = icmp eq i32 %82, -1
br i1 %83, label %84, label %86
84: ; preds = %80
%85 = tail call i32 (...) @abort()
unreachable
86: ; preds = %80
%87 = tail call i32 @close(i32 %24)
br label %88
88: ; preds = %86, %31, %19, %16, %6
%89 = phi i32 [ 0, %6 ], [ %18, %16 ], [ 0, %19 ], [ 0, %31 ], [ %72, %86 ]
ret i32 %89
}