#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;
};

/* Variables and functions */
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
scalar_t__ S_ISDIR(int /*<<< orphan*/);
int S_IWGRP;
int S_IWUSR;
int S_IXGRP;
int S_IXOTH;
int S_IXUSR;
int cpfile(char *, char *, int const);
int enum_opt_dir(int /*<<< orphan*/, char *, int, char *, int const, int const);
int mkdir(char *, int);
int remove(char *);
int /*<<< orphan*/ stat(char *, struct stat *);
int /*<<< orphan*/ strcat(char *, char *);
int optCopyMove(char *src, char *dst, char *filename, const int overWrite,
                const int isMove) {
  strcat(dst, "/");
  strcat(dst, filename);
  int ret = 0;
  struct stat info;
  stat(src, &info);
  if (S_ISDIR(info.st_mode)) {
    ret = mkdir(dst, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP |
                         S_IROTH | S_IXOTH);
    if ((0 == ret) || (overWrite)) {
      ret = enum_opt_dir(0, src, 2, dst, overWrite, isMove);
    }
  } else {
    ret = cpfile(src, dst, overWrite);
    ;
  }
  if ((isMove) && (0 == ret)) {
    ret = remove(src);
    ;
  }
  return ret;
}


x86 assembly (clang, -O0):
<optCopyMove>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1090 <strcat@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1090 <strcat@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1060 <stat@plt>
mov    -0x28(%rbp),%edi
call   1050 <S_ISDIR@plt>
cmp    $0x0,%rax
je     125b <optCopyMove+0xeb>
mov    -0x10(%rbp),%rdi
mov    0x2dcf(%rip),%rax
mov    (%rax),%esi
mov    0x2dee(%rip),%rax
or     (%rax),%esi
mov    0x2df5(%rip),%rax
or     (%rax),%esi
mov    0x2dc4(%rip),%rax
or     (%rax),%esi
mov    0x2ddb(%rip),%rax
or     (%rax),%esi
mov    0x2dc2(%rip),%rax
or     (%rax),%esi
mov    0x2da1(%rip),%rax
or     (%rax),%esi
mov    0x2dd0(%rip),%rax
or     (%rax),%esi
call   1040 <mkdir@plt>
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
cmp    -0x24(%rbp),%eax
je     1237 <optCopyMove+0xc7>
cmpl   $0x0,-0x1c(%rbp)
je     1256 <optCopyMove+0xe6>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
mov    -0x20(%rbp),%r9d
xor    %edi,%edi
mov    $0x2,%edx
call   1070 <enum_opt_dir@plt>
mov    %eax,-0x24(%rbp)
jmp    126e <optCopyMove+0xfe>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1080 <cpfile@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     128f <optCopyMove+0x11f>
xor    %eax,%eax
cmp    -0x24(%rbp),%eax
jne    128f <optCopyMove+0x11f>
mov    -0x8(%rbp),%rdi
call   1030 <remove@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<optCopyMove>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r8d,%r14d
mov    %ecx,%r15d
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %rdi,%r12
lea    0xe6e(%rip),%rsi
mov    %rbp,%rdi
call   1090 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1090 <strcat@plt>
lea    0x8(%rsp),%rsi
mov    %r12,%rdi
call   1060 <stat@plt>
mov    0x8(%rsp),%edi
call   1050 <S_ISDIR@plt>
test   %rax,%rax
je     1238 <optCopyMove+0xc8>
mov    0x2de1(%rip),%rax
mov    0x2e02(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e07(%rip),%rax
or     (%rax),%esi
mov    0x2dd6(%rip),%rax
or     (%rax),%esi
mov    0x2ded(%rip),%rax
or     (%rax),%esi
mov    0x2dd4(%rip),%rax
or     (%rax),%esi
mov    0x2db3(%rip),%rax
or     (%rax),%esi
mov    0x2de2(%rip),%rax
or     (%rax),%esi
mov    %rbp,%rdi
call   1040 <mkdir@plt>
test   %r15d,%r15d
jne    1219 <optCopyMove+0xa9>
test   %eax,%eax
jne    1263 <optCopyMove+0xf3>
xor    %edi,%edi
mov    %r12,%rsi
mov    $0x2,%edx
mov    %rbp,%rcx
mov    %r15d,%r8d
mov    %r14d,%r9d
call   1070 <enum_opt_dir@plt>
test   %r14d,%r14d
jne    124b <optCopyMove+0xdb>
jmp    1263 <optCopyMove+0xf3>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r15d,%edx
call   1080 <cpfile@plt>
test   %r14d,%r14d
je     1263 <optCopyMove+0xf3>
test   %eax,%eax
jne    1263 <optCopyMove+0xf3>
mov    %r12,%rdi
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <remove@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [2 x i8] c"/\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IXUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IXOTH = global i32 0
define i32 @optCopyMove(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.stat
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%13 = load i8*, i8** %7
%14 = call i32 @strcat(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = load i8*, i8** %7
%16 = load i8*, i8** %8
%17 = call i32 @strcat(i8* %15, i8* %16)
store i32 0, i32* %11
%18 = load i8*, i8** %6
%19 = call i32 @stat(i8* %18, %struct.stat* %12)
%20 = getelementptr inbounds %struct.stat, %struct.stat* %12, i32 0, i32 0
%21 = load i32, i32* %20
%22 = call i64 @S_ISDIR(i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %54
24: ; preds = %5
%25 = load i8*, i8** %7
%26 = load i32, i32* @S_IRUSR
%27 = load i32, i32* @S_IWUSR
%28 = or i32 %26, %27
%29 = load i32, i32* @S_IXUSR
%30 = or i32 %28, %29
%31 = load i32, i32* @S_IRGRP
%32 = or i32 %30, %31
%33 = load i32, i32* @S_IWGRP
%34 = or i32 %32, %33
%35 = load i32, i32* @S_IXGRP
%36 = or i32 %34, %35
%37 = load i32, i32* @S_IROTH
%38 = or i32 %36, %37
%39 = load i32, i32* @S_IXOTH
%40 = or i32 %38, %39
%41 = call i32 @mkdir(i8* %25, i32 %40)
store i32 %41, i32* %11
%42 = load i32, i32* %11
%43 = icmp eq i32 0, %42
br i1 %43, label %47, label %44
44: ; preds = %24
%45 = load i32, i32* %9
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %53
47: ; preds = %44, %24
%48 = load i8*, i8** %6
%49 = load i8*, i8** %7
%50 = load i32, i32* %9
%51 = load i32, i32* %10
%52 = call i32 @enum_opt_dir(i32 0, i8* %48, i32 2, i8* %49, i32 %50, i32 %51)
store i32 %52, i32* %11
br label %53
53: ; preds = %47, %44
br label %59
54: ; preds = %5
%55 = load i8*, i8** %6
%56 = load i8*, i8** %7
%57 = load i32, i32* %9
%58 = call i32 @cpfile(i8* %55, i8* %56, i32 %57)
store i32 %58, i32* %11
br label %59
59: ; preds = %54, %53
%60 = load i32, i32* %10
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %68
62: ; preds = %59
%63 = load i32, i32* %11
%64 = icmp eq i32 0, %63
br i1 %64, label %65, label %68
65: ; preds = %62
%66 = load i8*, i8** %6
%67 = call i32 @remove(i8* %66)
store i32 %67, i32* %11
br label %68
68: ; preds = %65, %62, %59
%69 = load i32, i32* %11
ret i32 %69
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [2 x i8] c"/\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IXUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IXOTH = global i32 0
define i32 @optCopyMove(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca %struct.stat
%7 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @strcat(i8* %1, i8* %2)
%9 = bitcast %struct.stat* %6 to i8*
%10 = call i32 @stat(i8* %0, %struct.stat* %6)
%11 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 0
%12 = load i32, i32* %11
%13 = tail call i64 @S_ISDIR(i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %37, label %15
15: ; preds = %5
%16 = load i32, i32* @S_IRUSR
%17 = load i32, i32* @S_IWUSR
%18 = or i32 %17, %16
%19 = load i32, i32* @S_IXUSR
%20 = or i32 %18, %19
%21 = load i32, i32* @S_IRGRP
%22 = or i32 %20, %21
%23 = load i32, i32* @S_IWGRP
%24 = or i32 %22, %23
%25 = load i32, i32* @S_IXGRP
%26 = or i32 %24, %25
%27 = load i32, i32* @S_IROTH
%28 = or i32 %26, %27
%29 = load i32, i32* @S_IXOTH
%30 = or i32 %28, %29
%31 = tail call i32 @mkdir(i8* %1, i32 %30)
%32 = icmp eq i32 %31, 0
%33 = icmp ne i32 %3, 0
%34 = or i1 %33, %32
br i1 %34, label %35, label %46
35: ; preds = %15
%36 = tail call i32 @enum_opt_dir(i32 0, i8* %0, i32 2, i8* %1, i32 %3, i32 %4)
br label %39
37: ; preds = %5
%38 = tail call i32 @cpfile(i8* %0, i8* %1, i32 %3)
br label %39
39: ; preds = %35, %37
%40 = phi i32 [ %36, %35 ], [ %38, %37 ]
%41 = icmp ne i32 %4, 0
%42 = icmp eq i32 %40, 0
%43 = select i1 %41, i1 %42, i1 false
br i1 %43, label %44, label %46
44: ; preds = %39
%45 = tail call i32 @remove(i8* %0)
br label %46
46: ; preds = %15, %44, %39
%47 = phi i32 [ %45, %44 ], [ %40, %39 ], [ %31, %15 ]
ret i32 %47
}