#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 /*<<< orphan*/ O_CREAT;
int /*<<< orphan*/ close(int /*<<< orphan*/);
int /*<<< orphan*/ lmc_does_namespace_exist(char const *);
int /*<<< orphan*/ lmc_file_path_for_namespace(char *, char const *);
int /*<<< orphan*/ lmc_shm_ensure_root_path();
int /*<<< orphan*/ open(char *, int /*<<< orphan*/, int);
void lmc_shm_ensure_namespace_file(const char *ns) {
  lmc_shm_ensure_root_path();
  char fn[1024];
  lmc_file_path_for_namespace((char *)&fn, ns);
  if (!lmc_does_namespace_exist(ns)) {
    close(open(fn, O_CREAT, 0777));
  }
}


x86 assembly (clang, -O0):
<lmc_shm_ensure_namespace_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <lmc_shm_ensure_root_path@plt>
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <lmc_file_path_for_namespace@plt>
mov    -0x8(%rbp),%rdi
call   1040 <lmc_does_namespace_exist@plt>
cmp    $0x0,%eax
jne    11a9 <lmc_shm_ensure_namespace_file+0x59>
lea    -0x410(%rbp),%rdi
mov    0x2e62(%rip),%rax
mov    (%rax),%esi
mov    $0x1ff,%edx
call   1070 <open@plt>
mov    %eax,%edi
call   1060 <close@plt>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lmc_shm_ensure_namespace_file>:
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <lmc_shm_ensure_root_path@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1050 <lmc_file_path_for_namespace@plt>
mov    %rbx,%rdi
call   1040 <lmc_does_namespace_exist@plt>
test   %eax,%eax
jne    1196 <lmc_shm_ensure_namespace_file+0x46>
mov    0x2e78(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdi
mov    $0x1ff,%edx
call   1070 <open@plt>
mov    %eax,%edi
call   1060 <close@plt>
add    $0x400,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@O_CREAT = global i32 0
define void @lmc_shm_ensure_namespace_file(i8* %0) {
%2 = alloca i8*
%3 = alloca [1024 x i8]
store i8* %0, i8** %2
%4 = call i32 (...) @lmc_shm_ensure_root_path()
%5 = bitcast [1024 x i8]* %3 to i8*
%6 = load i8*, i8** %2
%7 = call i32 @lmc_file_path_for_namespace(i8* %5, i8* %6)
%8 = load i8*, i8** %2
%9 = call i32 @lmc_does_namespace_exist(i8* %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %1
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%13 = load i32, i32* @O_CREAT
%14 = call i32 @open(i8* %12, i32 %13, i32 511)
%15 = call i32 @close(i32 %14)
br label %16
16: ; preds = %11, %1
ret void
}

LLVM IR (-O2):
@O_CREAT = global i32 0
define void @lmc_shm_ensure_namespace_file(i8* %0) {
%2 = alloca [1024 x i8]
%3 = tail call i32 (...) @lmc_shm_ensure_root_path()
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = call i32 @lmc_file_path_for_namespace(i8* %4, i8* %0)
%6 = call i32 @lmc_does_namespace_exist(i8* %0)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i32, i32* @O_CREAT
%10 = call i32 @open(i8* %4, i32 %9, i32 511)
%11 = call i32 @close(i32 %10)
br label %12
12: ; preds = %8, %1
ret void
}