#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 __u8;
typedef int __u32;

/* Variables and functions */
void fill_word(__u32 src, __u8 *dst, int offset) {
  dst[offset] = (src >> 24) & 0xff;
  dst[offset + 1] = (src >> 16) & 0xff;
  dst[offset + 2] = (src >> 8) & 0xff;
  dst[offset + 3] = src & 0xff;
}


x86 assembly (clang, -O0):
<fill_word>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%edx
sar    $0x18,%edx
and    $0xff,%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%edx
sar    $0x10,%edx
and    $0xff,%edx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%edx
sar    $0x8,%edx
and    $0xff,%edx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%edx
and    $0xff,%edx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_word>:
push   %rbx
mov    %edi,%eax
mov    %edi,%ecx
movzbl %ah,%ebx
movzbl %al,%edi
shr    $0x18,%eax
movslq %edx,%rdx
mov    %eax,(%rsi,%rdx,4)
shr    $0x10,%ecx
movzbl %cl,%eax
mov    %eax,0x4(%rsi,%rdx,4)
mov    %ebx,0x8(%rsi,%rdx,4)
mov    %edi,0xc(%rsi,%rdx,4)
pop    %rbx
ret

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

LLVM IR (-O2):
define void @fill_word(i32 %0, i32* nocapture writeonly %1, i32 %2) {
%4 = lshr i32 %0, 24
%5 = sext i32 %2 to i64
%6 = getelementptr inbounds i32, i32* %1, i64 %5
store i32 %4, i32* %6
%7 = lshr i32 %0, 16
%8 = and i32 %7, 255
%9 = add nsw i32 %2, 1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i32, i32* %1, i64 %10
store i32 %8, i32* %11
%12 = lshr i32 %0, 8
%13 = and i32 %12, 255
%14 = add nsw i32 %2, 2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %1, i64 %15
store i32 %13, i32* %16
%17 = and i32 %0, 255
%18 = add nsw i32 %2, 3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %1, i64 %19
store i32 %17, i32* %20
ret void
}