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

/* Variables and functions */
int /*<<< orphan*/ PATH_MAX;
scalar_t__ S_ISDIR(int /*<<< orphan*/);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int cp_file(char *, char *);
scalar_t__ create_dir(char const *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ is_dir(char const *);
scalar_t__ lstat(char *, struct stat *);
int /*<<< orphan*/ *opendir(char const *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ readdir_r(int /*<<< orphan*/ *, struct dirent *, struct dirent **);
int /*<<< orphan*/ sprintf(char *, char *, char const *, char *);
scalar_t__ strcmp(char *, char *);
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ strncat(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strncpy(char *, char const *, int /*<<< orphan*/);
int cp_dir(const char *source, const char *dest) {
  DIR *dir;
  struct dirent entry;
  struct dirent *result;
  struct stat entryInfo;
  char path_name[PATH_MAX + 1];
  char path_new[PATH_MAX + 1];
  int ret = 0;
  if (source == NULL || dest == NULL)
    return -1;
  if (!is_dir(source))
    return -1;
  if (create_dir(dest) != 0)
    return -1;
  if ((dir = opendir(source)) == NULL) {
    printf("Couldn't open %s : %s\n", source, strerror(errno));
    return -1;
  }
  while ((readdir_r(dir, &entry, &result) == 0) && result != 0) {
    if (strcmp(entry.d_name, ".") == 0 || strcmp(entry.d_name, "..") == 0) {
      continue;
    }
    strncpy(path_name, source, PATH_MAX);
    strncat(path_name, "/", PATH_MAX);
    strncat(path_name, entry.d_name, PATH_MAX);
    sprintf(path_new, "%s/%s", dest, entry.d_name);
    if (lstat(path_name, &entryInfo) == 0) {
      if (S_ISDIR(entryInfo.st_mode)) {
        if (create_dir(path_new) != 0)
          printf("erreur de creation de dir\n");
        if ((ret = cp_dir(path_name, path_new)) < 0)
          goto err_dir;
      } else {
        if ((ret = cp_file(path_name, path_new)) < 0)
          goto err_file;
      }
    }
  }
  return 0;
err_dir:
  printf("Couldn't copy dir\n");
  closedir(dir);
  return ret;
err_file:
  printf("Couldn't copy file\n");
  closedir(dir);
  return ret;
}


x86 assembly (clang, -O0):
<cp_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2de6(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %rsp,%rdx
mov    %rdx,-0x40(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x68(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x48(%rbp)
mov    (%rax),%eax
add    $0x1,%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1270 <cp_dir+0x80>
cmpq   $0x0,-0x18(%rbp)
jne    1283 <cp_dir+0x93>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x58(%rbp)
jmp    14f6 <cp_dir+0x306>
mov    -0x10(%rbp),%rdi
call   1080 <is_dir@plt>
cmp    $0x0,%eax
jne    12a8 <cp_dir+0xb8>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x58(%rbp)
jmp    14f6 <cp_dir+0x306>
mov    -0x18(%rbp),%rdi
call   10d0 <create_dir@plt>
cmp    $0x0,%rax
je     12ce <cp_dir+0xde>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x58(%rbp)
jmp    14f6 <cp_dir+0x306>
mov    -0x10(%rbp),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1323 <cp_dir+0x133>
mov    -0x10(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    0x2ce4(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x70(%rbp),%rsi
mov    %rax,%rdx
lea    0xcf7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x58(%rbp)
jmp    14f6 <cp_dir+0x306>
jmp    1328 <cp_dir+0x138>
mov    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1040 <readdir_r@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x71(%rbp)
jne    1356 <cp_dir+0x166>
cmpq   $0x0,-0x30(%rbp)
setne  %al
mov    %al,-0x71(%rbp)
mov    -0x71(%rbp),%al
test   $0x1,%al
jne    1366 <cp_dir+0x176>
jmp    1496 <cp_dir+0x2a6>
mov    -0x28(%rbp),%rdi
lea    0xca7(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
je     139a <cp_dir+0x1aa>
mov    -0x28(%rbp),%rdi
lea    0xc8c(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    139f <cp_dir+0x1af>
jmp    1328 <cp_dir+0x138>
mov    -0x68(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2c42(%rip),%rax
mov    (%rax),%edx
call   1030 <strncpy@plt>
mov    -0x68(%rbp),%rdi
mov    0x2c30(%rip),%rax
mov    (%rax),%edx
lea    0xc51(%rip),%rsi
call   1090 <strncat@plt>
mov    -0x68(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    0x2c13(%rip),%rax
mov    (%rax),%edx
call   1090 <strncat@plt>
mov    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xc25(%rip),%rsi
call   1100 <sprintf@plt>
mov    -0x68(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   10b0 <lstat@plt>
cmp    $0x0,%rax
jne    1491 <cp_dir+0x2a1>
mov    -0x38(%rbp),%edi
call   1070 <S_ISDIR@plt>
cmp    $0x0,%rax
je     1469 <cp_dir+0x279>
mov    -0x60(%rbp),%rdi
call   10d0 <create_dir@plt>
cmp    $0x0,%rax
je     1446 <cp_dir+0x256>
lea    0xbe3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x60(%rbp),%rsi
mov    -0x68(%rbp),%rdi
call   10e0 <cp_dir@plt>
mov    %eax,-0x54(%rbp)
cmp    $0x0,%eax
jge    1464 <cp_dir+0x274>
jmp    14a9 <cp_dir+0x2b9>
jmp    148c <cp_dir+0x29c>
mov    -0x60(%rbp),%rsi
mov    -0x68(%rbp),%rdi
call   10f0 <cp_file@plt>
mov    %eax,-0x54(%rbp)
cmp    $0x0,%eax
jge    1487 <cp_dir+0x297>
jmp    14d2 <cp_dir+0x2e2>
jmp    148c <cp_dir+0x29c>
jmp    1491 <cp_dir+0x2a1>
jmp    1328 <cp_dir+0x138>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x58(%rbp)
jmp    14f6 <cp_dir+0x306>
lea    0xb8d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   10a0 <closedir@plt>
mov    -0x54(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x58(%rbp)
jmp    14f6 <cp_dir+0x306>
lea    0xb77(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   10a0 <closedir@plt>
mov    -0x54(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x58(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cp_dir>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsp,%r14
mov    0x2dd5(%rip),%rcx
mov    (%rcx),%eax
add    $0x1,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    (%rcx),%eax
add    $0x1,%eax
mov    %rsp,%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    $0xffffffff,%ecx
test   %rdi,%rdi
je     1277 <cp_dir+0x77>
mov    %rsi,%r15
test   %rsi,%rsi
je     1277 <cp_dir+0x77>
mov    %rdi,%r12
call   1090 <is_dir@plt>
test   %eax,%eax
je     1272 <cp_dir+0x72>
mov    %r15,%rdi
call   10e0 <create_dir@plt>
test   %rax,%rax
je     128b <cp_dir+0x8b>
mov    $0xffffffff,%ecx
mov    %r14,%rsp
mov    %ecx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r12,%rdi
call   1060 <opendir@plt>
test   %rax,%rax
je     13dc <cp_dir+0x1dc>
lea    -0x30(%rbp),%rsi
lea    -0x50(%rbp),%rdx
mov    %rax,-0x40(%rbp)
mov    %rax,%rdi
call   1050 <readdir_r@plt>
xor    %ecx,%ecx
test   %rax,%rax
jne    1277 <cp_dir+0x77>
cmpq   $0x0,-0x50(%rbp)
je     1277 <cp_dir+0x77>
mov    %r14,-0x38(%rbp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    -0x30(%rbp),%rdi
lea    0xd3d(%rip),%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     13b0 <cp_dir+0x1b0>
mov    -0x30(%rbp),%rdi
lea    0xd23(%rip),%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     13b0 <cp_dir+0x1b0>
mov    0x2ce7(%rip),%r14
mov    (%r14),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <strncpy@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
lea    0xcf6(%rip),%rsi
call   10a0 <strncat@plt>
mov    -0x30(%rbp),%rsi
mov    (%r14),%edx
mov    %rbx,%rdi
call   10a0 <strncat@plt>
mov    -0x30(%rbp),%rcx
mov    %r13,%rdi
lea    0xcd6(%rip),%rsi
mov    %r15,%rdx
call   1110 <sprintf@plt>
mov    %rbx,%rdi
lea    -0x48(%rbp),%rsi
call   10c0 <lstat@plt>
test   %rax,%rax
jne    13b0 <cp_dir+0x1b0>
mov    -0x48(%rbp),%edi
call   1080 <S_ISDIR@plt>
test   %rax,%rax
je     1396 <cp_dir+0x196>
mov    %r13,%rdi
call   10e0 <create_dir@plt>
test   %rax,%rax
je     1385 <cp_dir+0x185>
lea    0xcc7(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10f0 <cp_dir@plt>
test   %eax,%eax
jns    13b0 <cp_dir+0x1b0>
jmp    1403 <cp_dir+0x203>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1100 <cp_file@plt>
test   %eax,%eax
js     140f <cp_dir+0x20f>
cs nopw 0x0(%rax,%rax,1)
nop
mov    -0x40(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1050 <readdir_r@plt>
test   %rax,%rax
jne    13d1 <cp_dir+0x1d1>
cmpq   $0x0,-0x50(%rbp)
jne    12d0 <cp_dir+0xd0>
mov    -0x38(%rbp),%r14
xor    %ecx,%ecx
jmp    1277 <cp_dir+0x77>
mov    0x2bf5(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xc0f(%rip),%rdi
mov    %r12,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1272 <cp_dir+0x72>
mov    %eax,%r14d
lea    0xc28(%rip),%rdi
jmp    1419 <cp_dir+0x219>
mov    %eax,%r14d
lea    0xc09(%rip),%rdi
call   1040 <puts@plt>
mov    -0x40(%rbp),%rdi
call   10b0 <closedir@plt>
mov    %r14d,%ecx
mov    -0x38(%rbp),%r14
jmp    1277 <cp_dir+0x77>

LLVM IR (-O0):
%struct.dirent = type { i8* }
%struct.stat = type { i32 }
@PATH_MAX = global i32 0
@.str = [23 x i8] c"Couldn't open %s : %s\0A\00"
@errno = global i32 0
@.str.1 = [2 x i8] c".\00"
@.str.2 = [3 x i8] c"..\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [6 x i8] c"%s/%s\00"
@.str.5 = [27 x i8] c"erreur de creation de dir\0A\00"
@.str.6 = [19 x i8] c"Couldn't copy dir\0A\00"
@.str.7 = [20 x i8] c"Couldn't copy file\0A\00"
define i32 @cp_dir(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca %struct.dirent
%8 = alloca %struct.dirent*
%9 = alloca %struct.stat
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i32
%14 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%15 = load i32, i32* @PATH_MAX
%16 = add nsw i32 %15, 1
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %10
%19 = alloca i8, i64 %17
store i64 %17, i64* %11
%20 = load i32, i32* @PATH_MAX
%21 = add nsw i32 %20, 1
%22 = zext i32 %21 to i64
%23 = alloca i8, i64 %22
store i64 %22, i64* %12
store i32 0, i32* %13
%24 = load i8*, i8** %4
%25 = icmp eq i8* %24, null
br i1 %25, label %29, label %26
26: ; preds = %2
%27 = load i8*, i8** %5
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %30
29: ; preds = %26, %2
store i32 -1, i32* %3
store i32 1, i32* %14
br label %119
30: ; preds = %26
%31 = load i8*, i8** %4
%32 = call i32 @is_dir(i8* %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %35, label %34
34: ; preds = %30
store i32 -1, i32* %3
store i32 1, i32* %14
br label %119
35: ; preds = %30
%36 = load i8*, i8** %5
%37 = call i64 @create_dir(i8* %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %35
store i32 -1, i32* %3
store i32 1, i32* %14
br label %119
40: ; preds = %35
%41 = load i8*, i8** %4
%42 = call i32* @opendir(i8* %41)
store i32* %42, i32** %6
%43 = icmp eq i32* %42, null
br i1 %43, label %44, label %49
44: ; preds = %40
%45 = load i8*, i8** %4
%46 = load i32, i32* @errno
%47 = call i8* @strerror(i32 %46)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %45, i8* %47)
store i32 -1, i32* %3
store i32 1, i32* %14
br label %119
49: ; preds = %40
br label %50
50: ; preds = %107, %69, %49
%51 = load i32*, i32** %6
%52 = call i64 @readdir_r(i32* %51, %struct.dirent* %7, %struct.dirent** %8)
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %50
%55 = load %struct.dirent*, %struct.dirent** %8
%56 = icmp ne %struct.dirent* %55, null
br label %57
57: ; preds = %54, %50
%58 = phi i1 [ false, %50 ], [ %56, %54 ]
br i1 %58, label %59, label %108
59: ; preds = %57
%60 = getelementptr inbounds %struct.dirent, %struct.dirent* %7, i32 0, i32 0
%61 = load i8*, i8** %60
%62 = call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%63 = icmp eq i64 %62, 0
br i1 %63, label %69, label %64
64: ; preds = %59
%65 = getelementptr inbounds %struct.dirent, %struct.dirent* %7, i32 0, i32 0
%66 = load i8*, i8** %65
%67 = call i64 @strcmp(i8* %66, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%68 = icmp eq i64 %67, 0
br i1 %68, label %69, label %70
69: ; preds = %64, %59
br label %50
70: ; preds = %64
%71 = load i8*, i8** %4
%72 = load i32, i32* @PATH_MAX
%73 = call i32 @strncpy(i8* %19, i8* %71, i32 %72)
%74 = load i32, i32* @PATH_MAX
%75 = call i32 @strncat(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %74)
%76 = getelementptr inbounds %struct.dirent, %struct.dirent* %7, i32 0, i32 0
%77 = load i8*, i8** %76
%78 = load i32, i32* @PATH_MAX
%79 = call i32 @strncat(i8* %19, i8* %77, i32 %78)
%80 = load i8*, i8** %5
%81 = getelementptr inbounds %struct.dirent, %struct.dirent* %7, i32 0, i32 0
%82 = load i8*, i8** %81
%83 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %80, i8* %82)
%84 = call i64 @lstat(i8* %19, %struct.stat* %9)
%85 = icmp eq i64 %84, 0
br i1 %85, label %86, label %107
86: ; preds = %70
%87 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%88 = load i32, i32* %87
%89 = call i64 @S_ISDIR(i32 %88)
%90 = icmp ne i64 %89, 0
br i1 %90, label %91, label %101
91: ; preds = %86
%92 = call i64 @create_dir(i8* %23)
%93 = icmp ne i64 %92, 0
br i1 %93, label %94, label %96
94: ; preds = %91
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %96
96: ; preds = %94, %91
%97 = call i32 @cp_dir(i8* %19, i8* %23)
store i32 %97, i32* %13
%98 = icmp slt i32 %97, 0
br i1 %98, label %99, label %100
99: ; preds = %96
br label %109
100: ; preds = %96
br label %106
101: ; preds = %86
%102 = call i32 @cp_file(i8* %19, i8* %23)
store i32 %102, i32* %13
%103 = icmp slt i32 %102, 0
br i1 %103, label %104, label %105
104: ; preds = %101
br label %114
105: ; preds = %101
br label %106
106: ; preds = %105, %100
br label %107
107: ; preds = %106, %70
br label %50
108: ; preds = %57
store i32 0, i32* %3
store i32 1, i32* %14
br label %119
109: ; preds = %99
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%111 = load i32*, i32** %6
%112 = call i32 @closedir(i32* %111)
%113 = load i32, i32* %13
store i32 %113, i32* %3
store i32 1, i32* %14
br label %119
114: ; preds = %104
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%116 = load i32*, i32** %6
%117 = call i32 @closedir(i32* %116)
%118 = load i32, i32* %13
store i32 %118, i32* %3
store i32 1, i32* %14
br label %119
119: ; preds = %114, %109, %108, %44, %39, %34, %29
%120 = load i8*, i8** %10
%121 = load i32, i32* %3
ret i32 %121
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
%struct.stat = type { i32 }
@PATH_MAX = global i32 0
@.str = [23 x i8] c"Couldn't open %s : %s\0A\00"
@errno = global i32 0
@.str.1 = [2 x i8] c".\00"
@.str.2 = [3 x i8] c"..\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [6 x i8] c"%s/%s\00"
@str = [19 x i8] c"Couldn't copy file\00"
@str.8 = [18 x i8] c"Couldn't copy dir\00"
@str.9 = [26 x i8] c"erreur de creation de dir\00"
define i32 @cp_dir(i8* %0, i8* %1) {
%3 = alloca %struct.dirent
%4 = alloca %struct.dirent*
%5 = alloca %struct.stat
%6 = bitcast %struct.dirent* %3 to i8*
%7 = bitcast %struct.dirent** %4 to i8*
%8 = bitcast %struct.stat* %5 to i8*
%9 = load i32, i32* @PATH_MAX
%10 = add nsw i32 %9, 1
%11 = zext i32 %10 to i64
%12 = tail call i8* @llvm.stacksave()
%13 = alloca i8, i64 %11
%14 = load i32, i32* @PATH_MAX
%15 = add nsw i32 %14, 1
%16 = zext i32 %15 to i64
%17 = alloca i8, i64 %16
%18 = icmp eq i8* %0, null
%19 = icmp eq i8* %1, null
%20 = or i1 %18, %19
br i1 %20, label %90, label %21
21: ; preds = %2
%22 = tail call i32 @is_dir(i8* %0)
%23 = icmp eq i32 %22, 0
br i1 %23, label %90, label %24
24: ; preds = %21
%25 = tail call i64 @create_dir(i8* %1)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %90
27: ; preds = %24
%28 = tail call i32* @opendir(i8* %0)
%29 = icmp eq i32* %28, null
br i1 %29, label %39, label %30
30: ; preds = %27
%31 = call i64 @readdir_r(i32* %28, %struct.dirent* %3, %struct.dirent** %4)
%32 = icmp eq i64 %31, 0
%33 = load %struct.dirent*, %struct.dirent** %4
%34 = icmp ne %struct.dirent* %33, null
%35 = select i1 %32, i1 %34, i1 false
br i1 %35, label %36, label %90
36: ; preds = %30
%37 = getelementptr inbounds %struct.dirent, %struct.dirent* %3, i64 0, i32 0
%38 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 0
br label %43
39: ; preds = %27
%40 = load i32, i32* @errno
%41 = tail call i8* @strerror(i32 %40)
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %41)
br label %90
43: ; preds = %36, %51
%44 = load i8*, i8** %37
%45 = call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %51, label %47
47: ; preds = %43
%48 = load i8*, i8** %37
%49 = call i64 @strcmp(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %57
51: ; preds = %57, %81, %78, %43, %47
%52 = call i64 @readdir_r(i32* %28, %struct.dirent* %3, %struct.dirent** %4)
%53 = icmp eq i64 %52, 0
%54 = load %struct.dirent*, %struct.dirent** %4
%55 = icmp ne %struct.dirent* %54, null
%56 = select i1 %53, i1 %55, i1 false
br i1 %56, label %43, label %90
57: ; preds = %47
%58 = load i32, i32* @PATH_MAX
%59 = call i32 @strncpy(i8* %13, i8* %0, i32 %58)
%60 = load i32, i32* @PATH_MAX
%61 = call i32 @strncat(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %60)
%62 = load i8*, i8** %37
%63 = load i32, i32* @PATH_MAX
%64 = call i32 @strncat(i8* %13, i8* %62, i32 %63)
%65 = load i8*, i8** %37
%66 = call i32 @sprintf(i8* %17, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %1, i8* %65)
%67 = call i64 @lstat(i8* %13, %struct.stat* %5)
%68 = icmp eq i64 %67, 0
br i1 %68, label %69, label %51
69: ; preds = %57
%70 = load i32, i32* %38
%71 = call i64 @S_ISDIR(i32 %70)
%72 = icmp eq i64 %71, 0
br i1 %72, label %81, label %73
73: ; preds = %69
%74 = call i64 @create_dir(i8* %17)
%75 = icmp eq i64 %74, 0
br i1 %75, label %78, label %76
76: ; preds = %73
%77 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.9, i64 0, i64 0))
br label %78
78: ; preds = %76, %73
%79 = call i32 @cp_dir(i8* %13, i8* %17)
%80 = icmp slt i32 %79, 0
br i1 %80, label %84, label %51
81: ; preds = %69
%82 = call i32 @cp_file(i8* %13, i8* %17)
%83 = icmp slt i32 %82, 0
br i1 %83, label %87, label %51
84: ; preds = %78
%85 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.8, i64 0, i64 0))
%86 = call i32 @closedir(i32* %28)
br label %90
87: ; preds = %81
%88 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%89 = call i32 @closedir(i32* %28)
br label %90
90: ; preds = %51, %30, %24, %21, %2, %87, %84, %39
%91 = phi i32 [ -1, %39 ], [ %79, %84 ], [ %82, %87 ], [ -1, %2 ], [ -1, %21 ], [ -1, %24 ], [ 0, %30 ], [ 0, %51 ]
ret i32 %91
}