#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;
struct archive {
  int dummy;
};

/* Variables and functions */
scalar_t__ av_arch_isroot(struct archive *, void *);
void *av_arch_resolve(struct archive *, char const *, int, int);
int /*<<< orphan*/ av_log(int, char *, ...);
scalar_t__ av_namespace_get(void *);
int /*<<< orphan*/ av_namespace_setflags(void *, int, int /*<<< orphan*/);
int /*<<< orphan*/ av_unref_obj(void *);
struct entry *av_arch_create(struct archive *arch, const char *path,
                             int flags) {
  struct archnode *nod;
  struct entry *ent;
  ent = av_arch_resolve(arch, path, 1, flags);
  if (ent == ((void *)0))
    return ((void *)0);
  if (av_arch_isroot(arch, ent)) {
    av_log(002, "Empty filename");
    av_unref_obj(ent);
    return ((void *)0);
  }
  nod = (struct archnode *)av_namespace_get(ent);
  if (nod != ((void *)0)) {
    av_log(002, "Entry for %s already exists", path);
    av_unref_obj(ent);
    return ((void *)0);
  }
  av_namespace_setflags(ent, flags, 0);
  return ent;
}


x86 assembly (clang, -O0):
<av_arch_create>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%ecx
mov    $0x1,%edx
call   1040 <av_arch_resolve@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11a4 <av_arch_create+0x44>
movq   $0x0,-0x8(%rbp)
jmp    123f <av_arch_create+0xdf>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1060 <av_arch_isroot@plt>
cmp    $0x0,%rax
je     11e4 <av_arch_create+0x84>
mov    $0x2,%edi
lea    0xe39(%rip),%rsi
mov    $0x0,%al
call   1080 <av_log@plt>
mov    -0x30(%rbp),%rdi
call   1050 <av_unref_obj@plt>
movq   $0x0,-0x8(%rbp)
jmp    123f <av_arch_create+0xdf>
mov    -0x30(%rbp),%rdi
call   1070 <av_namespace_get@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1229 <av_arch_create+0xc9>
mov    -0x18(%rbp),%rdx
mov    $0x2,%edi
lea    0xe03(%rip),%rsi
mov    $0x0,%al
call   1080 <av_log@plt>
mov    -0x30(%rbp),%rdi
call   1050 <av_unref_obj@plt>
movq   $0x0,-0x8(%rbp)
jmp    123f <av_arch_create+0xdf>
mov    -0x30(%rbp),%rdi
mov    -0x1c(%rbp),%esi
xor    %edx,%edx
call   1030 <av_namespace_setflags@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<av_arch_create>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%rbp
mov    $0x1,%edx
mov    %r15d,%ecx
call   1040 <av_arch_resolve@plt>
test   %rax,%rax
je     11ac <av_arch_create+0x4c>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    %rax,%rsi
call   1060 <av_arch_isroot@plt>
test   %rax,%rax
je     11b0 <av_arch_create+0x50>
lea    0xe64(%rip),%rsi
xor    %ebp,%ebp
mov    $0x2,%edi
xor    %eax,%eax
call   1080 <av_log@plt>
jmp    11d5 <av_arch_create+0x75>
xor    %ebp,%ebp
jmp    11dd <av_arch_create+0x7d>
mov    %rbx,%rdi
call   1070 <av_namespace_get@plt>
test   %rax,%rax
je     11eb <av_arch_create+0x8b>
lea    0xe4b(%rip),%rsi
xor    %ebp,%ebp
mov    $0x2,%edi
mov    %r14,%rdx
xor    %eax,%eax
call   1080 <av_log@plt>
mov    %rbx,%rdi
call   1050 <av_unref_obj@plt>
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
mov    %r15d,%esi
xor    %edx,%edx
call   1030 <av_namespace_setflags@plt>
mov    %rbx,%rbp
jmp    11dd <av_arch_create+0x7d>

