#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*/ createHash(unsigned char *, unsigned int, unsigned char *);
int /*<<< orphan*/ sscanf(char const *, char *, int *);
int /*<<< orphan*/ strcpy(char *, char const *);
unsigned int strlen(char *);
int /*<<< orphan*/ sub_804D1A8(char *, int, unsigned char *);
int sub_804D415(const char *key, char *buffer, int size) {
  char dest[512];
  strcpy(dest, key);
  unsigned int lengthWithNull;
  unsigned int length;
  lengthWithNull = strlen(dest);
  length = lengthWithNull - 1;
  length = (signed int)length / 2;
  char s[] = "AAAA";
  int i;
  int temp1;
  unsigned char magic[256];
  for (i = 0; i <= (signed int)length; ++i) {
    s[2] = dest[2 * i];
    s[3] = dest[2 * i + 1];
    sscanf((const char *)&s, "%x", &temp1);
    magic[i] = temp1;
  }
  unsigned char hashTable[258];
  createHash(magic, length, hashTable);
  sub_804D1A8(buffer, size, hashTable);
  return 0;
}


x86 assembly (clang, -O0):
<sub_804D415>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    -0x220(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x220(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x224(%rbp)
mov    -0x224(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x228(%rbp)
mov    -0x228(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x228(%rbp)
mov    0xe4f(%rip),%eax
mov    %eax,-0x22d(%rbp)
mov    0xe47(%rip),%al
mov    %al,-0x229(%rbp)
movl   $0x0,-0x234(%rbp)
mov    -0x234(%rbp),%eax
cmp    -0x228(%rbp),%eax
jg     1256 <sub_804D415+0x106>
mov    -0x234(%rbp),%eax
shl    $0x1,%eax
cltq
mov    -0x220(%rbp,%rax,1),%al
mov    %al,-0x22b(%rbp)
mov    -0x234(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cltq
mov    -0x220(%rbp,%rax,1),%al
mov    %al,-0x22a(%rbp)
lea    -0x22d(%rbp),%rdi
lea    0xde5(%rip),%rsi
lea    -0x238(%rbp),%rdx
call   1070 <sscanf@plt>
mov    -0x238(%rbp),%eax
mov    %al,%cl
movslq -0x234(%rbp),%rax
mov    %cl,-0x340(%rbp,%rax,1)
mov    -0x234(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x234(%rbp)
jmp    11cd <sub_804D415+0x7d>
lea    -0x340(%rbp),%rdi
mov    -0x228(%rbp),%esi
lea    -0x450(%rbp),%rdx
call   1060 <createHash@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x450(%rbp),%rdx
call   1050 <sub_804D1A8@plt>
xor    %eax,%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sub_804D415>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    %edx,0x10(%rsp)
mov    %rsi,0x18(%rsp)
mov    %rdi,%rsi
lea    0x120(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    -0x1(%rax),%ecx
shr    $0x1f,%ecx
lea    (%rax,%rcx,1),%r12d
add    $0xffffffff,%r12d
sar    %r12d
movb   $0x0,0xc(%rsp)
movl   $0x41414141,0x8(%rsp)
41
cmp    $0x80000000,%eax
ja     11ff <sub_804D415+0xaf>
xor    %r14d,%r14d
test   %r12d,%r12d
mov    $0x0,%r15d
cmovg  %r12d,%r15d
add    $0x1,%r15d
lea    0xe40(%rip),%r13
lea    0x8(%rsp),%rbp
lea    0x14(%rsp),%rbx
nop
movzwl 0x120(%rsp,%r14,2),%eax
mov    %ax,0xa(%rsp)
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1070 <sscanf@plt>
movzbl 0x14(%rsp),%eax
mov    %al,0x20(%rsp,%r14,1)
add    $0x1,%r14
cmp    %r14,%r15
jne    11d0 <sub_804D415+0x80>
lea    0x20(%rsp),%rdi
lea    0x320(%rsp),%rbx
mov    %r12d,%esi
mov    %rbx,%rdx
call   1060 <createHash@plt>
mov    0x18(%rsp),%rdi
mov    0x10(%rsp),%esi
mov    %rbx,%rdx
call   1050 <sub_804D1A8@plt>
xor    %eax,%eax
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.sub_804D415.s = [5 x i8] c"AAAA\00"
@.str = [3 x i8] c"%x\00"
define i32 @sub_804D415(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [512 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca [5 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca [256 x i8]
%14 = alloca [258 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%15 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%16 = load i8*, i8** %4
%17 = call i32 @strcpy(i8* %15, i8* %16)
%18 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
store i32 %19, i32* %8
%20 = load i32, i32* %8
%21 = sub i32 %20, 1
store i32 %21, i32* %9
%22 = load i32, i32* %9
%23 = sdiv i32 %22, 2
store i32 %23, i32* %9
%24 = bitcast [5 x i8]* %10 to i8*
store i32 0, i32* %11
br label %25
25: ; preds = %50, %3
%26 = load i32, i32* %11
%27 = load i32, i32* %9
%28 = icmp sle i32 %26, %27
br i1 %28, label %29, label %53
29: ; preds = %25
%30 = load i32, i32* %11
%31 = mul nsw i32 2, %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = getelementptr inbounds [5 x i8], [5 x i8]* %10, i64 0, i64 2
store i8 %34, i8* %35
%36 = load i32, i32* %11
%37 = mul nsw i32 2, %36
%38 = add nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = getelementptr inbounds [5 x i8], [5 x i8]* %10, i64 0, i64 3
store i8 %41, i8* %42
%43 = bitcast [5 x i8]* %10 to i8*
%44 = call i32 @sscanf(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %12)
%45 = load i32, i32* %12
%46 = trunc i32 %45 to i8
%47 = load i32, i32* %11
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 %48
store i8 %46, i8* %49
br label %50
50: ; preds = %29
%51 = load i32, i32* %11
%52 = add nsw i32 %51, 1
store i32 %52, i32* %11
br label %25
53: ; preds = %25
%54 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%55 = load i32, i32* %9
%56 = getelementptr inbounds [258 x i8], [258 x i8]* %14, i64 0, i64 0
%57 = call i32 @createHash(i8* %54, i32 %55, i8* %56)
%58 = load i8*, i8** %5
%59 = load i32, i32* %6
%60 = getelementptr inbounds [258 x i8], [258 x i8]* %14, i64 0, i64 0
%61 = call i32 @sub_804D1A8(i8* %58, i32 %59, i8* %60)
ret i32 0
}

LLVM IR (-O2):
@__const.sub_804D415.s = [5 x i8] c"AAAA\00"
@.str = [3 x i8] c"%x\00"
define i32 @sub_804D415(i8* %0, i8* %1, i32 %2) {
%4 = alloca [512 x i8]
%5 = alloca [5 x i8]
%6 = alloca i32
%7 = alloca [256 x i8]
%8 = alloca [258 x i8]
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%10 = call i32 @strcpy(i8* %9, i8* %0)
%11 = call i32 @strlen(i8* %9)
%12 = add i32 %11, -1
%13 = sdiv i32 %12, 2
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%15 = bitcast i32* %6 to i8*
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%17 = icmp ugt i32 %11, -2147483648
br i1 %17, label %38, label %18
18: ; preds = %3
%19 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 2
%20 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 3
%21 = call i32 @llvm.smax.i32(i32 %13, i32 0)
%22 = add nuw nsw i32 %21, 1
%23 = zext i32 %22 to i64
br label %24
24: ; preds = %18, %24
%25 = phi i64 [ 0, %18 ], [ %36, %24 ]
%26 = shl nuw nsw i64 %25, 1
%27 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 %26
%28 = load i8, i8* %27
store i8 %28, i8* %19
%29 = or i64 %26, 1
%30 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 %29
%31 = load i8, i8* %30
store i8 %31, i8* %20
%32 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%33 = load i32, i32* %6
%34 = trunc i32 %33 to i8
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %25
store i8 %34, i8* %35
%36 = add nuw nsw i64 %25, 1
%37 = icmp eq i64 %36, %23
br i1 %37, label %38, label %24
38: ; preds = %24, %3
%39 = getelementptr inbounds [258 x i8], [258 x i8]* %8, i64 0, i64 0
%40 = call i32 @createHash(i8* %16, i32 %13, i8* %39)
%41 = call i32 @sub_804D1A8(i8* %1, i32 %2, i8* %39)
ret i32 0
}