#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*/ str_to_key(unsigned char *, unsigned char *);
void sid_to_key2(unsigned long sid, unsigned char deskey[8]) {
  unsigned char s[7];
  s[0] = (unsigned char)((sid >> 24) & 0xFF);
  s[1] = (unsigned char)(sid & 0xFF);
  s[2] = (unsigned char)((sid >> 8) & 0xFF);
  s[3] = (unsigned char)((sid >> 16) & 0xFF);
  s[4] = s[0];
  s[5] = s[1];
  s[6] = s[2];
  str_to_key(s, deskey);
}


x86 assembly (clang, -O0):
<sid_to_key2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    %al,-0x17(%rbp)
mov    -0x8(%rbp),%rax
and    $0xff,%rax
mov    %al,-0x16(%rbp)
mov    -0x8(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %al,-0x15(%rbp)
mov    -0x8(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %al,-0x14(%rbp)
mov    -0x17(%rbp),%al
mov    %al,-0x13(%rbp)
mov    -0x16(%rbp),%al
mov    %al,-0x12(%rbp)
mov    -0x15(%rbp),%al
mov    %al,-0x11(%rbp)
lea    -0x17(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <str_to_key@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sid_to_key2>:
push   %rax
mov    %rdi,%rax
shr    $0x18,%rax
mov    %al,0x1(%rsp)
mov    %dil,0x2(%rsp)
mov    %rdi,%rcx
shr    $0x8,%rcx
mov    %cl,0x3(%rsp)
mov    %rdi,%rdx
shr    $0x10,%rdx
mov    %dl,0x4(%rsp)
mov    %al,0x5(%rsp)
mov    %dil,0x6(%rsp)
mov    %cl,0x7(%rsp)
lea    0x1(%rsp),%rdi
call   1030 <str_to_key@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @sid_to_key2(i64 %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca [7 x i8]
store i64 %0, i64* %3
store i8* %1, i8** %4
%6 = load i64, i64* %3
%7 = lshr i64 %6, 24
%8 = and i64 %7, 255
%9 = trunc i64 %8 to i8
%10 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
store i8 %9, i8* %10
%11 = load i64, i64* %3
%12 = and i64 %11, 255
%13 = trunc i64 %12 to i8
%14 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 1
store i8 %13, i8* %14
%15 = load i64, i64* %3
%16 = lshr i64 %15, 8
%17 = and i64 %16, 255
%18 = trunc i64 %17 to i8
%19 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 2
store i8 %18, i8* %19
%20 = load i64, i64* %3
%21 = lshr i64 %20, 16
%22 = and i64 %21, 255
%23 = trunc i64 %22 to i8
%24 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 3
store i8 %23, i8* %24
%25 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%26 = load i8, i8* %25
%27 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 4
store i8 %26, i8* %27
%28 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 1
%29 = load i8, i8* %28
%30 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 5
store i8 %29, i8* %30
%31 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 2
%32 = load i8, i8* %31
%33 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 6
store i8 %32, i8* %33
%34 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%35 = load i8*, i8** %4
%36 = call i32 @str_to_key(i8* %34, i8* %35)
ret void
}

LLVM IR (-O2):
define void @sid_to_key2(i64 %0, i8* %1) {
%3 = alloca [7 x i8]
%4 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%5 = lshr i64 %0, 24
%6 = trunc i64 %5 to i8
store i8 %6, i8* %4
%7 = trunc i64 %0 to i8
%8 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 1
store i8 %7, i8* %8
%9 = lshr i64 %0, 8
%10 = trunc i64 %9 to i8
%11 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 2
store i8 %10, i8* %11
%12 = lshr i64 %0, 16
%13 = trunc i64 %12 to i8
%14 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 3
store i8 %13, i8* %14
%15 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 4
store i8 %6, i8* %15
%16 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 5
store i8 %7, i8* %16
%17 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 6
store i8 %10, i8* %17
%18 = call i32 @str_to_key(i8* %4, i8* %1)
ret void
}