#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 */

/* Variables and functions */
int PATH_MAX;
scalar_t__ is_immutable(char const *);
int /*<<< orphan*/ logprintf(char *, char const *);
int /*<<< orphan*/ sysprintf(char *, char const *, char const *);
void copy_file(const char *srcpath, const char *destpath) {
  char cmd[2 * PATH_MAX + 8];
  int code;
  if (is_immutable(destpath))
    return;
  logprintf("0 from: %s", srcpath);
  logprintf("0 to: %s", destpath);
  sysprintf("cp -rf %s %s", srcpath, destpath);
}


x86 assembly (clang, -O0):
<copy_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ea9(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
add    $0x8,%eax
mov    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <is_immutable@plt>
cmp    $0x0,%rax
je     117b <copy_file+0x4b>
movl   $0x1,-0x28(%rbp)
jmp    11b6 <copy_file+0x86>
mov    -0x8(%rbp),%rsi
lea    0xe7a(%rip),%rdi
call   1050 <logprintf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe75(%rip),%rdi
call   1050 <logprintf@plt>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe6a(%rip),%rdi
call   1040 <sysprintf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy_file>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <is_immutable@plt>
test   %rax,%rax
je     114f <copy_file+0x1f>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xeaa(%rip),%rdi
mov    %r14,%rsi
call   1050 <logprintf@plt>
lea    0xea6(%rip),%rdi
mov    %rbx,%rsi
call   1050 <logprintf@plt>
lea    0xea0(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <sysprintf@plt>

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [11 x i8] c"0 from: %s\00"
@.str.1 = [9 x i8] c"0 to: %s\00"
@.str.2 = [13 x i8] c"cp -rf %s %s\00"
define void @copy_file(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%9 = load i32, i32* @PATH_MAX
%10 = mul nsw i32 2, %9
%11 = add nsw i32 %10, 8
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %5
%14 = alloca i8, i64 %12
store i64 %12, i64* %6
%15 = load i8*, i8** %4
%16 = call i64 @is_immutable(i8* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %2
store i32 1, i32* %8
br label %27
19: ; preds = %2
%20 = load i8*, i8** %3
%21 = call i32 @logprintf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = load i8*, i8** %4
%23 = call i32 @logprintf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = load i8*, i8** %3
%25 = load i8*, i8** %4
%26 = call i32 @sysprintf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %24, i8* %25)
store i32 0, i32* %8
br label %27
27: ; preds = %19, %18
%28 = load i8*, i8** %5
%29 = load i32, i32* %8
switch i32 %29, label %31 [
i32 0, label %30
i32 1, label %30
]
30: ; preds = %27, %27
ret void
31: ; preds = %27
unreachable
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [11 x i8] c"0 from: %s\00"
@.str.1 = [9 x i8] c"0 to: %s\00"
@.str.2 = [13 x i8] c"cp -rf %s %s\00"
define void @copy_file(i8* %0, i8* %1) {
%3 = tail call i64 @is_immutable(i8* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = tail call i32 @logprintf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0)
%7 = tail call i32 @logprintf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%8 = tail call i32 @sysprintf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %1)
br label %9
9: ; preds = %2, %5
ret void
}