#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 */
scalar_t__ lmc_is_filename(char const *);
char *lmc_namespace_root_path();
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, ...);
void lmc_file_path_for_namespace(char *result, const char *ns) {
  if (lmc_is_filename(ns)) {
    snprintf(result, 1023, "%s", ns);
  } else {
    snprintf(result, 1023, "%s/%s.lmc", lmc_namespace_root_path(), ns);
  }
}


x86 assembly (clang, -O0):
<lmc_file_path_for_namespace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <lmc_is_filename@plt>
cmp    $0x0,%rax
je     1173 <lmc_file_path_for_namespace+0x43>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x3ff,%esi
lea    0xe99(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    11a0 <lmc_file_path_for_namespace+0x70>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <lmc_namespace_root_path@plt>
mov    -0x18(%rbp),%rdi
mov    %rax,%rcx
mov    -0x10(%rbp),%r8
mov    $0x3ff,%esi
lea    0xe6a(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lmc_file_path_for_namespace>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <lmc_is_filename@plt>
test   %rax,%rax
je     1167 <lmc_file_path_for_namespace+0x37>
lea    0xeb2(%rip),%rdx
mov    %r14,%rdi
mov    $0x3ff,%esi
mov    %rbx,%rcx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <snprintf@plt>
xor    %eax,%eax
call   1040 <lmc_namespace_root_path@plt>
lea    0xe8e(%rip),%rdx
mov    %r14,%rdi
mov    $0x3ff,%esi
mov    %rax,%rcx
mov    %rbx,%r8
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <snprintf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [10 x i8] c"%s/%s.lmc\00"
define void @lmc_file_path_for_namespace(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = call i64 @lmc_is_filename(i8* %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i8*, i8** %3
%10 = load i8*, i8** %4
%11 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %9, i32 1023, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %17
12: ; preds = %2
%13 = load i8*, i8** %3
%14 = call i8* (...) @lmc_namespace_root_path()
%15 = load i8*, i8** %4
%16 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %13, i32 1023, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %14, i8* %15)
br label %17
17: ; preds = %12, %8
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [10 x i8] c"%s/%s.lmc\00"
define void @lmc_file_path_for_namespace(i8* %0, i8* %1) {
%3 = tail call i64 @lmc_is_filename(i8* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %0, i32 1023, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %10
7: ; preds = %2
%8 = tail call i8* (...) @lmc_namespace_root_path()
%9 = tail call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %0, i32 1023, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %8, i8* %1)
br label %10
10: ; preds = %7, %5
ret void
}