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

/* Variables and functions */
void sg_put_unaligned_le48(uint64_t val, void *p) {
  ((uint8_t *)p)[5] = (val >> 40) & 0xff;
  ((uint8_t *)p)[4] = (val >> 32) & 0xff;
  ((uint8_t *)p)[3] = (val >> 24) & 0xff;
  ((uint8_t *)p)[2] = (val >> 16) & 0xff;
  ((uint8_t *)p)[1] = (val >> 8) & 0xff;
  ((uint8_t *)p)[0] = val & 0xff;
}


x86 assembly (clang, -O0):
<sg_put_unaligned_le48>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x28,%ecx
sar    %cl,%eax
mov    %eax,%ecx
and    $0xff,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x4(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    %eax,%ecx
and    $0xff,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x4(%rbp),%ecx
sar    $0x18,%ecx
and    $0xff,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x4(%rbp),%ecx
sar    $0x10,%ecx
and    $0xff,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x4(%rbp),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x4(%rbp),%ecx
and    $0xff,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<sg_put_unaligned_le48>:
mov    %edi,%eax
mov    %edi,%ecx
movzbl %ah,%edx
movzbl %al,%edi
shr    $0x18,%eax
mov    %eax,0xc(%rsi)
shr    $0x10,%ecx
movzbl %cl,%eax
mov    %eax,0x8(%rsi)
mov    %edx,0x4(%rsi)
mov    %edi,(%rsi)
ret

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

LLVM IR (-O2):
define void @sg_put_unaligned_le48(i32 %0, i8* nocapture writeonly %1) {
%3 = bitcast i8* %1 to i32*
%4 = lshr i32 %0, 24
%5 = getelementptr inbounds i8, i8* %1, i64 12
%6 = bitcast i8* %5 to i32*
store i32 %4, i32* %6
%7 = lshr i32 %0, 16
%8 = and i32 %7, 255
%9 = getelementptr inbounds i8, i8* %1, i64 8
%10 = bitcast i8* %9 to i32*
store i32 %8, i32* %10
%11 = lshr i32 %0, 8
%12 = and i32 %11, 255
%13 = getelementptr inbounds i8, i8* %1, i64 4
%14 = bitcast i8* %13 to i32*
store i32 %12, i32* %14
%15 = and i32 %0, 255
store i32 %15, i32* %3
ret void
}