#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_setprop_placeholder(void *, int, char const *, int, void **);
int /*<<< orphan*/ memcpy(void *, void const *, int);
int fdt_setprop(void *fdt, int nodeoffset, const char *name, const void *val,
                int len) {
  void *prop_data;
  int err;
  err = fdt_setprop_placeholder(fdt, nodeoffset, name, len, &prop_data);
  if (err)
    return err;
  if (len)
    memcpy(prop_data, val, len);
  return 0;
}


x86 assembly (clang, -O0):
<fdt_setprop>:
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
mov    -0x2c(%rbp),%ecx
lea    -0x38(%rbp),%r8
call   1040 <fdt_setprop_placeholder@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     116a <fdt_setprop+0x4a>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118b <fdt_setprop+0x6b>
cmpl   $0x0,-0x2c(%rbp)
je     1184 <fdt_setprop+0x64>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1030 <memcpy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fdt_setprop>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %r8d,%ebx
mov    %rcx,%r14
lea    0x8(%rsp),%r8
mov    %ebx,%ecx
call   1040 <fdt_setprop_placeholder@plt>
mov    %eax,%ebp
test   %ebx,%ebx
je     1153 <fdt_setprop+0x33>
test   %ebp,%ebp
jne    1153 <fdt_setprop+0x33>
mov    0x8(%rsp),%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1030 <memcpy@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @fdt_setprop(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 = load i32, i32* %11
%18 = call i32 @fdt_setprop_placeholder(i8* %14, i32 %15, i8* %16, i32 %17, i8** %12)
store i32 %18, i32* %13
%19 = load i32, i32* %13
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %5
%22 = load i32, i32* %13
store i32 %22, i32* %6
br label %32
23: ; preds = %5
%24 = load i32, i32* %11
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = load i8*, i8** %12
%28 = load i8*, i8** %10
%29 = load i32, i32* %11
%30 = call i32 @memcpy(i8* %27, i8* %28, i32 %29)
br label %31
31: ; preds = %26, %23
store i32 0, i32* %6
br label %32
32: ; preds = %31, %21
%33 = load i32, i32* %6
ret i32 %33
}

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