#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_begin_node(void *, char *);
int fdt_create(void *, int);
int fdt_end_node(void *);
int fdt_finish(void *);
int fdt_finish_reservemap(void *);
int fdt_open_into(void *, void *, int);
int fdt_create_empty_tree(void *buf, int bufsize) {
  int err;
  err = fdt_create(buf, bufsize);
  if (err)
    return err;
  err = fdt_finish_reservemap(buf);
  if (err)
    return err;
  err = fdt_begin_node(buf, "");
  if (err)
    return err;
  err = fdt_end_node(buf);
  if (err)
    return err;
  err = fdt_finish(buf);
  if (err)
    return err;
  return fdt_open_into(buf, buf, bufsize);
}


x86 assembly (clang, -O0):
<fdt_create_empty_tree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <fdt_create@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1193 <fdt_create_empty_tree+0x33>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1231 <fdt_create_empty_tree+0xd1>
mov    -0x10(%rbp),%rdi
call   1050 <fdt_finish_reservemap@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     11b4 <fdt_create_empty_tree+0x54>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1231 <fdt_create_empty_tree+0xd1>
mov    -0x10(%rbp),%rdi
lea    0xe41(%rip),%rsi
call   1040 <fdt_begin_node@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     11dc <fdt_create_empty_tree+0x7c>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1231 <fdt_create_empty_tree+0xd1>
mov    -0x10(%rbp),%rdi
call   1030 <fdt_end_node@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     11fd <fdt_create_empty_tree+0x9d>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1231 <fdt_create_empty_tree+0xd1>
mov    -0x10(%rbp),%rdi
call   1060 <fdt_finish@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     121e <fdt_create_empty_tree+0xbe>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1231 <fdt_create_empty_tree+0xd1>
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1080 <fdt_open_into@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fdt_create_empty_tree>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1070 <fdt_create@plt>
test   %eax,%eax
jne    11a8 <fdt_create_empty_tree+0x48>
mov    %rbx,%rdi
call   1050 <fdt_finish_reservemap@plt>
test   %eax,%eax
jne    11a8 <fdt_create_empty_tree+0x48>
lea    0xe7c(%rip),%rsi
mov    %rbx,%rdi
call   1040 <fdt_begin_node@plt>
test   %eax,%eax
jne    11a8 <fdt_create_empty_tree+0x48>
mov    %rbx,%rdi
call   1030 <fdt_end_node@plt>
test   %eax,%eax
jne    11a8 <fdt_create_empty_tree+0x48>
mov    %rbx,%rdi
call   1060 <fdt_finish@plt>
test   %eax,%eax
je     11af <fdt_create_empty_tree+0x4f>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1080 <fdt_open_into@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i32 @fdt_create_empty_tree(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%7 = load i8*, i8** %4
%8 = load i32, i32* %5
%9 = call i32 @fdt_create(i8* %7, i32 %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = load i32, i32* %6
store i32 %13, i32* %3
br label %47
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = call i32 @fdt_finish_reservemap(i8* %15)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = load i32, i32* %6
store i32 %20, i32* %3
br label %47
21: ; preds = %14
%22 = load i8*, i8** %4
%23 = call i32 @fdt_begin_node(i8* %22, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = load i32, i32* %6
store i32 %27, i32* %3
br label %47
28: ; preds = %21
%29 = load i8*, i8** %4
%30 = call i32 @fdt_end_node(i8* %29)
store i32 %30, i32* %6
%31 = load i32, i32* %6
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = load i32, i32* %6
store i32 %34, i32* %3
br label %47
35: ; preds = %28
%36 = load i8*, i8** %4
%37 = call i32 @fdt_finish(i8* %36)
store i32 %37, i32* %6
%38 = load i32, i32* %6
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = load i32, i32* %6
store i32 %41, i32* %3
br label %47
42: ; preds = %35
%43 = load i8*, i8** %4
%44 = load i8*, i8** %4
%45 = load i32, i32* %5
%46 = call i32 @fdt_open_into(i8* %43, i8* %44, i32 %45)
store i32 %46, i32* %3
br label %47
47: ; preds = %42, %40, %33, %26, %19, %12
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i32 @fdt_create_empty_tree(i8* %0, i32 %1) {
%3 = tail call i32 @fdt_create(i8* %0, i32 %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %19
5: ; preds = %2
%6 = tail call i32 @fdt_finish_reservemap(i8* %0)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %19
8: ; preds = %5
%9 = tail call i32 @fdt_begin_node(i8* %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %8
%12 = tail call i32 @fdt_end_node(i8* %0)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = tail call i32 @fdt_finish(i8* %0)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = tail call i32 @fdt_open_into(i8* %0, i8* %0, i32 %1)
br label %19
19: ; preds = %14, %11, %8, %5, %2, %17
%20 = phi i32 [ %18, %17 ], [ %3, %2 ], [ %6, %5 ], [ %9, %8 ], [ %12, %11 ], [ %15, %14 ]
ret i32 %20
}