#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 /*<<< orphan*/ PATH_MAX;
scalar_t__ S_ISDIR(int /*<<< orphan*/);
scalar_t__ S_ISREG(int /*<<< orphan*/);
int /*<<< orphan*/ make_path(char *, char const *, char const *);
int /*<<< orphan*/ print_message(int, char *, char const *, ...);
int demo(const char *path_from, const char *path_to, const char *path_tree,
         const struct stat *st) {
  char path_from_full[(PATH_MAX + 1)];
  char path_to_full[(PATH_MAX + 1)];
  make_path(path_from_full, path_from, path_tree);
  make_path(path_to_full, path_to, path_tree);
  if (S_ISREG(st->st_mode)) {
    print_message(4, "cp \"%s\" -> \"%s\".\n", path_from_full, path_to_full);
  } else if (S_ISDIR(st->st_mode)) {
    print_message(4, "mkdir \"%s\".\n", path_to_full);
  } else {
    print_message(1, "skip \"%s\"\n", path_tree);
  }
  return 0;
}


x86 assembly (clang, -O0):
<demo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    0x2e91(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %rsp,%rdx
mov    %rdx,-0x28(%rbp)
mov    %rcx,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rdi
sub    %rdx,%rdi
mov    %rdi,-0x48(%rbp)
mov    %rdi,%rsp
mov    %rcx,-0x30(%rbp)
mov    (%rax),%eax
add    $0x1,%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1060 <make_path@plt>
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1060 <make_path@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
call   1050 <S_ISREG@plt>
cmp    $0x0,%rax
je     11fb <demo+0xbb>
mov    -0x40(%rbp),%rcx
mov    -0x48(%rbp),%rdx
mov    $0x4,%edi
lea    0xe11(%rip),%rsi
mov    $0x0,%al
call   1030 <print_message@plt>
jmp    1248 <demo+0x108>
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
call   1040 <S_ISDIR@plt>
cmp    $0x0,%rax
je     122c <demo+0xec>
mov    -0x40(%rbp),%rdx
mov    $0x4,%edi
lea    0xdf2(%rip),%rsi
mov    $0x0,%al
call   1030 <print_message@plt>
jmp    1243 <demo+0x103>
mov    -0x18(%rbp),%rdx
mov    $0x1,%edi
lea    0xde3(%rip),%rsi
mov    $0x0,%al
call   1030 <print_message@plt>
jmp    1248 <demo+0x108>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<demo>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%r13
mov    %rdi,%rsi
mov    0x2e8f(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rsp,%r12
sub    %rax,%r12
mov    %r12,%rsp
mov    %rbx,%rdi
call   1060 <make_path@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r14,%rdx
call   1060 <make_path@plt>
mov    (%r15),%edi
call   1050 <S_ISREG@plt>
test   %rax,%rax
je     11be <demo+0x7e>
lea    0xe56(%rip),%rsi
mov    $0x4,%edi
mov    %rbx,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1030 <print_message@plt>
jmp    11f2 <demo+0xb2>
mov    (%r15),%edi
call   1040 <S_ISDIR@plt>
test   %rax,%rax
je     11dc <demo+0x9c>
lea    0xe40(%rip),%rsi
mov    $0x4,%edi
mov    %r12,%rdx
jmp    11eb <demo+0xab>
lea    0xe3c(%rip),%rsi
mov    $0x1,%edi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <print_message@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@PATH_MAX = global i32 0
@.str = [18 x i8] c"cp \22%s\22 -> \22%s\22.\0A\00"
@.str.1 = [13 x i8] c"mkdir \22%s\22.\0A\00"
@.str.2 = [11 x i8] c"skip \22%s\22\0A\00"
define i32 @demo(i8* %0, i8* %1, i8* %2, %struct.stat* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca %struct.stat*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store %struct.stat* %3, %struct.stat** %8
%12 = load i32, i32* @PATH_MAX
%13 = add nsw i32 %12, 1
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %9
%16 = alloca i8, i64 %14
store i64 %14, i64* %10
%17 = load i32, i32* @PATH_MAX
%18 = add nsw i32 %17, 1
%19 = zext i32 %18 to i64
%20 = alloca i8, i64 %19
store i64 %19, i64* %11
%21 = load i8*, i8** %5
%22 = load i8*, i8** %7
%23 = call i32 @make_path(i8* %16, i8* %21, i8* %22)
%24 = load i8*, i8** %6
%25 = load i8*, i8** %7
%26 = call i32 @make_path(i8* %20, i8* %24, i8* %25)
%27 = load %struct.stat*, %struct.stat** %8
%28 = getelementptr inbounds %struct.stat, %struct.stat* %27, i32 0, i32 0
%29 = load i32, i32* %28
%30 = call i64 @S_ISREG(i32 %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %4
%33 = call i32 (i32, i8*, i8*, ...) @print_message(i32 4, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %20)
br label %46
34: ; preds = %4
%35 = load %struct.stat*, %struct.stat** %8
%36 = getelementptr inbounds %struct.stat, %struct.stat* %35, i32 0, i32 0
%37 = load i32, i32* %36
%38 = call i64 @S_ISDIR(i32 %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %34
%41 = call i32 (i32, i8*, i8*, ...) @print_message(i32 4, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %20)
br label %45
42: ; preds = %34
%43 = load i8*, i8** %7
%44 = call i32 (i32, i8*, i8*, ...) @print_message(i32 1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %43)
br label %45
45: ; preds = %42, %40
br label %46
46: ; preds = %45, %32
%47 = load i8*, i8** %9
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@PATH_MAX = global i32 0
@.str = [18 x i8] c"cp \22%s\22 -> \22%s\22.\0A\00"
@.str.1 = [13 x i8] c"mkdir \22%s\22.\0A\00"
@.str.2 = [11 x i8] c"skip \22%s\22\0A\00"
define i32 @demo(i8* %0, i8* %1, i8* %2, %struct.stat* nocapture %3) {
%5 = load i32, i32* @PATH_MAX
%6 = add nsw i32 %5, 1
%7 = zext i32 %6 to i64
%8 = alloca i8, i64 %7
%9 = alloca i8, i64 %7
%10 = call i32 @make_path(i8* %8, i8* %0, i8* %2)
%11 = call i32 @make_path(i8* %9, i8* %1, i8* %2)
%12 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%13 = load i32, i32* %12
%14 = call i64 @S_ISREG(i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %4
%17 = call i32 (i32, i8*, i8*, ...) @print_message(i32 4, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %9)
br label %26
18: ; preds = %4
%19 = load i32, i32* %12
%20 = call i64 @S_ISDIR(i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %18
%23 = call i32 (i32, i8*, i8*, ...) @print_message(i32 4, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %26
24: ; preds = %18
%25 = call i32 (i32, i8*, i8*, ...) @print_message(i32 1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %2)
br label %26
26: ; preds = %22, %24, %16
ret i32 0
}