// File: /workspace/github_c_makefile_star2_O3/CSerxzm[P]WindowstoLinuxInterface/src/XCOPY.c
// Function: mycpdir
int mycpdir(char *name1, char *name2)
{
    int ret;
    DIR *dir1;
    DIR *dir2;
    struct dirent *drr;
    struct stat info;
    struct stat dirinfo;
    char buf1[1024];
    char buf2[1024];
    lstat(name1, &info);
    dir1=opendir(name1);
    if(dir1==NULL)
    {
        perror("opendir1");
        return 1;
    }
    dir2=opendir(name2); 
    if(dir2==NULL)
    {
        mkdir(name2, info.st_mode);
        dir2=opendir(name2);
    }

    while(1)
    {
        bzero(buf2, sizeof(buf2));
        bzero(buf2, sizeof(buf2));
        drr=readdir(dir1);
        if(drr==NULL)break;
        if(*drr->d_name=='.')
            continue;
        sprintf(buf1, "%s/%s", name1, drr->d_name);
        sprintf(buf2, "%s/%s", name2, drr->d_name);
        ret=lstat(buf1, &dirinfo);
        if(ret<0)
        {
            perror("lstat\n");
            break;
        }
        if(S_ISDIR(dirinfo.st_mode))
        {
            mycpdir(buf1 , buf2);
        }
        else if(S_ISREG(dirinfo.st_mode))
        {
            mycp(buf1, buf2);
        }
        else if(S_ISLNK(dirinfo.st_mode))
        {
            mycplink(buf1, buf2);
        }
    }
	closedir(dir1);
    closedir(dir2);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x938, %rsp            # imm = 0x938
movq %rsi, %rbx
movq %rdi, %r14
leaq -0x160(%rbp), %rsi
callq 0x10d0
movq %r14, -0x40(%rbp)
movq %r14, %rdi
callq 0x1060
testq %rax, %rax
je 0x1651
movq %rax, %r15
movq %rbx, %rdi
callq 0x1060
testq %rax, %rax
jne 0x154d
movl -0x148(%rbp), %esi
movq %rbx, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x1060
movq %rax, -0x30(%rbp)
movq %rbx, -0x38(%rbp)
leaq -0x560(%rbp), %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x1090
movq %r15, %rdi
callq 0x10f0
testq %rax, %rax
je 0x1670
movq %rax, %r14
leaq -0x560(%rbp), %r13
leaq 0xa88(%rip), %r12       # 0x2012
leaq -0x960(%rbp), %rbx
cmpb $0x2e, 0x13(%r14)
jne 0x15bc
movl $0x400, %edx            # imm = 0x400
movq %r13, %rdi
xorl %esi, %esi
callq 0x1090
movq %r15, %rdi
callq 0x10f0
movq %rax, %r14
testq %rax, %rax
jne 0x1591
jmp 0x1670
addq $0x13, %r14
movq %rbx, %rdi
movq %r12, %rsi
movq -0x40(%rbp), %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x1130
movq %r13, %rdi
movq %r12, %rsi
movq -0x38(%rbp), %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x1130
movq %rbx, %rdi
leaq -0xd0(%rbp), %rsi
callq 0x10d0
testl %eax, %eax
js 0x1664
movl -0xb8(%rbp), %eax
movl $0xf000, %ecx           # imm = 0xF000
andl %ecx, %eax
cmpl $0xa000, %eax           # imm = 0xA000
je 0x1641
cmpl $0x8000, %eax           # imm = 0x8000
je 0x1631
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x1598
movq %rbx, %rdi
movq %r13, %rsi
callq 0x14ec
jmp 0x1598
movq %rbx, %rdi
movq %r13, %rsi
callq 0x13bc
jmp 0x1598
movq %rbx, %rdi
movq %r13, %rsi
callq 0x135d
jmp 0x1598
leaq 0x9b1(%rip), %rdi       # 0x2009
callq 0x1120
movl $0x1, %eax
jmp 0x1683
leaq 0x9ad(%rip), %rdi       # 0x2018
callq 0x1120
movq %r15, %rdi
callq 0x10b0
movq -0x30(%rbp), %rdi
callq 0x10b0
xorl %eax, %eax
addq $0x938, %rsp            # imm = 0x938
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq