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

/* Variables and functions */
int /*<<< orphan*/ str_to_key(unsigned char *, unsigned char *);
void sid_to_key2(uint32_t 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    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x18,%eax
and    $0xff,%eax
mov    %al,-0x17(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x16(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %al,-0x15(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
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    %edi,%eax
shr    $0x18,%eax
mov    %al,0x1(%rsp)
mov    %dil,0x2(%rsp)
mov    %edi,%ecx
shr    $0x8,%ecx
mov    %cl,0x3(%rsp)
mov    %edi,%edx
shr    $0x10,%edx
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(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [7 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = load i32, i32* %3
%7 = ashr i32 %6, 24
%8 = and i32 %7, 255
%9 = trunc i32 %8 to i8
%10 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
store i8 %9, i8* %10
%11 = load i32, i32* %3
%12 = and i32 %11, 255
%13 = trunc i32 %12 to i8
%14 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 1
store i8 %13, i8* %14
%15 = load i32, i32* %3
%16 = ashr i32 %15, 8
%17 = and i32 %16, 255
%18 = trunc i32 %17 to i8
%19 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 2
store i8 %18, i8* %19
%20 = load i32, i32* %3
%21 = ashr i32 %20, 16
%22 = and i32 %21, 255
%23 = trunc i32 %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(i32 %0, i8* %1) {
%3 = alloca [7 x i8]
%4 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%5 = lshr i32 %0, 24
%6 = trunc i32 %5 to i8
store i8 %6, i8* %4
%7 = trunc i32 %0 to i8
%8 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 1
store i8 %7, i8* %8
%9 = lshr i32 %0, 8
%10 = trunc i32 %9 to i8
%11 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 2
store i8 %10, i8* %11
%12 = lshr i32 %0, 16
%13 = trunc i32 %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
}