#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 fdt_node_end_offset_(void *, int);
int /*<<< orphan*/ fdt_offset_ptr_w_(void *, int);
int fdt_rw_probe_(void *);
int fdt_splice_struct_(void *, int /*<<< orphan*/, int, int /*<<< orphan*/);
int fdt_del_node(void *fdt, int nodeoffset) {
  int endoffset;
  {
    int err_;
    if ((err_ = fdt_rw_probe_(fdt)) != 0)
      return err_;
  };
  endoffset = fdt_node_end_offset_(fdt, nodeoffset);
  if (endoffset < 0)
    return endoffset;
  return fdt_splice_struct_(fdt, fdt_offset_ptr_w_(fdt, nodeoffset),
                            endoffset - nodeoffset, 0);
}


x86 assembly (clang, -O0):
<fdt_del_node>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fdt_rw_probe_@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
je     116f <fdt_del_node+0x2f>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11bd <fdt_del_node+0x7d>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <fdt_node_end_offset_@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1193 <fdt_del_node+0x53>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11bd <fdt_del_node+0x7d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <fdt_offset_ptr_w_@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
mov    -0x18(%rbp),%edx
sub    -0x14(%rbp),%edx
xor    %ecx,%ecx
call   1060 <fdt_splice_struct_@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fdt_del_node>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
call   1030 <fdt_rw_probe_@plt>
mov    %eax,%ebp
test   %eax,%eax
je     115c <fdt_del_node+0x1c>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <fdt_node_end_offset_@plt>
mov    %eax,%ebp
test   %eax,%eax
js     1155 <fdt_del_node+0x15>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1050 <fdt_offset_ptr_w_@plt>
sub    %r14d,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
mov    %ebp,%edx
xor    %ecx,%ecx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <fdt_splice_struct_@plt>

LLVM IR (-O0):
define i32 @fdt_del_node(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%8 = load i8*, i8** %4
%9 = call i32 @fdt_rw_probe_(i8* %8)
store i32 %9, i32* %7
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = load i32, i32* %7
store i32 %12, i32* %3
br label %30
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = load i32, i32* %5
%16 = call i32 @fdt_node_end_offset_(i8* %14, i32 %15)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = load i32, i32* %6
store i32 %20, i32* %3
br label %30
21: ; preds = %13
%22 = load i8*, i8** %4
%23 = load i8*, i8** %4
%24 = load i32, i32* %5
%25 = call i32 @fdt_offset_ptr_w_(i8* %23, i32 %24)
%26 = load i32, i32* %6
%27 = load i32, i32* %5
%28 = sub nsw i32 %26, %27
%29 = call i32 @fdt_splice_struct_(i8* %22, i32 %25, i32 %28, i32 0)
store i32 %29, i32* %3
br label %30
30: ; preds = %21, %19, %11
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
define i32 @fdt_del_node(i8* %0, i32 %1) {
%3 = tail call i32 @fdt_rw_probe_(i8* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %12
5: ; preds = %2
%6 = tail call i32 @fdt_node_end_offset_(i8* %0, i32 %1)
%7 = icmp slt i32 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = tail call i32 @fdt_offset_ptr_w_(i8* %0, i32 %1)
%10 = sub nsw i32 %6, %1
%11 = tail call i32 @fdt_splice_struct_(i8* %0, i32 %9, i32 %10, i32 0)
br label %12
12: ; preds = %5, %2, %8
%13 = phi i32 [ %11, %8 ], [ %3, %2 ], [ %6, %5 ]
ret i32 %13
}