#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 */
struct hash_table {
  int dummy;
};
typedef int e;

/* Variables and functions */
char *alloca(int);
int /*<<< orphan*/ *hash_table_get(struct hash_table const *, char *);
int /*<<< orphan*/ memcpy(char *, char const *, int);
int name_allowed(const struct hash_table *ht, const char *b, const char *e) {
  char *copy;
  if (!ht)
    return 1;
  do {
    const char *BTA_beg = (b);
    int BTA_len = (e)-BTA_beg;
    char **BTA_dest = &(copy);
    *BTA_dest = alloca(BTA_len + 1);
    memcpy(*BTA_dest, BTA_beg, BTA_len);
    (*BTA_dest)[BTA_len] = '\0';
  } while (0);
  return hash_table_get(ht, copy) != NULL;
}


x86 assembly (clang, -O0):
<name_allowed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115b <name_allowed+0x2b>
movl   $0x1,-0x4(%rbp)
jmp    11d1 <name_allowed+0xa1>
jmp    1160 <name_allowed+0x30>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x34(%rbp)
lea    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x34(%rbp),%edi
add    $0x1,%edi
call   1030 <alloca@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x40(%rbp),%rax
mov    (%rax),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x34(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x40(%rbp),%rax
mov    (%rax),%rax
movslq -0x34(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <hash_table_get@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<name_allowed>:
test   %rdi,%rdi
je     118b <name_allowed+0x5b>
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r14
sub    %rsi,%rbx
lea    0x1(%rbx),%edi
call   1030 <alloca@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1040 <memcpy@plt>
movslq %ebx,%rax
movb   $0x0,(%r12,%rax,1)
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <hash_table_get@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    $0x1,%eax
ret

LLVM IR (-O0):
%struct.hash_table = type { i32 }
define i32 @name_allowed(%struct.hash_table* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.hash_table*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8**
store %struct.hash_table* %0, %struct.hash_table** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%12 = load %struct.hash_table*, %struct.hash_table** %5
%13 = icmp ne %struct.hash_table* %12, null
br i1 %13, label %15, label %14
14: ; preds = %3
store i32 1, i32* %4
br label %44
15: ; preds = %3
br label %16
16: ; preds = %15
%17 = load i8*, i8** %6
store i8* %17, i8** %9
%18 = load i8*, i8** %7
%19 = load i8*, i8** %9
%20 = ptrtoint i8* %18 to i64
%21 = ptrtoint i8* %19 to i64
%22 = sub i64 %20, %21
%23 = trunc i64 %22 to i32
store i32 %23, i32* %10
store i8** %8, i8*** %11
%24 = load i32, i32* %10
%25 = add nsw i32 %24, 1
%26 = call i8* @alloca(i32 %25)
%27 = load i8**, i8*** %11
store i8* %26, i8** %27
%28 = load i8**, i8*** %11
%29 = load i8*, i8** %28
%30 = load i8*, i8** %9
%31 = load i32, i32* %10
%32 = call i32 @memcpy(i8* %29, i8* %30, i32 %31)
%33 = load i8**, i8*** %11
%34 = load i8*, i8** %33
%35 = load i32, i32* %10
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
store i8 0, i8* %37
br label %38
38: ; preds = %16
%39 = load %struct.hash_table*, %struct.hash_table** %5
%40 = load i8*, i8** %8
%41 = call i32* @hash_table_get(%struct.hash_table* %39, i8* %40)
%42 = icmp ne i32* %41, null
%43 = zext i1 %42 to i32
store i32 %43, i32* %4
br label %44
44: ; preds = %38, %14
%45 = load i32, i32* %4
ret i32 %45
}

LLVM IR (-O2):
%struct.hash_table = type { i32 }
define i32 @name_allowed(%struct.hash_table* %0, i8* %1, i8* %2) {
%4 = icmp eq %struct.hash_table* %0, null
br i1 %4, label %19, label %5
5: ; preds = %3
%6 = ptrtoint i8* %2 to i64
%7 = ptrtoint i8* %1 to i64
%8 = sub i64 %6, %7
%9 = trunc i64 %8 to i32
%10 = add nsw i32 %9, 1
%11 = tail call i8* @alloca(i32 %10)
%12 = tail call i32 @memcpy(i8* %11, i8* %1, i32 %9)
%13 = shl i64 %8, 32
%14 = ashr exact i64 %13, 32
%15 = getelementptr inbounds i8, i8* %11, i64 %14
store i8 0, i8* %15
%16 = tail call i32* @hash_table_get(%struct.hash_table* %0, i8* %11)
%17 = icmp ne i32* %16, null
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %3, %5
%20 = phi i32 [ %18, %5 ], [ 1, %3 ]
ret i32 %20
}