#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 */
typedef void entry;
typedef void archnode;

/* Variables and functions */
scalar_t__ av_namespace_get(void *);
void *av_namespace_next(void *);
void *av_namespace_subdir(void *, void *);
int /*<<< orphan*/ av_unref_obj(void *);
void arch_free_tree(struct entry *parent) {
  struct entry *ent;
  struct archnode *nod;
  ent = av_namespace_subdir(((void *)0), parent);
  while (ent != ((void *)0)) {
    struct entry *next;
    arch_free_tree(ent);
    next = av_namespace_next(ent);
    av_unref_obj(ent);
    ent = next;
  }
  nod = (struct archnode *)av_namespace_get(parent);
  av_unref_obj(nod);
  av_unref_obj(parent);
}


x86 assembly (clang, -O0):
<arch_free_tree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1040 <av_namespace_subdir@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11a4 <arch_free_tree+0x54>
mov    -0x10(%rbp),%rdi
call   1030 <arch_free_tree@plt>
mov    -0x10(%rbp),%rdi
call   1060 <av_namespace_next@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <av_unref_obj@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    116d <arch_free_tree+0x1d>
mov    -0x8(%rbp),%rdi
call   1070 <av_namespace_get@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <av_unref_obj@plt>
mov    -0x8(%rbp),%rdi
call   1050 <av_unref_obj@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arch_free_tree>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %edi,%edi
mov    %r14,%rsi
call   1040 <av_namespace_subdir@plt>
test   %rax,%rax
je     1193 <arch_free_tree+0x43>
mov    %rax,%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <arch_free_tree@plt>
mov    %rbx,%rdi
call   1060 <av_namespace_next@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1050 <av_unref_obj@plt>
mov    %r15,%rbx
test   %r15,%r15
jne    1170 <arch_free_tree+0x20>
mov    %r14,%rdi
call   1070 <av_namespace_get@plt>
mov    %rax,%rdi
call   1050 <av_unref_obj@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <av_unref_obj@plt>

LLVM IR (-O0):
%struct.entry = type opaque
%struct.archnode = type opaque
define void @arch_free_tree(%struct.entry* %0) {
%2 = alloca %struct.entry*
%3 = alloca %struct.entry*
%4 = alloca %struct.archnode*
%5 = alloca %struct.entry*
store %struct.entry* %0, %struct.entry** %2
%6 = load %struct.entry*, %struct.entry** %2
%7 = bitcast %struct.entry* %6 to i8*
%8 = call i8* @av_namespace_subdir(i8* null, i8* %7)
%9 = bitcast i8* %8 to %struct.entry*
store %struct.entry* %9, %struct.entry** %3
br label %10
10: ; preds = %13, %1
%11 = load %struct.entry*, %struct.entry** %3
%12 = icmp ne %struct.entry* %11, null
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = load %struct.entry*, %struct.entry** %3
%15 = load %struct.entry*, %struct.entry** %3
%16 = bitcast %struct.entry* %15 to i8*
%17 = call i8* @av_namespace_next(i8* %16)
%18 = bitcast i8* %17 to %struct.entry*
store %struct.entry* %18, %struct.entry** %5
%19 = load %struct.entry*, %struct.entry** %3
%20 = bitcast %struct.entry* %19 to i8*
%21 = call i32 @av_unref_obj(i8* %20)
%22 = load %struct.entry*, %struct.entry** %5
store %struct.entry* %22, %struct.entry** %3
br label %10
23: ; preds = %10
%24 = load %struct.entry*, %struct.entry** %2
%25 = bitcast %struct.entry* %24 to i8*
%26 = call i64 @av_namespace_get(i8* %25)
%27 = inttoptr i64 %26 to %struct.archnode*
store %struct.archnode* %27, %struct.archnode** %4
%28 = load %struct.archnode*, %struct.archnode** %4
%29 = bitcast %struct.archnode* %28 to i8*
%30 = call i32 @av_unref_obj(i8* %29)
%31 = load %struct.entry*, %struct.entry** %2
%32 = bitcast %struct.entry* %31 to i8*
%33 = call i32 @av_unref_obj(i8* %32)
ret void
}

LLVM IR (-O2):
%struct.entry = type opaque
define void @arch_free_tree(%struct.entry* %0) {
%2 = bitcast %struct.entry* %0 to i8*
%3 = tail call i8* @av_namespace_subdir(i8* null, i8* %2)
%4 = icmp eq i8* %3, null
br i1 %4, label %11, label %5
5: ; preds = %1, %5
%6 = phi i8* [ %8, %5 ], [ %3, %1 ]
%7 = bitcast i8* %6 to %struct.entry*
tail call void @arch_free_tree(%struct.entry* %7)
%8 = tail call i8* @av_namespace_next(i8* %6)
%9 = tail call i32 @av_unref_obj(i8* %6)
%10 = icmp eq i8* %8, null
br i1 %10, label %11, label %5
11: ; preds = %5, %1
%12 = tail call i64 @av_namespace_get(i8* %2)
%13 = inttoptr i64 %12 to i8*
%14 = tail call i32 @av_unref_obj(i8* %13)
%15 = tail call i32 @av_unref_obj(i8* %2)
ret void
}