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


x86 assembly (clang, -O0):
<fdt_setprop_inplace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%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   1040 <fdt_getprop@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1179 <fdt_setprop_inplace+0x49>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d2 <fdt_setprop_inplace+0xa2>
mov    -0x3c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
je     1191 <fdt_setprop_inplace+0x61>
movl   $0xfffffffd,-0x4(%rbp)
jmp    11d2 <fdt_setprop_inplace+0xa2>
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    -0x4c(%rbp),%esi
mov    -0x48(%rbp),%rdx
mov    %eax,%ecx
mov    -0x28(%rbp),%r9
mov    -0x2c(%rbp),%eax
xor    %r8d,%r8d
mov    %eax,(%rsp)
call   1050 <fdt_setprop_inplace_namelen_partial@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fdt_setprop_inplace>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r8d,%r15d
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %esi,%r12d
mov    %rdi,%rbp
lea    0xc(%rsp),%rcx
call   1040 <fdt_getprop@plt>
mov    %rax,%rcx
mov    0xc(%rsp),%eax
test   %rcx,%rcx
je     118d <fdt_setprop_inplace+0x5d>
cmp    %r15d,%eax
mov    $0xfffffffd,%eax
jne    118d <fdt_setprop_inplace+0x5d>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r15d,(%rsp)
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %rbx,%rdx
mov    %eax,%ecx
xor    %r8d,%r8d
mov    %r14,%r9
call   1050 <fdt_setprop_inplace_namelen_partial@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
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(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 %36
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 %36
27: ; preds = %22
%28 = load i8*, i8** %7
%29 = load i32, i32* %8
%30 = load i8*, i8** %9
%31 = load i8*, i8** %9
%32 = call i32 @strlen(i8* %31)
%33 = load i8*, i8** %10
%34 = load i32, i32* %11
%35 = call i32 @fdt_setprop_inplace_namelen_partial(i8* %28, i32 %29, i8* %30, i32 %32, i32 0, i8* %33, i32 %34)
store i32 %35, i32* %6
br label %36
36: ; preds = %27, %26, %20
%37 = load i32, i32* %6
ret i32 %37
}

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(i8* %0, i32 %1, i8* %2, i32* %6)
%9 = icmp eq i8* %8, null
%10 = load i32, i32* %6
br i1 %9, label %16, label %11
11: ; preds = %5
%12 = icmp eq i32 %10, %4
br i1 %12, label %13, label %16
13: ; preds = %11
%14 = call i32 @strlen(i8* %2)
%15 = call i32 @fdt_setprop_inplace_namelen_partial(i8* %0, i32 %1, i8* %2, i32 %14, i32 0, i8* %3, i32 %4)
br label %16
16: ; preds = %5, %11, %13
%17 = phi i32 [ %15, %13 ], [ -3, %11 ], [ %10, %5 ]
ret i32 %17
}