#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*/ lmc_clean_string(char *, char const *);
int /*<<< orphan*/ lmc_hash(char *, int /*<<< orphan*/);
scalar_t__ lmc_is_filename(char const *);
int /*<<< orphan*/ snprintf(char *, int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, char const *);
int /*<<< orphan*/ strlen(char *);
void lmc_namespacify(char *result, const char *s) {
  char cs[1024];
  if (lmc_is_filename(s)) {
    lmc_clean_string(cs, s);
  } else {
    strcpy(cs, s);
  }
  snprintf(result, 15, "/lmc-%zX", lmc_hash(cs, strlen(cs)));
}


x86 assembly (clang, -O0):
<lmc_namespacify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <lmc_is_filename@plt>
cmp    $0x0,%rax
je     119b <lmc_namespacify+0x3b>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <lmc_clean_string@plt>
jmp    11ab <lmc_namespacify+0x4b>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x418(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x420(%rbp)
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x420(%rbp),%rdi
mov    %eax,%esi
call   1070 <lmc_hash@plt>
mov    -0x418(%rbp),%rdi
mov    %eax,%ecx
mov    $0xf,%esi
lea    0xe0d(%rip),%rdx
call   1050 <snprintf@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lmc_namespacify>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1060 <lmc_is_filename@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
test   %rax,%rax
je     118a <lmc_namespacify+0x2a>
call   1080 <lmc_clean_string@plt>
jmp    118f <lmc_namespacify+0x2f>
call   1030 <strcpy@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1070 <lmc_hash@plt>
lea    0xe55(%rip),%rdx
mov    %r14,%rdi
mov    $0xf,%esi
mov    %eax,%ecx
call   1050 <snprintf@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i8] c"/lmc-%zX\00"
define void @lmc_namespacify(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [1024 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = call i64 @lmc_is_filename(i8* %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%11 = load i8*, i8** %4
%12 = call i32 @lmc_clean_string(i8* %10, i8* %11)
br label %17
13: ; preds = %2
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%15 = load i8*, i8** %4
%16 = call i32 @strcpy(i8* %14, i8* %15)
br label %17
17: ; preds = %13, %9
%18 = load i8*, i8** %3
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
%22 = call i32 @lmc_hash(i8* %19, i32 %21)
%23 = call i32 @snprintf(i8* %18, i32 15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %22)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"/lmc-%zX\00"
define void @lmc_namespacify(i8* %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @lmc_is_filename(i8* %1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = call i32 @lmc_clean_string(i8* %4, i8* %1)
br label %11
9: ; preds = %2
%10 = call i32 @strcpy(i8* %4, i8* %1)
br label %11
11: ; preds = %9, %7
%12 = call i32 @strlen(i8* %4)
%13 = call i32 @lmc_hash(i8* %4, i32 %12)
%14 = call i32 @snprintf(i8* %0, i32 15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %13)
ret void
}