#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 */
void *fdt_getprop_w(void *, int, char const *, int *);
int /*<<< orphan*/ memcpy(void *, void const *, int);
int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
                        const void *val, int len) {
  void *propval;
  int proplen;
  propval = fdt_getprop_w(fdt, nodeoffset, name, &proplen);
  if (!propval)
    return proplen;
  if (proplen != len)
    return -3;
  memcpy(propval, val, len);
  return 0;
}


x86 assembly (clang, -O0):
<fdt_setprop_inplace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
lea    -0x3c(%rbp),%rcx
call   1030 <fdt_getprop_w@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1169 <fdt_setprop_inplace+0x49>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1198 <fdt_setprop_inplace+0x78>
mov    -0x3c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
je     1181 <fdt_setprop_inplace+0x61>
movl   $0xfffffffd,-0x4(%rbp)
jmp    1198 <fdt_setprop_inplace+0x78>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fdt_setprop_inplace>:
push   %r14
push   %rbx
push   %rax
mov    %r8d,%ebx
mov    %rcx,%r14
lea    0x4(%rsp),%rcx
call   1030 <fdt_getprop_w@plt>
mov    %rax,%rdi
mov    0x4(%rsp),%eax
test   %rdi,%rdi
je     1155 <fdt_setprop_inplace+0x35>
cmp    %ebx,%eax
mov    $0xfffffffd,%eax
jne    1155 <fdt_setprop_inplace+0x35>
mov    %r14,%rsi
mov    %ebx,%edx
call   1040 <memcpy@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @fdt_setprop_inplace(i8* %0, i32 %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = bitcast i32* %6 to i8*
%8 = call i8* @fdt_getprop_w(i8* %0, i32 %1, i8* %2, i32* %6)
%9 = icmp eq i8* %8, null
%10 = load i32, i32* %6
br i1 %9, label %15, label %11
11: ; preds = %5
%12 = icmp eq i32 %10, %4
br i1 %12, label %13, label %15
13: ; preds = %11
%14 = call i32 @memcpy(i8* %8, i8* %3, i32 %4)
br label %15
15: ; preds = %5, %11, %13
%16 = phi i32 [ 0, %13 ], [ -3, %11 ], [ %10, %5 ]
ret i32 %16
}