#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_add_subnode(void *, int /*<<< orphan*/, char *);
int fdt_first_property_offset(void *, int);
int fdt_get_path(void *, int, char *, int);
char *fdt_getprop_by_offset(void *, int, char const **, int *);
int fdt_next_property_offset(void *, int);
int fdt_setprop_placeholder(void *, int, char const *, int, void **);
int fdt_subnode_offset(void *, int, char *);
int fdt_subnode_offset_namelen(void *, int /*<<< orphan*/, char const *, int);
int get_path_len(void *, int);
char const *memchr(char const *, char, int);
scalar_t__ memcmp(char const *, char *, int);
int /*<<< orphan*/ memcpy(char *, char const *, int);
int overlay_get_target(void *, void *, int, char const **);
char *strchr(char const *, char);
int /*<<< orphan*/ strlen(char const *);
int overlay_symbol_update(void *fdt, void *fdto) {
  int root_sym, ov_sym, prop, path_len, fragment, target;
  int len, frag_name_len, ret, rel_path_len;
  const char *s, *e;
  const char *path;
  const char *name;
  const char *frag_name;
  const char *rel_path;
  const char *target_path;
  char *buf;
  void *p;
  ov_sym = fdt_subnode_offset(fdto, 0, "__symbols__");
  if (ov_sym < 0)
    return 0;
  root_sym = fdt_subnode_offset(fdt, 0, "__symbols__");
  if (root_sym == -1)
    root_sym = fdt_add_subnode(fdt, 0, "__symbols__");
  if (root_sym < 0)
    return root_sym;
  for (prop = fdt_first_property_offset(fdto, ov_sym); prop >= 0;
       prop = fdt_next_property_offset(fdto, prop)) {
    path = fdt_getprop_by_offset(fdto, prop, &name, &path_len);
    if (!path)
      return path_len;
    if (path_len < 1 || memchr(path, '\0', path_len) != &path[path_len - 1])
      return -15;
    e = path + path_len;
    if (*path != '/')
      return -15;
    s = strchr(path + 1, '/');
    if (!s)
      return -16;
    frag_name = path + 1;
    frag_name_len = s - path - 1;
    len = sizeof("/__overlay__/") - 1;
    if ((e - s) < len || memcmp(s, "/__overlay__/", len))
      return -16;
    rel_path = s + len;
    rel_path_len = e - rel_path;
    ret = fdt_subnode_offset_namelen(fdto, 0, frag_name, frag_name_len);
    if (ret < 0)
      return -16;
    fragment = ret;
    ret = fdt_subnode_offset(fdto, fragment, "__overlay__");
    if (ret < 0)
      return -16;
    ret = overlay_get_target(fdt, fdto, fragment, &target_path);
    if (ret < 0)
      return ret;
    target = ret;
    if (!target_path) {
      ret = get_path_len(fdt, target);
      if (ret < 0)
        return ret;
      len = ret;
    } else {
      len = strlen(target_path);
    }
    ret = fdt_setprop_placeholder(fdt, root_sym, name,
                                  len + (len > 1) + rel_path_len + 1, &p);
    if (ret < 0)
      return ret;
    if (!target_path) {
      ret = overlay_get_target(fdt, fdto, fragment, &target_path);
      if (ret < 0)
        return ret;
      target = ret;
    }
    buf = p;
    if (len > 1) {
      if (!target_path) {
        ret = fdt_get_path(fdt, target, buf, len + 1);
        if (ret < 0)
          return ret;
      } else
        memcpy(buf, target_path, len + 1);
    } else
      len--;
    buf[len] = '/';
    memcpy(buf + len + 1, rel_path, rel_path_len);
    buf[len + 1 + rel_path_len] = '\0';
  }
  return 0;
}


