#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_check_header(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_check_header(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_check_header@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   1060 <_fdt_offset_ptr_w@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
mov    -0x18(%rbp),%edx
sub    -0x14(%rbp),%edx
xor    %ecx,%ecx
call   1050 <_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_check_header@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   1060 <_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    1050 <_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_check_header(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_check_header(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
}