#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 */
typedef int uint8_t;
typedef int uint32_t;

/* Variables and functions */
void build_sym_key_cache(uint32_t *cache, int cache_len) {
  static const uint8_t key[] = {0x50, 0x6d, 0x50, 0x6d, 0x50, 0x6d, 0x50, 0x6d,
                                0x50, 0x6d, 0x50, 0x6d, 0x50, 0x6d, 0x50, 0x6d,
                                0xcb, 0x2b, 0x5a, 0x5a, 0xb4, 0x30, 0x7b, 0xae,
                                0xa3, 0x2d, 0xcb, 0x77, 0x0c, 0xf2, 0x30, 0x80,
                                0x3b, 0xb7, 0x42, 0x6a, 0xfa, 0x01, 0xac, 0xbe};
  uint32_t result = (((uint32_t)key[0]) << 24) | (((uint32_t)key[1]) << 16) |
                    (((uint32_t)key[2]) << 8) | ((uint32_t)key[3]);
  uint32_t idx = 32;
  int i;
  for (i = 0; i < cache_len; i++, idx++) {
    uint8_t shift = (idx % (sizeof(uint8_t) * 8));
    uint32_t bit;
    cache[i] = result;
    bit = ((key[idx / (sizeof(uint8_t) * 8)] << shift) & 0x80) ? 1 : 0;
    result = ((result << 1) | bit);
  }
}


x86 assembly (clang, -O0):
<build_sym_key_cache>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0xeef(%rip),%eax
shl    $0x18,%eax
mov    0xeea(%rip),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    0xee3(%rip),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
or     0xedc(%rip),%eax
mov    %eax,-0x10(%rbp)
movl   $0x20,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b6 <build_sym_key_cache+0xb6>
movslq -0x14(%rbp),%rax
and    $0x1f,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movslq -0x14(%rbp),%rcx
shr    $0x5,%rcx
lea    0xe8b(%rip),%rax
mov    (%rax,%rcx,4),%edx
mov    -0x1c(%rbp),%ecx
shl    %cl,%edx
and    $0x80,%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
or     -0x20(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1141 <build_sym_key_cache+0x41>
pop    %rbp
ret

x86 assembly (clang, -O2):
<build_sym_key_cache>:
test   %esi,%esi
jle    1144 <build_sym_key_cache+0x44>
mov    %esi,%r9d
mov    $0x506d506d,%edx
xor    %esi,%esi
lea    0xeeb(%rip),%r8
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x20(%rsi),%rcx
mov    %edx,(%rdi,%rsi,4)
mov    %ecx,%eax
shr    $0x5,%eax
mov    (%r8,%rax,4),%eax
shl    %cl,%eax
movzbl %al,%eax
shr    $0x7,%eax
lea    (%rax,%rdx,2),%edx
add    $0x1,%rsi
cmp    %rsi,%r9
jne    1120 <build_sym_key_cache+0x20>
ret

LLVM IR (-O0):
@build_sym_key_cache.key = internal constant [40 x i32] [i32 80, i32 109, i32 80, i32 109, i32 80, i32 109, i32 80, i32 109, i32 80, i32 109, i32 80, i32 109, i32 80, i32 109, i32 80, i32 109, i32 203, i32 43, i32 90, i32 90, i32 180, i32 48, i32 123, i32 174, i32 163, i32 45, i32 203, i32 119, i32 12, i32 242, i32 48, i32 128, i32 59, i32 183, i32 66, i32 106, i32 250, i32 1, i32 172, i32 190]
define void @build_sym_key_cache(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%10 = load i32, i32* getelementptr inbounds ([40 x i32], [40 x i32]* @build_sym_key_cache.key, i64 0, i64 0)
%11 = shl i32 %10, 24
%12 = load i32, i32* getelementptr inbounds ([40 x i32], [40 x i32]* @build_sym_key_cache.key, i64 0, i64 1)
%13 = shl i32 %12, 16
%14 = or i32 %11, %13
%15 = load i32, i32* getelementptr inbounds ([40 x i32], [40 x i32]* @build_sym_key_cache.key, i64 0, i64 2)
%16 = shl i32 %15, 8
%17 = or i32 %14, %16
%18 = load i32, i32* getelementptr inbounds ([40 x i32], [40 x i32]* @build_sym_key_cache.key, i64 0, i64 3)
%19 = or i32 %17, %18
store i32 %19, i32* %5
store i32 32, i32* %6
store i32 0, i32* %7
br label %20
20: ; preds = %49, %2
%21 = load i32, i32* %7
%22 = load i32, i32* %4
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %54
24: ; preds = %20
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = urem i64 %26, 32
%28 = trunc i64 %27 to i32
store i32 %28, i32* %8
%29 = load i32, i32* %5
%30 = load i32*, i32** %3
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
store i32 %29, i32* %33
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = udiv i64 %35, 32
%37 = getelementptr inbounds [40 x i32], [40 x i32]* @build_sym_key_cache.key, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = load i32, i32* %8
%40 = shl i32 %38, %39
%41 = and i32 %40, 128
%42 = icmp ne i32 %41, 0
%43 = zext i1 %42 to i64
%44 = select i1 %42, i32 1, i32 0
store i32 %44, i32* %9
%45 = load i32, i32* %5
%46 = shl i32 %45, 1
%47 = load i32, i32* %9
%48 = or i32 %46, %47
store i32 %48, i32* %5
br label %49
49: ; preds = %24
%50 = load i32, i32* %7
%51 = add nsw i32 %50, 1
store i32 %51, i32* %7
%52 = load i32, i32* %6
%53 = add nsw i32 %52, 1
store i32 %53, i32* %6
br label %20
54: ; preds = %20
ret void
}

LLVM IR (-O2):
@build_sym_key_cache.key = internal unnamed_addr constant [40 x i32] [i32 80, i32 109, i32 80, i32 109, i32 80, i32 109, i32 80, i32 109, i32 80, i32 109, i32 80, i32 109, i32 80, i32 109, i32 80, i32 109, i32 203, i32 43, i32 90, i32 90, i32 180, i32 48, i32 123, i32 174, i32 163, i32 45, i32 203, i32 119, i32 12, i32 242, i32 48, i32 128, i32 59, i32 183, i32 66, i32 106, i32 250, i32 1, i32 172, i32 190]
define void @build_sym_key_cache(i32* nocapture writeonly %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %25
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %22, %6 ]
%8 = phi i32 [ 1349341293, %4 ], [ %21, %6 ]
%9 = phi i32 [ 32, %4 ], [ %23, %6 ]
%10 = and i32 %9, 31
%11 = getelementptr inbounds i32, i32* %0, i64 %7
store i32 %8, i32* %11
%12 = lshr i32 %9, 5
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds [40 x i32], [40 x i32]* @build_sym_key_cache.key, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = lshr i32 128, %10
%17 = and i32 %15, %16
%18 = icmp ne i32 %17, 0
%19 = zext i1 %18 to i32
%20 = shl i32 %8, 1
%21 = or i32 %20, %19
%22 = add nuw nsw i64 %7, 1
%23 = add nuw nsw i32 %9, 1
%24 = icmp eq i64 %22, %5
br i1 %24, label %25, label %6
25: ; preds = %6, %2
ret void
}