x86 assembly (clang, -O0):
<overlay_symbol_update>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
lea    0xdf0(%rip),%rdx
call   10f0 <fdt_subnode_offset@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    122e <overlay_symbol_update+0x3e>
movl   $0x0,-0x4(%rbp)
jmp    15f8 <overlay_symbol_update+0x408>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
lea    0xdc5(%rip),%rdx
call   10f0 <fdt_subnode_offset@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1262 <overlay_symbol_update+0x72>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
lea    0xda6(%rip),%rdx
call   10b0 <fdt_add_subnode@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1277 <overlay_symbol_update+0x87>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    15f8 <overlay_symbol_update+0x408>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1030 <fdt_first_property_offset@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     15f1 <overlay_symbol_update+0x401>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    -0x60(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1110 <fdt_getprop_by_offset@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    12be <overlay_symbol_update+0xce>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    15f8 <overlay_symbol_update+0x408>
cmpl   $0x1,-0x28(%rbp)
jl     12ef <overlay_symbol_update+0xff>
mov    -0x58(%rbp),%rdi
mov    -0x28(%rbp),%edx
xor    %esi,%esi
call   1090 <memchr@plt>
mov    -0x58(%rbp),%rcx
mov    -0x28(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
je     12fb <overlay_symbol_update+0x10b>
movl   $0xfffffff1,-0x4(%rbp)
jmp    15f8 <overlay_symbol_update+0x408>
mov    -0x58(%rbp),%rax
movslq -0x28(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x58(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     1326 <overlay_symbol_update+0x136>
movl   $0xfffffff1,-0x4(%rbp)
jmp    15f8 <overlay_symbol_update+0x408>
mov    -0x58(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2f,%esi
call   1080 <strchr@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1353 <overlay_symbol_update+0x163>
movl   $0xfffffff0,-0x4(%rbp)
jmp    15f8 <overlay_symbol_update+0x408>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x68(%rbp)
mov    -0x48(%rbp),%rax
mov    -0x58(%rbp),%rcx
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,-0x38(%rbp)
movl   $0xd,-0x34(%rbp)
mov    -0x50(%rbp),%rax
mov    -0x48(%rbp),%rcx
sub    %rcx,%rax
movslq -0x34(%rbp),%rcx
cmp    %rcx,%rax
jl     13ad <overlay_symbol_update+0x1bd>
mov    -0x48(%rbp),%rdi
mov    -0x34(%rbp),%edx
lea    0xc6e(%rip),%rsi
call   10a0 <memcmp@plt>
cmp    $0x0,%rax
je     13b9 <overlay_symbol_update+0x1c9>
movl   $0xfffffff0,-0x4(%rbp)
jmp    15f8 <overlay_symbol_update+0x408>
mov    -0x48(%rbp),%rax
movslq -0x34(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x70(%rbp)
mov    -0x50(%rbp),%rax
mov    -0x70(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x68(%rbp),%rdx
mov    -0x38(%rbp),%ecx
xor    %esi,%esi
call   10d0 <fdt_subnode_offset_namelen@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    1401 <overlay_symbol_update+0x211>
movl   $0xfffffff0,-0x4(%rbp)
jmp    15f8 <overlay_symbol_update+0x408>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x2c(%rbp),%esi
lea    0xc05(%rip),%rdx
call   10f0 <fdt_subnode_offset@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    1433 <overlay_symbol_update+0x243>
movl   $0xfffffff0,-0x4(%rbp)
jmp    15f8 <overlay_symbol_update+0x408>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x2c(%rbp),%edx
lea    -0x78(%rbp),%rcx
call   1070 <overlay_get_target@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    145f <overlay_symbol_update+0x26f>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    15f8 <overlay_symbol_update+0x408>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x30(%rbp)
cmpq   $0x0,-0x78(%rbp)
jne    149f <overlay_symbol_update+0x2af>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%esi
call   1050 <get_path_len@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    1494 <overlay_symbol_update+0x2a4>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    15f8 <overlay_symbol_update+0x408>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    14ab <overlay_symbol_update+0x2bb>
mov    -0x78(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x60(%rbp),%rdx
mov    -0x34(%rbp),%ecx
cmpl   $0x1,-0x34(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%eax
add    %eax,%ecx
add    -0x40(%rbp),%ecx
add    $0x1,%ecx
lea    -0x88(%rbp),%r8
call   10e0 <fdt_setprop_placeholder@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    14f1 <overlay_symbol_update+0x301>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    15f8 <overlay_symbol_update+0x408>
cmpq   $0x0,-0x78(%rbp)
jne    152e <overlay_symbol_update+0x33e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x2c(%rbp),%edx
lea    -0x78(%rbp),%rcx
call   1070 <overlay_get_target@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    1528 <overlay_symbol_update+0x338>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    15f8 <overlay_symbol_update+0x408>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x88(%rbp),%rax
mov    %rax,-0x80(%rbp)
cmpl   $0x1,-0x34(%rbp)
jle    1599 <overlay_symbol_update+0x3a9>
cmpq   $0x0,-0x78(%rbp)
jne    1581 <overlay_symbol_update+0x391>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x80(%rbp),%rdx
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
call   1040 <fdt_get_path@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    157c <overlay_symbol_update+0x38c>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    15f8 <overlay_symbol_update+0x408>
jmp    1594 <overlay_symbol_update+0x3a4>
mov    -0x80(%rbp),%rdi
mov    -0x78(%rbp),%rsi
mov    -0x34(%rbp),%edx
add    $0x1,%edx
call   10c0 <memcpy@plt>
jmp    15a2 <overlay_symbol_update+0x3b2>
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
mov    -0x80(%rbp),%rax
movslq -0x34(%rbp),%rcx
movb   $0x2f,(%rax,%rcx,1)
mov    -0x80(%rbp),%rdi
movslq -0x34(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
mov    -0x70(%rbp),%rsi
mov    -0x40(%rbp),%edx
call   10c0 <memcpy@plt>
mov    -0x80(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
add    -0x40(%rbp),%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1100 <fdt_next_property_offset@plt>
mov    %eax,-0x24(%rbp)
jmp    1286 <overlay_symbol_update+0x96>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<overlay_symbol_update>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdi,0x8(%rsp)
lea    0xdf6(%rip),%rdx
xor    %r15d,%r15d
mov    %rsi,0x18(%rsp)
mov    %rsi,%rdi
xor    %esi,%esi
call   10f0 <fdt_subnode_offset@plt>
test   %eax,%eax
js     14be <overlay_symbol_update+0x2ce>
mov    %eax,%ebx
lea    0xdd3(%rip),%rdx
mov    0x8(%rsp),%rdi
xor    %esi,%esi
call   10f0 <fdt_subnode_offset@plt>
mov    %eax,%r15d
cmp    $0xffffffff,%eax
jne    1257 <overlay_symbol_update+0x67>
lea    0xdb8(%rip),%rdx
mov    0x8(%rsp),%rdi
xor    %esi,%esi
call   10b0 <fdt_add_subnode@plt>
mov    %eax,%r15d
test   %r15d,%r15d
mov    0x18(%rsp),%rdi
js     14be <overlay_symbol_update+0x2ce>
mov    %ebx,%esi
call   1030 <fdt_first_property_offset@plt>
mov    %eax,0x14(%rsp)
test   %eax,%eax
js     14bb <overlay_symbol_update+0x2cb>
mov    %r15d,0x34(%rsp)
mov    0x18(%rsp),%rdi
mov    0x14(%rsp),%esi
lea    0x40(%rsp),%rdx
lea    0x24(%rsp),%rcx
call   1110 <fdt_getprop_by_offset@plt>
mov    0x24(%rsp),%edx
test   %rax,%rax
je     14d0 <overlay_symbol_update+0x2e0>
mov    $0xfffffff1,%r15d
test   %edx,%edx
jle    14be <overlay_symbol_update+0x2ce>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
call   1090 <memchr@plt>
movslq 0x24(%rsp),%rbp
lea    (%rbx,%rbp,1),%rcx
add    $0xffffffffffffffff,%rcx
cmp    %rcx,%rax
jne    14be <overlay_symbol_update+0x2ce>
cmpb   $0x2f,(%rbx)
jne    14be <overlay_symbol_update+0x2ce>
lea    0x1(%rbx),%r14
mov    %r14,%rdi
mov    $0x2f,%esi
call   1080 <strchr@plt>
mov    $0xfffffff0,%r15d
test   %rax,%rax
je     14be <overlay_symbol_update+0x2ce>
mov    %rax,%r12
mov    %rbx,%r13
add    %rbp,%r13
mov    %r13,%rax
sub    %r12,%rax
cmp    $0xd,%rax
jl     14be <overlay_symbol_update+0x2ce>
mov    %r12,%rdi
lea    0xced(%rip),%rsi
mov    $0xd,%edx
call   10a0 <memcmp@plt>
test   %rax,%rax
jne    14be <overlay_symbol_update+0x2ce>
not    %ebx
add    %r12d,%ebx
mov    0x18(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    %r14,%rdx
mov    %ebx,%ecx
call   10d0 <fdt_subnode_offset_namelen@plt>
test   %eax,%eax
js     14be <overlay_symbol_update+0x2ce>
mov    %eax,%ebx
mov    %rbp,%rdi
mov    %eax,%esi
lea    0xcb9(%rip),%rdx
call   10f0 <fdt_subnode_offset@plt>
test   %eax,%eax
js     14be <overlay_symbol_update+0x2ce>
mov    0x8(%rsp),%rdi
mov    0x18(%rsp),%rsi
mov    %ebx,%edx
lea    0x28(%rsp),%rcx
call   1070 <overlay_get_target@plt>
mov    %eax,%ebp
test   %eax,%eax
js     14da <overlay_symbol_update+0x2ea>
mov    0x28(%rsp),%rdi
test   %rdi,%rdi
je     13a2 <overlay_symbol_update+0x1b2>
call   1060 <strlen@plt>
mov    %eax,%r14d
jmp    13bc <overlay_symbol_update+0x1cc>
mov    0x8(%rsp),%rdi
mov    %ebp,%esi
call   1050 <get_path_len@plt>
mov    %eax,%r14d
mov    %eax,%r15d
test   %eax,%eax
js     14be <overlay_symbol_update+0x2ce>
add    $0xd,%r12
sub    %r12d,%r13d
mov    0x40(%rsp),%rdx
xor    %eax,%eax
cmp    $0x2,%r14d
setge  %al
lea    (%r14,%r13,1),%ecx
add    $0x1,%ecx
add    %eax,%ecx
mov    0x8(%rsp),%rdi
mov    0x34(%rsp),%esi
lea    0x38(%rsp),%r8
call   10e0 <fdt_setprop_placeholder@plt>
test   %eax,%eax
js     14d5 <overlay_symbol_update+0x2e5>
cmpq   $0x0,0x28(%rsp)
jne    1420 <overlay_symbol_update+0x230>
mov    0x8(%rsp),%rdi
mov    0x18(%rsp),%rsi
mov    %ebx,%edx
lea    0x28(%rsp),%rcx
call   1070 <overlay_get_target@plt>
mov    %eax,%ebp
mov    %eax,%r15d
test   %eax,%eax
js     14be <overlay_symbol_update+0x2ce>
mov    0x38(%rsp),%rbx
cmp    $0x2,%r14d
jl     1450 <overlay_symbol_update+0x260>
lea    0x1(%r14),%ecx
mov    0x28(%rsp),%rsi
test   %rsi,%rsi
je     1456 <overlay_symbol_update+0x266>
mov    %rbx,%rdi
mov    %ecx,%edx
call   10c0 <memcpy@plt>
jmp    1470 <overlay_symbol_update+0x280>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xffffffff,%r14d
jmp    1470 <overlay_symbol_update+0x280>
mov    0x8(%rsp),%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1040 <fdt_get_path@plt>
test   %eax,%eax
js     14d5 <overlay_symbol_update+0x2e5>
nopl   0x0(%rax)
mov    %rbx,%rbp
movslq %r14d,%rbx
movb   $0x2f,0x0(%rbp,%rbx,1)
lea    (%rbx,%rbp,1),%rdi
add    $0x1,%rdi
mov    %r12,%rsi
mov    %r13d,%edx
call   10c0 <memcpy@plt>
lea    (%rbx,%r13,1),%eax
add    $0x1,%eax
cltq
movb   $0x0,0x0(%rbp,%rax,1)
mov    0x18(%rsp),%rdi
mov    0x14(%rsp),%esi
call   1100 <fdt_next_property_offset@plt>
xor    %r15d,%r15d
mov    %eax,0x14(%rsp)
test   %eax,%eax
jns    127d <overlay_symbol_update+0x8d>
jmp    14be <overlay_symbol_update+0x2ce>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %edx,%r15d
jmp    14be <overlay_symbol_update+0x2ce>
mov    %eax,%r15d
jmp    14be <overlay_symbol_update+0x2ce>
mov    %ebp,%r15d
jmp    14be <overlay_symbol_update+0x2ce>

LLVM IR (-O0):
@.str = [12 x i8] c"__symbols__\00"
@.str.1 = [14 x i8] c"/__overlay__/\00"
@.str.2 = [12 x i8] c"__overlay__\00"
define i32 @overlay_symbol_update(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i8*
%21 = alloca i8*
%22 = alloca i8*
%23 = alloca i8*
%24 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%25 = load i8*, i8** %5
%26 = call i32 @fdt_subnode_offset(i8* %25, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 %26, i32* %7
%27 = load i32, i32* %7
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %2
store i32 0, i32* %3
br label %250
30: ; preds = %2
%31 = load i8*, i8** %4
%32 = call i32 @fdt_subnode_offset(i8* %31, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 %32, i32* %6
%33 = load i32, i32* %6
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %38
35: ; preds = %30
%36 = load i8*, i8** %4
%37 = call i32 @fdt_add_subnode(i8* %36, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 %37, i32* %6
br label %38
38: ; preds = %35, %30
%39 = load i32, i32* %6
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = load i32, i32* %6
store i32 %42, i32* %3
br label %250
43: ; preds = %38
%44 = load i8*, i8** %5
%45 = load i32, i32* %7
%46 = call i32 @fdt_first_property_offset(i8* %44, i32 %45)
store i32 %46, i32* %8
br label %47
47: ; preds = %245, %43
%48 = load i32, i32* %8
%49 = icmp sge i32 %48, 0
br i1 %49, label %50, label %249
50: ; preds = %47
%51 = load i8*, i8** %5
%52 = load i32, i32* %8
%53 = call i8* @fdt_getprop_by_offset(i8* %51, i32 %52, i8** %19, i32* %9)
store i8* %53, i8** %18
%54 = load i8*, i8** %18
%55 = icmp ne i8* %54, null
br i1 %55, label %58, label %56
56: ; preds = %50
%57 = load i32, i32* %9
store i32 %57, i32* %3
br label %250
58: ; preds = %50
%59 = load i32, i32* %9
%60 = icmp slt i32 %59, 1
br i1 %60, label %71, label %61
61: ; preds = %58
%62 = load i8*, i8** %18
%63 = load i32, i32* %9
%64 = call i8* @memchr(i8* %62, i8 signext 0, i32 %63)
%65 = load i8*, i8** %18
%66 = load i32, i32* %9
%67 = sub nsw i32 %66, 1
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %65, i64 %68
%70 = icmp ne i8* %64, %69
br i1 %70, label %71, label %72
71: ; preds = %61, %58
store i32 -15, i32* %3
br label %250
72: ; preds = %61
%73 = load i8*, i8** %18
%74 = load i32, i32* %9
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %73, i64 %75
store i8* %76, i8** %17
%77 = load i8*, i8** %18
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = icmp ne i32 %79, 47
br i1 %80, label %81, label %82
81: ; preds = %72
store i32 -15, i32* %3
br label %250
82: ; preds = %72
%83 = load i8*, i8** %18
%84 = getelementptr inbounds i8, i8* %83, i64 1
%85 = call i8* @strchr(i8* %84, i8 signext 47)
store i8* %85, i8** %16
%86 = load i8*, i8** %16
%87 = icmp ne i8* %86, null
br i1 %87, label %89, label %88
88: ; preds = %82
store i32 -16, i32* %3
br label %250
89: ; preds = %82
%90 = load i8*, i8** %18
%91 = getelementptr inbounds i8, i8* %90, i64 1
store i8* %91, i8** %20
%92 = load i8*, i8** %16
%93 = load i8*, i8** %18
%94 = ptrtoint i8* %92 to i64
%95 = ptrtoint i8* %93 to i64
%96 = sub i64 %94, %95
%97 = sub nsw i64 %96, 1
%98 = trunc i64 %97 to i32
store i32 %98, i32* %13
store i32 13, i32* %12
%99 = load i8*, i8** %17
%100 = load i8*, i8** %16
%101 = ptrtoint i8* %99 to i64
%102 = ptrtoint i8* %100 to i64
%103 = sub i64 %101, %102
%104 = load i32, i32* %12
%105 = sext i32 %104 to i64
%106 = icmp slt i64 %103, %105
br i1 %106, label %112, label %107
107: ; preds = %89
%108 = load i8*, i8** %16
%109 = load i32, i32* %12
%110 = call i64 @memcmp(i8* %108, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %109)
%111 = icmp ne i64 %110, 0
br i1 %111, label %112, label %113
112: ; preds = %107, %89
store i32 -16, i32* %3
br label %250
113: ; preds = %107
%114 = load i8*, i8** %16
%115 = load i32, i32* %12
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds i8, i8* %114, i64 %116
store i8* %117, i8** %21
%118 = load i8*, i8** %17
%119 = load i8*, i8** %21
%120 = ptrtoint i8* %118 to i64
%121 = ptrtoint i8* %119 to i64
%122 = sub i64 %120, %121
%123 = trunc i64 %122 to i32
store i32 %123, i32* %15
%124 = load i8*, i8** %5
%125 = load i8*, i8** %20
%126 = load i32, i32* %13
%127 = call i32 @fdt_subnode_offset_namelen(i8* %124, i32 0, i8* %125, i32 %126)
store i32 %127, i32* %14
%128 = load i32, i32* %14
%129 = icmp slt i32 %128, 0
br i1 %129, label %130, label %131
130: ; preds = %113
store i32 -16, i32* %3
br label %250
131: ; preds = %113
%132 = load i32, i32* %14
store i32 %132, i32* %10
%133 = load i8*, i8** %5
%134 = load i32, i32* %10
%135 = call i32 @fdt_subnode_offset(i8* %133, i32 %134, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store i32 %135, i32* %14
%136 = load i32, i32* %14
%137 = icmp slt i32 %136, 0
br i1 %137, label %138, label %139
138: ; preds = %131
store i32 -16, i32* %3
br label %250
139: ; preds = %131
%140 = load i8*, i8** %4
%141 = load i8*, i8** %5
%142 = load i32, i32* %10
%143 = call i32 @overlay_get_target(i8* %140, i8* %141, i32 %142, i8** %22)
store i32 %143, i32* %14
%144 = load i32, i32* %14
%145 = icmp slt i32 %144, 0
br i1 %145, label %146, label %148
146: ; preds = %139
%147 = load i32, i32* %14
store i32 %147, i32* %3
br label %250
148: ; preds = %139
%149 = load i32, i32* %14
store i32 %149, i32* %11
%150 = load i8*, i8** %22
%151 = icmp ne i8* %150, null
br i1 %151, label %162, label %152
152: ; preds = %148
%153 = load i8*, i8** %4
%154 = load i32, i32* %11
%155 = call i32 @get_path_len(i8* %153, i32 %154)
store i32 %155, i32* %14
%156 = load i32, i32* %14
%157 = icmp slt i32 %156, 0
br i1 %157, label %158, label %160
158: ; preds = %152
%159 = load i32, i32* %14
store i32 %159, i32* %3
br label %250
160: ; preds = %152
%161 = load i32, i32* %14
store i32 %161, i32* %12
br label %165
162: ; preds = %148
%163 = load i8*, i8** %22
%164 = call i32 @strlen(i8* %163)
store i32 %164, i32* %12
br label %165
165: ; preds = %162, %160
%166 = load i8*, i8** %4
%167 = load i32, i32* %6
%168 = load i8*, i8** %19
%169 = load i32, i32* %12
%170 = load i32, i32* %12
%171 = icmp sgt i32 %170, 1
%172 = zext i1 %171 to i32
%173 = add nsw i32 %169, %172
%174 = load i32, i32* %15
%175 = add nsw i32 %173, %174
%176 = add nsw i32 %175, 1
%177 = call i32 @fdt_setprop_placeholder(i8* %166, i32 %167, i8* %168, i32 %176, i8** %24)
store i32 %177, i32* %14
%178 = load i32, i32* %14
%179 = icmp slt i32 %178, 0
br i1 %179, label %180, label %182
180: ; preds = %165
%181 = load i32, i32* %14
store i32 %181, i32* %3
br label %250
182: ; preds = %165
%183 = load i8*, i8** %22
%184 = icmp ne i8* %183, null
br i1 %184, label %196, label %185
185: ; preds = %182
%186 = load i8*, i8** %4
%187 = load i8*, i8** %5
%188 = load i32, i32* %10
%189 = call i32 @overlay_get_target(i8* %186, i8* %187, i32 %188, i8** %22)
store i32 %189, i32* %14
%190 = load i32, i32* %14
%191 = icmp slt i32 %190, 0
br i1 %191, label %192, label %194
192: ; preds = %185
%193 = load i32, i32* %14
store i32 %193, i32* %3
br label %250
194: ; preds = %185
%195 = load i32, i32* %14
store i32 %195, i32* %11
br label %196
196: ; preds = %194, %182
%197 = load i8*, i8** %24
store i8* %197, i8** %23
%198 = load i32, i32* %12
%199 = icmp sgt i32 %198, 1
br i1 %199, label %200, label %222
200: ; preds = %196
%201 = load i8*, i8** %22
%202 = icmp ne i8* %201, null
br i1 %202, label %215, label %203
203: ; preds = %200
%204 = load i8*, i8** %4
%205 = load i32, i32* %11
%206 = load i8*, i8** %23
%207 = load i32, i32* %12
%208 = add nsw i32 %207, 1
%209 = call i32 @fdt_get_path(i8* %204, i32 %205, i8* %206, i32 %208)
store i32 %209, i32* %14
%210 = load i32, i32* %14
%211 = icmp slt i32 %210, 0
br i1 %211, label %212, label %214
212: ; preds = %203
%213 = load i32, i32* %14
store i32 %213, i32* %3
br label %250
214: ; preds = %203
br label %221
215: ; preds = %200
%216 = load i8*, i8** %23
%217 = load i8*, i8** %22
%218 = load i32, i32* %12
%219 = add nsw i32 %218, 1
%220 = call i32 @memcpy(i8* %216, i8* %217, i32 %219)
br label %221
221: ; preds = %215, %214
br label %225
222: ; preds = %196
%223 = load i32, i32* %12
%224 = add nsw i32 %223, -1
store i32 %224, i32* %12
br label %225
225: ; preds = %222, %221
%226 = load i8*, i8** %23
%227 = load i32, i32* %12
%228 = sext i32 %227 to i64
%229 = getelementptr inbounds i8, i8* %226, i64 %228
store i8 47, i8* %229
%230 = load i8*, i8** %23
%231 = load i32, i32* %12
%232 = sext i32 %231 to i64
%233 = getelementptr inbounds i8, i8* %230, i64 %232
%234 = getelementptr inbounds i8, i8* %233, i64 1
%235 = load i8*, i8** %21
%236 = load i32, i32* %15
%237 = call i32 @memcpy(i8* %234, i8* %235, i32 %236)
%238 = load i8*, i8** %23
%239 = load i32, i32* %12
%240 = add nsw i32 %239, 1
%241 = load i32, i32* %15
%242 = add nsw i32 %240, %241
%243 = sext i32 %242 to i64
%244 = getelementptr inbounds i8, i8* %238, i64 %243
store i8 0, i8* %244
br label %245
245: ; preds = %225
%246 = load i8*, i8** %5
%247 = load i32, i32* %8
%248 = call i32 @fdt_next_property_offset(i8* %246, i32 %247)
store i32 %248, i32* %8
br label %47
249: ; preds = %47
store i32 0, i32* %3
br label %250
250: ; preds = %249, %212, %192, %180, %158, %146, %138, %130, %112, %88, %81, %71, %56, %41, %29
%251 = load i32, i32* %3
ret i32 %251
}

LLVM IR (-O2):
@.str = [12 x i8] c"__symbols__\00"
@.str.1 = [14 x i8] c"/__overlay__/\00"
@.str.2 = [12 x i8] c"__overlay__\00"
define i32 @overlay_symbol_update(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i8** %4 to i8*
%9 = bitcast i8** %5 to i8*
%10 = bitcast i8** %6 to i8*
%11 = tail call i32 @fdt_subnode_offset(i8* %1, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%12 = icmp slt i32 %11, 0
br i1 %12, label %121, label %13
13: ; preds = %2
%14 = tail call i32 @fdt_subnode_offset(i8* %0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @fdt_add_subnode(i8* %0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
%19 = phi i32 [ %17, %16 ], [ %14, %13 ]
%20 = icmp slt i32 %19, 0
br i1 %20, label %121, label %21
21: ; preds = %18
%22 = tail call i32 @fdt_first_property_offset(i8* %1, i32 %11)
%23 = icmp sgt i32 %22, -1
br i1 %23, label %24, label %121
24: ; preds = %21, %109
%25 = phi i32 [ %119, %109 ], [ %22, %21 ]
%26 = call i8* @fdt_getprop_by_offset(i8* %1, i32 %25, i8** %4, i32* %3)
%27 = icmp eq i8* %26, null
%28 = load i32, i32* %3
br i1 %27, label %121, label %29
29: ; preds = %24
%30 = icmp slt i32 %28, 1
br i1 %30, label %121, label %31
31: ; preds = %29
%32 = call i8* @memchr(i8* %26, i8 signext 0, i32 %28)
%33 = load i32, i32* %3
%34 = add nsw i32 %33, -1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %26, i64 %35
%37 = icmp eq i8* %32, %36
br i1 %37, label %38, label %121
38: ; preds = %31
%39 = sext i32 %33 to i64
%40 = getelementptr inbounds i8, i8* %26, i64 %39
%41 = load i8, i8* %26
%42 = icmp eq i8 %41, 47
br i1 %42, label %43, label %121
43: ; preds = %38
%44 = getelementptr inbounds i8, i8* %26, i64 1
%45 = call i8* @strchr(i8* %44, i8 signext 47)
%46 = icmp eq i8* %45, null
br i1 %46, label %121, label %47
47: ; preds = %43
%48 = ptrtoint i8* %45 to i64
%49 = ptrtoint i8* %26 to i64
%50 = xor i64 %49, -1
%51 = add i64 %48, %50
%52 = trunc i64 %51 to i32
%53 = ptrtoint i8* %40 to i64
%54 = sub i64 %53, %48
%55 = icmp slt i64 %54, 13
br i1 %55, label %121, label %56
56: ; preds = %47
%57 = call i64 @memcmp(i8* %45, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 13)
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %121
59: ; preds = %56
%60 = getelementptr inbounds i8, i8* %45, i64 13
%61 = ptrtoint i8* %60 to i64
%62 = sub i64 %53, %61
%63 = trunc i64 %62 to i32
%64 = call i32 @fdt_subnode_offset_namelen(i8* %1, i32 0, i8* %44, i32 %52)
%65 = icmp slt i32 %64, 0
br i1 %65, label %121, label %66
66: ; preds = %59
%67 = call i32 @fdt_subnode_offset(i8* %1, i32 %64, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%68 = icmp slt i32 %67, 0
br i1 %68, label %121, label %69
69: ; preds = %66
%70 = call i32 @overlay_get_target(i8* %0, i8* %1, i32 %64, i8** %5)
%71 = icmp slt i32 %70, 0
br i1 %71, label %121, label %72
72: ; preds = %69
%73 = load i8*, i8** %5
%74 = icmp eq i8* %73, null
br i1 %74, label %75, label %78
75: ; preds = %72
%76 = call i32 @get_path_len(i8* %0, i32 %70)
%77 = icmp slt i32 %76, 0
br i1 %77, label %121, label %80
78: ; preds = %72
%79 = call i32 @strlen(i8* %73)
br label %80
80: ; preds = %75, %78
%81 = phi i32 [ %79, %78 ], [ %76, %75 ]
%82 = load i8*, i8** %4
%83 = icmp sgt i32 %81, 1
%84 = zext i1 %83 to i32
%85 = add i32 %81, 1
%86 = add i32 %85, %63
%87 = add i32 %86, %84
%88 = call i32 @fdt_setprop_placeholder(i8* %0, i32 %19, i8* %82, i32 %87, i8** %6)
%89 = icmp slt i32 %88, 0
br i1 %89, label %121, label %90
90: ; preds = %80
%91 = load i8*, i8** %5
%92 = icmp eq i8* %91, null
br i1 %92, label %93, label %96
93: ; preds = %90
%94 = call i32 @overlay_get_target(i8* %0, i8* %1, i32 %64, i8** %5)
%95 = icmp slt i32 %94, 0
br i1 %95, label %121, label %96
96: ; preds = %93, %90
%97 = phi i32 [ %70, %90 ], [ %94, %93 ]
%98 = load i8*, i8** %6
br i1 %83, label %99, label %107
99: ; preds = %96
%100 = load i8*, i8** %5
%101 = icmp eq i8* %100, null
br i1 %101, label %102, label %105
102: ; preds = %99
%103 = call i32 @fdt_get_path(i8* %0, i32 %97, i8* %98, i32 %85)
%104 = icmp slt i32 %103, 0
br i1 %104, label %121, label %109
105: ; preds = %99
%106 = call i32 @memcpy(i8* %98, i8* %100, i32 %85)
br label %109
107: ; preds = %96
%108 = add nsw i32 %81, -1
br label %109
109: ; preds = %105, %102, %107
%110 = phi i32 [ %81, %105 ], [ %81, %102 ], [ %108, %107 ]
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i8, i8* %98, i64 %111
store i8 47, i8* %112
%113 = getelementptr inbounds i8, i8* %112, i64 1
%114 = call i32 @memcpy(i8* %113, i8* %60, i32 %63)
%115 = add i32 %63, 1
%116 = add i32 %115, %110
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds i8, i8* %98, i64 %117
store i8 0, i8* %118
%119 = call i32 @fdt_next_property_offset(i8* %1, i32 %25)
%120 = icmp sgt i32 %119, -1
br i1 %120, label %24, label %121
121: ; preds = %31, %29, %38, %43, %56, %47, %59, %66, %69, %75, %80, %93, %102, %109, %24, %21, %18, %2
%122 = phi i32 [ 0, %2 ], [ %19, %18 ], [ 0, %21 ], [ %28, %24 ], [ -15, %31 ], [ -15, %29 ], [ -15, %38 ], [ -16, %43 ], [ -16, %56 ], [ -16, %47 ], [ -16, %59 ], [ -16, %66 ], [ %70, %69 ], [ %76, %75 ], [ %88, %80 ], [ %94, %93 ], [ %103, %102 ], [ 0, %109 ]
ret i32 %122
}