#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 /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, char *);
scalar_t__ rename(char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int test_moved_from_helper(char *oldpath, void *private) {
  char *newpath = (char *)private;
  if (rename(oldpath, newpath) < 0) {
    fprintf(stderr, "Cannot rename %s to %s: %s\n", oldpath, "/tmp/test_file",
            strerror(errno));
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<test_moved_from_helper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <rename@plt>
cmp    $0x0,%rax
jge    11aa <test_moved_from_helper+0x7a>
mov    0x2e7a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rdx
mov    %rax,%r8
lea    0xe6e(%rip),%rsi
lea    0xe83(%rip),%rcx
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b1 <test_moved_from_helper+0x81>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_moved_from_helper>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <rename@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jns    117c <test_moved_from_helper+0x4c>
mov    0x2e94(%rip),%rax
mov    (%rax),%ebp
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xe9d(%rip),%rsi
lea    0xeb2(%rip),%rcx
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%r8
call   1030 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"Cannot rename %s to %s: %s\0A\00"
@.str.1 = [15 x i8] c"/tmp/test_file\00"
@errno = global i32 0
define i32 @test_moved_from_helper(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
store i8* %7, i8** %6
%8 = load i8*, i8** %4
%9 = load i8*, i8** %6
%10 = call i64 @rename(i8* %8, i8* %9)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %4
%15 = load i32, i32* @errno
%16 = call i8* @strerror(i32 %15)
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %14, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %16)
store i32 -1, i32* %3
br label %19
18: ; preds = %2
store i32 0, i32* %3
br label %19
19: ; preds = %18, %12
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"Cannot rename %s to %s: %s\0A\00"
@.str.1 = [15 x i8] c"/tmp/test_file\00"
@errno = global i32 0
define i32 @test_moved_from_helper(i8* %0, i8* nocapture %1) {
%3 = tail call i64 @rename(i8* %0, i8* %1)
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i32, i32* @errno
%8 = tail call i8* @strerror(i32 %7)
%9 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %8)
br label %10
10: ; preds = %2, %5
%11 = phi i32 [ -1, %5 ], [ 0, %2 ]
ret i32 %11
}