#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 uint64_t;

/* Variables and functions */
void create_key(char *keypart, uint64_t m_key) {
  for (int i = 0; i < 8; i++) {
    uint64_t part = m_key;
    for (int j = i; j > 0; j--)
      part = part >> 8;
    part = part & 0xff;
    keypart[i] = (char)(part);
  }
}


x86 assembly (clang, -O0):
<create_key>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x8,-0x10(%rbp)
jge    1172 <create_key+0x72>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    1149 <create_key+0x49>
mov    -0x14(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1128 <create_key+0x28>
mov    -0x14(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1112 <create_key+0x12>
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_key>:
mov    %esi,%eax
mov    %al,(%rdi)
mov    %ah,0x1(%rdi)
mov    %esi,%ecx
shr    $0x10,%ecx
mov    %cl,0x2(%rdi)
movd   %esi,%xmm0
shr    $0x18,%eax
mov    %al,0x3(%rdi)
psrad  $0x1f,%xmm0
punpcklbw %xmm0,%xmm0
pshuflw $0x0,%xmm0,%xmm0
movd   %xmm0,0x4(%rdi)
ret

LLVM IR (-O0):
define void @create_key(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %8
8: ; preds = %32, %2
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 8
br i1 %10, label %11, label %35
11: ; preds = %8
%12 = load i32, i32* %4
store i32 %12, i32* %6
%13 = load i32, i32* %5
store i32 %13, i32* %7
br label %14
14: ; preds = %20, %11
%15 = load i32, i32* %7
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %14
%18 = load i32, i32* %6
%19 = ashr i32 %18, 8
store i32 %19, i32* %6
br label %20
20: ; preds = %17
%21 = load i32, i32* %7
%22 = add nsw i32 %21, -1
store i32 %22, i32* %7
br label %14
23: ; preds = %14
%24 = load i32, i32* %6
%25 = and i32 %24, 255
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = trunc i32 %26 to i8
%28 = load i8*, i8** %3
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
store i8 %27, i8* %31
br label %32
32: ; preds = %23
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %8
35: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @create_key(i8* nocapture writeonly %0, i32 %1) {
%3 = trunc i32 %1 to i8
store i8 %3, i8* %0
%4 = lshr i32 %1, 8
%5 = trunc i32 %4 to i8
%6 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %5, i8* %6
%7 = lshr i32 %1, 16
%8 = trunc i32 %7 to i8
%9 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %8, i8* %9
%10 = lshr i32 %1, 24
%11 = trunc i32 %10 to i8
%12 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %11, i8* %12
%13 = getelementptr inbounds i8, i8* %0, i64 4
%14 = insertelement <4 x i32> poison, i32 %1, i64 0
%15 = ashr <4 x i32> %14, <i32 31, i32 0, i32 0, i32 0>
%16 = trunc <4 x i32> %15 to <4 x i8>
%17 = shufflevector <4 x i8> %16, <4 x i8> poison, <4 x i32> zeroinitializer
%18 = bitcast i8* %13 to <4 x i8>*
store <4 x i8> %17, <4 x i8>* %18
ret void
}