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

/* Variables and functions */
int /*<<< orphan*/ BackupNode(char *, struct stat const *, int);
int /*<<< orphan*/ *opendir(char const *);
int /*<<< orphan*/ perror(char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ strcat(int /*<<< orphan*/, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char const *);
void BackupDirContent(const char *nodename, const struct stat *tinode,
                      int tfd) {
  DIR *dir;
  struct dirent *dentry;
  char name[4096];
  dir = opendir(nodename);
  if (!dir) {
    perror("folder open error:  ");
    return;
  }
  while ((dentry = readdir(dir)) != NULL) {
    if (!strcmp(dentry->d_name, ".") || !strcmp(dentry->d_name, "..")) {
      continue;
    }
    strcat(strcat(strcpy(name, nodename), "/"), dentry->d_name);
    BackupNode(name, tinode, tfd);
  }
}


x86 assembly (clang, -O0):
<BackupDirContent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <opendir@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11af <BackupDirContent+0x3f>
lea    0xe5b(%rip),%rdi
call   1080 <perror@plt>
jmp    124c <BackupDirContent+0xdc>
jmp    11b4 <BackupDirContent+0x44>
mov    -0x20(%rbp),%rdi
call   1070 <readdir@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     124c <BackupDirContent+0xdc>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
lea    0xe3d(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
je     1203 <BackupDirContent+0x93>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
lea    0xe20(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1208 <BackupDirContent+0x98>
jmp    11b4 <BackupDirContent+0x44>
lea    -0x1030(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    %eax,%edi
lea    0xdf7(%rip),%rsi
call   1090 <strcat@plt>
mov    %eax,%edi
mov    -0x28(%rbp),%rax
mov    (%rax),%rsi
call   1090 <strcat@plt>
lea    -0x1030(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <BackupNode@plt>
jmp    11b4 <BackupDirContent+0x44>
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BackupDirContent>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
mov    %edx,0x4(%rsp)
mov    %rsi,0x8(%rsp)
mov    %rdi,%r12
call   1040 <opendir@plt>
test   %rax,%rax
je     123d <BackupDirContent+0xcd>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <readdir@plt>
test   %rax,%rax
je     122b <BackupDirContent+0xbb>
mov    %rax,%r14
lea    0xe5d(%rip),%rbp
lea    0x10(%rsp),%r13
jmp    11d0 <BackupDirContent+0x60>
mov    %rbx,%rdi
call   1070 <readdir@plt>
mov    %rax,%r14
test   %rax,%rax
je     122b <BackupDirContent+0xbb>
mov    (%r14),%r15
mov    %r15,%rdi
mov    %rbp,%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     11c0 <BackupDirContent+0x50>
mov    %r15,%rdi
lea    0xe29(%rip),%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     11c0 <BackupDirContent+0x50>
mov    %r13,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    %eax,%edi
lea    0xe0f(%rip),%rsi
call   1090 <strcat@plt>
mov    (%r14),%rsi
mov    %eax,%edi
call   1090 <strcat@plt>
mov    %r13,%rdi
mov    0x8(%rsp),%rsi
mov    0x4(%rsp),%edx
call   1050 <BackupNode@plt>
jmp    11c0 <BackupDirContent+0x50>
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdbc(%rip),%rdi
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <perror@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
%struct.dirent = type { i8* }
@.str = [21 x i8] c"folder open error: \00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [3 x i8] c"..\00"
@.str.3 = [2 x i8] c"/\00"
define void @BackupDirContent(i8* %0, %struct.stat* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca %struct.stat*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca %struct.dirent*
%9 = alloca [4096 x i8]
store i8* %0, i8** %4
store %struct.stat* %1, %struct.stat** %5
store i32 %2, i32* %6
%10 = load i8*, i8** %4
%11 = call i32* @opendir(i8* %10)
store i32* %11, i32** %7
%12 = load i32*, i32** %7
%13 = icmp ne i32* %12, null
br i1 %13, label %16, label %14
14: ; preds = %3
%15 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %47
16: ; preds = %3
br label %17
17: ; preds = %34, %33, %16
%18 = load i32*, i32** %7
%19 = call %struct.dirent* @readdir(i32* %18)
store %struct.dirent* %19, %struct.dirent** %8
%20 = icmp ne %struct.dirent* %19, null
br i1 %20, label %21, label %47
21: ; preds = %17
%22 = load %struct.dirent*, %struct.dirent** %8
%23 = getelementptr inbounds %struct.dirent, %struct.dirent* %22, i32 0, i32 0
%24 = load i8*, i8** %23
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %21
%28 = load %struct.dirent*, %struct.dirent** %8
%29 = getelementptr inbounds %struct.dirent, %struct.dirent* %28, i32 0, i32 0
%30 = load i8*, i8** %29
%31 = call i32 @strcmp(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%32 = icmp ne i32 %31, 0
br i1 %32, label %34, label %33
33: ; preds = %27, %21
br label %17
34: ; preds = %27
%35 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%36 = load i8*, i8** %4
%37 = call i32 @strcpy(i8* %35, i8* %36)
%38 = call i32 @strcat(i32 %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%39 = load %struct.dirent*, %struct.dirent** %8
%40 = getelementptr inbounds %struct.dirent, %struct.dirent* %39, i32 0, i32 0
%41 = load i8*, i8** %40
%42 = call i32 @strcat(i32 %38, i8* %41)
%43 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%44 = load %struct.stat*, %struct.stat** %5
%45 = load i32, i32* %6
%46 = call i32 @BackupNode(i8* %43, %struct.stat* %44, i32 %45)
br label %17
47: ; preds = %14, %17
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.dirent = type { i8* }
@.str = [21 x i8] c"folder open error: \00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [3 x i8] c"..\00"
@.str.3 = [2 x i8] c"/\00"
define void @BackupDirContent(i8* %0, %struct.stat* %1, i32 %2) {
%4 = alloca [4096 x i8]
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%6 = tail call i32* @opendir(i8* %0)
%7 = icmp eq i32* %6, null
br i1 %7, label %11, label %8
8: ; preds = %3
%9 = call %struct.dirent* @readdir(i32* %6)
%10 = icmp eq %struct.dirent* %9, null
br i1 %10, label %31, label %13
11: ; preds = %3
%12 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %31
13: ; preds = %8, %22
%14 = phi %struct.dirent* [ %23, %22 ], [ %9, %8 ]
%15 = getelementptr inbounds %struct.dirent, %struct.dirent* %14, i64 0, i32 0
%16 = load i8*, i8** %15
%17 = call i32 @strcmp(i8* dereferenceable(1) %16, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %13
%20 = call i32 @strcmp(i8* dereferenceable(1) %16, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %13, %19, %25
%23 = call %struct.dirent* @readdir(i32* %6)
%24 = icmp eq %struct.dirent* %23, null
br i1 %24, label %31, label %13
25: ; preds = %19
%26 = call i32 @strcpy(i8* %5, i8* %0)
%27 = call i32 @strcat(i32 %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%28 = load i8*, i8** %15
%29 = call i32 @strcat(i32 %27, i8* %28)
%30 = call i32 @BackupNode(i8* %5, %struct.stat* %1, i32 %2)
br label %22
31: ; preds = %22, %8, %11
ret void
}