#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 */
typedef int /*<<< orphan*/ mode_t;
typedef int /*<<< orphan*/ dev_t;

/* Variables and functions */
int _mv_error(char const *, int);
scalar_t__ mknod(char const *, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ unlink(char const *);
int _mv_single_nod(char const *src, char const *dst, mode_t mode, dev_t rdev) {
  if (mknod(dst, mode, rdev) != 0)
    return _mv_error(dst, 1);
  if (unlink(src) != 0)
    _mv_error(src, 0);
  return 0;
}


x86 assembly (clang, -O0):
<_mv_single_nod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1040 <mknod@plt>
cmp    $0x0,%rax
je     1175 <_mv_single_nod+0x45>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
call   1050 <_mv_error@plt>
mov    %eax,-0x4(%rbp)
jmp    119a <_mv_single_nod+0x6a>
mov    -0x10(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
je     1193 <_mv_single_nod+0x63>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1050 <_mv_error@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_mv_single_nod>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
mov    %edx,%esi
mov    %ecx,%edx
call   1040 <mknod@plt>
test   %rax,%rax
je     115f <_mv_single_nod+0x2f>
mov    %rbx,%rdi
mov    $0x1,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <_mv_error@plt>
mov    %r14,%rdi
call   1030 <unlink@plt>
test   %rax,%rax
je     1176 <_mv_single_nod+0x46>
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <_mv_error@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @_mv_single_nod(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%10 = load i8*, i8** %7
%11 = load i32, i32* %8
%12 = load i32, i32* %9
%13 = call i64 @mknod(i8* %10, i32 %11, i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %4
%16 = load i8*, i8** %7
%17 = call i32 @_mv_error(i8* %16, i32 1)
store i32 %17, i32* %5
br label %26
18: ; preds = %4
%19 = load i8*, i8** %6
%20 = call i64 @unlink(i8* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i8*, i8** %6
%24 = call i32 @_mv_error(i8* %23, i32 0)
br label %25
25: ; preds = %22, %18
store i32 0, i32* %5
br label %26
26: ; preds = %25, %15
%27 = load i32, i32* %5
ret i32 %27
}

LLVM IR (-O2):
define i32 @_mv_single_nod(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = tail call i64 @mknod(i8* %1, i32 %2, i32 %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call i32 @_mv_error(i8* %1, i32 1)
br label %14
9: ; preds = %4
%10 = tail call i64 @unlink(i8* %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 @_mv_error(i8* %0, i32 0)
br label %14
14: ; preds = %9, %12, %7
%15 = phi i32 [ %8, %7 ], [ 0, %12 ], [ 0, %9 ]
ret i32 %15
}