LLVM IR (-O0):
%struct.entry = type opaque
%struct.archive = type { i32 }
%struct.archnode = type opaque
@.str = [15 x i8] c"Empty filename\00"
@.str.1 = [28 x i8] c"Entry for %s already exists\00"
define %struct.entry* @av_arch_create(%struct.archive* %0, i8* %1, i32 %2) {
%4 = alloca %struct.entry*
%5 = alloca %struct.archive*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca %struct.archnode*
%9 = alloca %struct.entry*
store %struct.archive* %0, %struct.archive** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%10 = load %struct.archive*, %struct.archive** %5
%11 = load i8*, i8** %6
%12 = load i32, i32* %7
%13 = call i8* @av_arch_resolve(%struct.archive* %10, i8* %11, i32 1, i32 %12)
%14 = bitcast i8* %13 to %struct.entry*
store %struct.entry* %14, %struct.entry** %9
%15 = load %struct.entry*, %struct.entry** %9
%16 = icmp eq %struct.entry* %15, null
br i1 %16, label %17, label %18
17: ; preds = %3
store %struct.entry* null, %struct.entry** %4
br label %48
18: ; preds = %3
%19 = load %struct.archive*, %struct.archive** %5
%20 = load %struct.entry*, %struct.entry** %9
%21 = bitcast %struct.entry* %20 to i8*
%22 = call i64 @av_arch_isroot(%struct.archive* %19, i8* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %18
%25 = call i32 (i32, i8*, ...) @av_log(i32 2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%26 = load %struct.entry*, %struct.entry** %9
%27 = bitcast %struct.entry* %26 to i8*
%28 = call i32 @av_unref_obj(i8* %27)
store %struct.entry* null, %struct.entry** %4
br label %48
29: ; preds = %18
%30 = load %struct.entry*, %struct.entry** %9
%31 = bitcast %struct.entry* %30 to i8*
%32 = call i64 @av_namespace_get(i8* %31)
%33 = inttoptr i64 %32 to %struct.archnode*
store %struct.archnode* %33, %struct.archnode** %8
%34 = load %struct.archnode*, %struct.archnode** %8
%35 = icmp ne %struct.archnode* %34, null
br i1 %35, label %36, label %42
36: ; preds = %29
%37 = load i8*, i8** %6
%38 = call i32 (i32, i8*, ...) @av_log(i32 2, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %37)
%39 = load %struct.entry*, %struct.entry** %9
%40 = bitcast %struct.entry* %39 to i8*
%41 = call i32 @av_unref_obj(i8* %40)
store %struct.entry* null, %struct.entry** %4
br label %48
42: ; preds = %29
%43 = load %struct.entry*, %struct.entry** %9
%44 = bitcast %struct.entry* %43 to i8*
%45 = load i32, i32* %7
%46 = call i32 @av_namespace_setflags(i8* %44, i32 %45, i32 0)
%47 = load %struct.entry*, %struct.entry** %9
store %struct.entry* %47, %struct.entry** %4
br label %48
48: ; preds = %42, %36, %24, %17
%49 = load %struct.entry*, %struct.entry** %4
ret %struct.entry* %49
}

LLVM IR (-O2):
%struct.entry = type opaque
%struct.archive = type { i32 }
@.str = [15 x i8] c"Empty filename\00"
@.str.1 = [28 x i8] c"Entry for %s already exists\00"
define %struct.entry* @av_arch_create(%struct.archive* %0, i8* %1, i32 %2) {
%4 = tail call i8* @av_arch_resolve(%struct.archive* %0, i8* %1, i32 1, i32 %2)
%5 = bitcast i8* %4 to %struct.entry*
%6 = icmp eq i8* %4, null
br i1 %6, label %21, label %7
7: ; preds = %3
%8 = tail call i64 @av_arch_isroot(%struct.archive* %0, i8* %4)
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = tail call i32 (i32, i8*, ...) @av_log(i32 2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @av_unref_obj(i8* %4)
br label %21
13: ; preds = %7
%14 = tail call i64 @av_namespace_get(i8* %4)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = tail call i32 (i32, i8*, ...) @av_log(i32 2, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%18 = tail call i32 @av_unref_obj(i8* %4)
br label %21
19: ; preds = %13
%20 = tail call i32 @av_namespace_setflags(i8* %4, i32 %2, i32 0)
br label %21
21: ; preds = %3, %19, %16, %10
%22 = phi %struct.entry* [ null, %10 ], [ null, %16 ], [ %5, %19 ], [ null, %3 ]
ret %struct.entry* %22
}