#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 */
struct vpdretriever {
  int dummy;
};
struct system {
  int dummy;
};

/* Variables and functions */
scalar_t__ build_system_sub(struct vpdretriever *, struct system *);
int /*<<< orphan*/ free_system(struct system *);
struct system *get_system(struct vpdretriever *);
struct system *get_component_tree(struct vpdretriever *dbenv) {
  struct system *root;
  if (!dbenv)
    return NULL;
  root = get_system(dbenv);
  if (!root)
    return NULL;
  if (build_system_sub(dbenv, root))
    goto geterr;
  return root;
geterr:
  free_system(root);
  return NULL;
}


x86 assembly (clang, -O0):
<get_component_tree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1154 <get_component_tree+0x24>
movq   $0x0,-0x8(%rbp)
jmp    11b3 <get_component_tree+0x83>
mov    -0x10(%rbp),%rdi
call   1030 <get_system@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1179 <get_component_tree+0x49>
movq   $0x0,-0x8(%rbp)
jmp    11b3 <get_component_tree+0x83>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <build_system_sub@plt>
cmp    $0x0,%rax
je     1195 <get_component_tree+0x65>
jmp    11a2 <get_component_tree+0x72>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11b3 <get_component_tree+0x83>
mov    -0x18(%rbp),%rdi
call   1040 <free_system@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_component_tree>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1161 <get_component_tree+0x31>
mov    %rdi,%rbx
call   1030 <get_system@plt>
test   %rax,%rax
je     1161 <get_component_tree+0x31>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <build_system_sub@plt>
test   %rax,%rax
je     1164 <get_component_tree+0x34>
mov    %r14,%rdi
call   1040 <free_system@plt>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.system = type { i32 }
%struct.vpdretriever = type { i32 }
define %struct.system* @get_component_tree(%struct.vpdretriever* %0) {
%2 = alloca %struct.system*
%3 = alloca %struct.vpdretriever*
%4 = alloca %struct.system*
store %struct.vpdretriever* %0, %struct.vpdretriever** %3
%5 = load %struct.vpdretriever*, %struct.vpdretriever** %3
%6 = icmp ne %struct.vpdretriever* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store %struct.system* null, %struct.system** %2
br label %25
8: ; preds = %1
%9 = load %struct.vpdretriever*, %struct.vpdretriever** %3
%10 = call %struct.system* @get_system(%struct.vpdretriever* %9)
store %struct.system* %10, %struct.system** %4
%11 = load %struct.system*, %struct.system** %4
%12 = icmp ne %struct.system* %11, null
br i1 %12, label %14, label %13
13: ; preds = %8
store %struct.system* null, %struct.system** %2
br label %25
14: ; preds = %8
%15 = load %struct.vpdretriever*, %struct.vpdretriever** %3
%16 = load %struct.system*, %struct.system** %4
%17 = call i64 @build_system_sub(%struct.vpdretriever* %15, %struct.system* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
br label %22
20: ; preds = %14
%21 = load %struct.system*, %struct.system** %4
store %struct.system* %21, %struct.system** %2
br label %25
22: ; preds = %19
%23 = load %struct.system*, %struct.system** %4
%24 = call i32 @free_system(%struct.system* %23)
store %struct.system* null, %struct.system** %2
br label %25
25: ; preds = %22, %20, %13, %7
%26 = load %struct.system*, %struct.system** %2
ret %struct.system* %26
}

LLVM IR (-O2):
%struct.system = type { i32 }
%struct.vpdretriever = type { i32 }
define %struct.system* @get_component_tree(%struct.vpdretriever* %0) {
%2 = icmp eq %struct.vpdretriever* %0, null
br i1 %2, label %11, label %3
3: ; preds = %1
%4 = tail call %struct.system* @get_system(%struct.vpdretriever* %0)
%5 = icmp eq %struct.system* %4, null
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = tail call i64 @build_system_sub(%struct.vpdretriever* %0, %struct.system* %4)
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @free_system(%struct.system* %4)
br label %11
11: ; preds = %6, %3, %1, %9
%12 = phi %struct.system* [ null, %9 ], [ null, %1 ], [ null, %3 ], [ %4, %6 ]
ret %struct.system* %12
}