#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 {
  scalar_t__ st_ino;
  scalar_t__ st_dev;
  int /*<<< orphan*/ st_mode;
};
typedef int /*<<< orphan*/ cwd;

/* Variables and functions */
int /*<<< orphan*/ BackupDirContent(char const *, struct stat const *, int);
int /*<<< orphan*/ HeaderWrite(char const *, struct stat *, int);
scalar_t__ S_ISDIR(int /*<<< orphan*/);
scalar_t__ S_ISREG(int /*<<< orphan*/);
int /*<<< orphan*/ WriteContent(char const *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ *getcwd(char *, int);
int lstat(char const *, struct stat *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcmp(char const *, char *);
void BackupNode(const char *nodename, const struct stat *tinode, int tfd) {
  struct stat srcinode;
  if (lstat(nodename, &srcinode) == -1) {
    perror("srcinode error:  ");
    char cwd[1024];
    if (getcwd(cwd, sizeof(cwd)) != NULL)
      fprintf(stdout, "Current working dir: %s\n", cwd);
    return;
  }
  if (srcinode.st_ino == tinode->st_ino && srcinode.st_dev == tinode->st_dev) {
    fprintf(stderr, "source equals target\n");
    return;
  }
  if (S_ISREG(srcinode.st_mode)) {
    HeaderWrite(nodename, &srcinode, tfd);
    WriteContent(nodename, tfd);
  } else if (S_ISDIR(srcinode.st_mode)) {
    if (!strcmp(nodename, ".") || !strcmp(nodename, "..")) {
      printf("Ignoring special Folder %s\n", nodename);
      return;
    }
    HeaderWrite(nodename, &srcinode, tfd);
    BackupDirContent(nodename, tinode, tfd);
  } else {
    printf("ignoring special File %s\n", nodename);
  }
}


x86 assembly (clang, -O0):
<BackupNode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1070 <lstat@plt>
cmp    $0xffffffff,%eax
jne    1226 <BackupNode+0x76>
lea    0xe1d(%rip),%rdi
call   10b0 <perror@plt>
lea    -0x430(%rbp),%rdi
mov    $0x400,%esi
call   1060 <getcwd@plt>
cmp    $0x0,%rax
je     1221 <BackupNode+0x71>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
lea    -0x430(%rbp),%rdx
lea    0xdf8(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    132b <BackupNode+0x17b>
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
jne    1265 <BackupNode+0xb5>
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    0x8(%rcx),%rax
jne    1265 <BackupNode+0xb5>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
lea    0xdd2(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    132b <BackupNode+0x17b>
mov    -0x20(%rbp),%edi
call   10a0 <S_ISREG@plt>
cmp    $0x0,%rax
je     1298 <BackupNode+0xe8>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    -0x30(%rbp),%rsi
call   10d0 <HeaderWrite@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10c0 <WriteContent@plt>
jmp    132b <BackupNode+0x17b>
mov    -0x20(%rbp),%edi
call   1050 <S_ISDIR@plt>
cmp    $0x0,%rax
je     1316 <BackupNode+0x166>
mov    -0x8(%rbp),%rdi
lea    0xd8d(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
je     12dc <BackupNode+0x12c>
mov    -0x8(%rbp),%rdi
lea    0xd73(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    12f1 <BackupNode+0x141>
mov    -0x8(%rbp),%rsi
lea    0xd5d(%rip),%rdi
call   1040 <printf@plt>
jmp    132b <BackupNode+0x17b>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    -0x30(%rbp),%rsi
call   10d0 <HeaderWrite@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <BackupDirContent@plt>
jmp    1326 <BackupNode+0x176>
mov    -0x8(%rbp),%rsi
lea    0xd3f(%rip),%rdi
call   1040 <printf@plt>
jmp    132b <BackupNode+0x17b>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BackupNode>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x428,%rsp
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
call   1070 <lstat@plt>
cmp    $0xffffffff,%eax
je     12c2 <BackupNode+0x112>
mov    0x8(%rsp),%rax
cmp    (%r15),%rax
jne    1212 <BackupNode+0x62>
mov    0x10(%rsp),%rax
cmp    0x8(%r15),%rax
jne    1212 <BackupNode+0x62>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
lea    0xe2d(%rip),%rsi
xor    %eax,%eax
add    $0x428,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <fprintf@plt>
mov    0x18(%rsp),%ebp
mov    %ebp,%edi
call   10a0 <S_ISREG@plt>
test   %rax,%rax
je     124b <BackupNode+0x9b>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
mov    %r14d,%edx
call   10d0 <HeaderWrite@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   10c0 <WriteContent@plt>
add    $0x428,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebp,%edi
call   1050 <S_ISDIR@plt>
test   %rax,%rax
je     129d <BackupNode+0xed>
lea    0xde4(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     12a6 <BackupNode+0xf6>
lea    0xdd0(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     12a6 <BackupNode+0xf6>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
mov    %r14d,%edx
call   10d0 <HeaderWrite@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
call   1030 <BackupDirContent@plt>
jmp    123d <BackupNode+0x8d>
lea    0xdbc(%rip),%rdi
jmp    12ad <BackupNode+0xfd>
lea    0xd97(%rip),%rdi
mov    %rbx,%rsi
add    $0x428,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>
lea    0xd37(%rip),%rdi
call   10b0 <perror@plt>
lea    0x20(%rsp),%rdi
mov    $0x400,%esi
call   1060 <getcwd@plt>
test   %rax,%rax
je     123d <BackupNode+0x8d>
mov    0x2ceb(%rip),%rax
mov    (%rax),%edi
lea    0xd1c(%rip),%rsi
lea    0x20(%rsp),%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    123d <BackupNode+0x8d>

LLVM IR (-O0):
%struct.stat = type { i64, i64, i32 }
@.str = [18 x i8] c"srcinode error: \00"
@stdout = global i32 0
@.str.1 = [25 x i8] c"Current working dir: %s\0A\00"
@stderr = global i32 0
@.str.2 = [22 x i8] c"source equals target\0A\00"
@.str.3 = [2 x i8] c".\00"
@.str.4 = [3 x i8] c"..\00"
@.str.5 = [28 x i8] c"Ignoring special Folder %s\0A\00"
@.str.6 = [26 x i8] c"ignoring special File %s\0A\00"
define void @BackupNode(i8* %0, %struct.stat* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca %struct.stat*
%6 = alloca i32
%7 = alloca %struct.stat
%8 = alloca [1024 x i8]
store i8* %0, i8** %4
store %struct.stat* %1, %struct.stat** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %4
%10 = call i32 @lstat(i8* %9, %struct.stat* %7)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %22
12: ; preds = %3
%13 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%15 = call i32* @getcwd(i8* %14, i32 1024)
%16 = icmp ne i32* %15, null
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = load i32, i32* @stdout
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %17, %12
br label %79
22: ; preds = %3
%23 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%24 = load i64, i64* %23
%25 = load %struct.stat*, %struct.stat** %5
%26 = getelementptr inbounds %struct.stat, %struct.stat* %25, i32 0, i32 0
%27 = load i64, i64* %26
%28 = icmp eq i64 %24, %27
br i1 %28, label %29, label %39
29: ; preds = %22
%30 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 1
%31 = load i64, i64* %30
%32 = load %struct.stat*, %struct.stat** %5
%33 = getelementptr inbounds %struct.stat, %struct.stat* %32, i32 0, i32 1
%34 = load i64, i64* %33
%35 = icmp eq i64 %31, %34
br i1 %35, label %36, label %39
36: ; preds = %29
%37 = load i32, i32* @stderr
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %79
39: ; preds = %29, %22
%40 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 2
%41 = load i32, i32* %40
%42 = call i64 @S_ISREG(i32 %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %51
44: ; preds = %39
%45 = load i8*, i8** %4
%46 = load i32, i32* %6
%47 = call i32 @HeaderWrite(i8* %45, %struct.stat* %7, i32 %46)
%48 = load i8*, i8** %4
%49 = load i32, i32* %6
%50 = call i32 @WriteContent(i8* %48, i32 %49)
br label %79
51: ; preds = %39
%52 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 2
%53 = load i32, i32* %52
%54 = call i64 @S_ISDIR(i32 %53)
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %75
56: ; preds = %51
%57 = load i8*, i8** %4
%58 = call i32 @strcmp(i8* %57, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %64
60: ; preds = %56
%61 = load i8*, i8** %4
%62 = call i32 @strcmp(i8* %61, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%63 = icmp ne i32 %62, 0
br i1 %63, label %67, label %64
64: ; preds = %60, %56
%65 = load i8*, i8** %4
%66 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %65)
br label %79
67: ; preds = %60
%68 = load i8*, i8** %4
%69 = load i32, i32* %6
%70 = call i32 @HeaderWrite(i8* %68, %struct.stat* %7, i32 %69)
%71 = load i8*, i8** %4
%72 = load %struct.stat*, %struct.stat** %5
%73 = load i32, i32* %6
%74 = call i32 @BackupDirContent(i8* %71, %struct.stat* %72, i32 %73)
br label %78
75: ; preds = %51
%76 = load i8*, i8** %4
%77 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %76)
br label %78
78: ; preds = %75, %67
br label %79
79: ; preds = %21, %36, %64, %78, %44
ret void
}

LLVM IR (-O2):
%struct.stat = type { i64, i64, i32 }
@.str = [18 x i8] c"srcinode error: \00"
@stdout = global i32 0
@.str.1 = [25 x i8] c"Current working dir: %s\0A\00"
@stderr = global i32 0
@.str.2 = [22 x i8] c"source equals target\0A\00"
@.str.3 = [2 x i8] c".\00"
@.str.4 = [3 x i8] c"..\00"
@.str.5 = [28 x i8] c"Ignoring special Folder %s\0A\00"
@.str.6 = [26 x i8] c"ignoring special File %s\0A\00"
define void @BackupNode(i8* %0, %struct.stat* %1, i32 %2) {
%4 = alloca %struct.stat
%5 = alloca [1024 x i8]
%6 = bitcast %struct.stat* %4 to i8*
%7 = call i32 @lstat(i8* %0, %struct.stat* %4)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %18
9: ; preds = %3
%10 = tail call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%12 = call i32* @getcwd(i8* %11, i32 1024)
%13 = icmp eq i32* %12, null
br i1 %13, label %17, label %14
14: ; preds = %9
%15 = load i32, i32* @stdout
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %17
17: ; preds = %14, %9
br label %57
18: ; preds = %3
%19 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%20 = load i64, i64* %19
%21 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%22 = load i64, i64* %21
%23 = icmp eq i64 %20, %22
br i1 %23, label %24, label %33
24: ; preds = %18
%25 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 1
%26 = load i64, i64* %25
%27 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 1
%28 = load i64, i64* %27
%29 = icmp eq i64 %26, %28
br i1 %29, label %30, label %33
30: ; preds = %24
%31 = load i32, i32* @stderr
%32 = tail call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %57
33: ; preds = %24, %18
%34 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 2
%35 = load i32, i32* %34
%36 = tail call i64 @S_ISREG(i32 %35)
%37 = icmp eq i64 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %33
%39 = call i32 @HeaderWrite(i8* %0, %struct.stat* %4, i32 %2)
%40 = call i32 @WriteContent(i8* %0, i32 %2)
br label %57
41: ; preds = %33
%42 = tail call i64 @S_ISDIR(i32 %35)
%43 = icmp eq i64 %42, 0
br i1 %43, label %55, label %44
44: ; preds = %41
%45 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%46 = icmp eq i32 %45, 0
br i1 %46, label %50, label %47
47: ; preds = %44
%48 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %47, %44
%51 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %0)
br label %57
52: ; preds = %47
%53 = call i32 @HeaderWrite(i8* %0, %struct.stat* %4, i32 %2)
%54 = call i32 @BackupDirContent(i8* %0, %struct.stat* %1, i32 %2)
br label %57
55: ; preds = %41
%56 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %0)
br label %57
57: ; preds = %38, %55, %52, %50, %30, %17
ret void
}