#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 move_file(const char *srcpath, const char *destpath) {
  char cmd[2 * PATH_MAX + 4];
  int code;
  if (is_immutable(srcpath))
    return;
  if (is_immutable(destpath))
    return;
  logprintf("0 from: %s", srcpath);
  logprintf("0 to: %s", destpath);
  sysprintf("mv %s %s", srcpath, destpath);
}


x86 assembly (clang, -O0):
<move_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    $0x4,%eax
mov    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <is_immutable@plt>
cmp    $0x0,%rax
je     117b <move_file+0x4b>
movl   $0x1,-0x28(%rbp)
jmp    11d5 <move_file+0xa5>
mov    -0x10(%rbp),%rdi
call   1030 <is_immutable@plt>
cmp    $0x0,%rax
je     119a <move_file+0x6a>
movl   $0x1,-0x28(%rbp)
jmp    11d5 <move_file+0xa5>
mov    -0x8(%rbp),%rsi
lea    0xe5b(%rip),%rdi
call   1050 <logprintf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe56(%rip),%rdi
call   1050 <logprintf@plt>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe4b(%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):
<move_file>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <is_immutable@plt>
test   %rax,%rax
jne    1151 <move_file+0x21>
mov    %r14,%rdi
call   1030 <is_immutable@plt>
test   %rax,%rax
je     1159 <move_file+0x29>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xea0(%rip),%rdi
mov    %rbx,%rsi
call   1050 <logprintf@plt>
lea    0xe9c(%rip),%rdi
mov    %r14,%rsi
call   1050 <logprintf@plt>
lea    0xe96(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%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 = [9 x i8] c"mv %s %s\00"
define void @move_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, 4
%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** %3
%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 %32
19: ; preds = %2
%20 = load i8*, i8** %4
%21 = call i64 @is_immutable(i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19
store i32 1, i32* %8
br label %32
24: ; preds = %19
%25 = load i8*, i8** %3
%26 = call i32 @logprintf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = load i8*, i8** %4
%28 = call i32 @logprintf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = load i8*, i8** %3
%30 = load i8*, i8** %4
%31 = call i32 @sysprintf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %29, i8* %30)
store i32 0, i32* %8
br label %32
32: ; preds = %24, %23, %18
%33 = load i8*, i8** %5
%34 = load i32, i32* %8
switch i32 %34, label %36 [
i32 0, label %35
i32 1, label %35
]
35: ; preds = %32, %32
ret void
36: ; preds = %32
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 = [9 x i8] c"mv %s %s\00"
define void @move_file(i8* %0, i8* %1) {
%3 = tail call i64 @is_immutable(i8* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %12
5: ; preds = %2
%6 = tail call i64 @is_immutable(i8* %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %5
%9 = tail call i32 @logprintf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0)
%10 = tail call i32 @logprintf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%11 = tail call i32 @sysprintf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %1)
br label %12
12: ; preds = %5, %2, %8
ret void
}