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

/* Variables and functions */
void store_dword(uint8_t *loc, uint32_t index, uint32_t block) {
  *(loc + index + 0) = (block & 0xFF000000) >> 24;
  *(loc + index + 1) = (block & 0x00FF0000) >> 16;
  *(loc + index + 2) = (block & 0x0000FF00) >> 8;
  *(loc + index + 3) = (block & 0x000000FF);
}


x86 assembly (clang, -O0):
<store_dword>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%edx
and    $0xff000000,%edx
shr    $0x18,%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%edx
and    $0xff0000,%edx
sar    $0x10,%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,0x4(%rax,%rcx,4)
mov    -0x10(%rbp),%edx
and    $0xff00,%edx
sar    $0x8,%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,0x8(%rax,%rcx,4)
mov    -0x10(%rbp),%edx
and    $0xff,%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,0xc(%rax,%rcx,4)
pop    %rbp
ret

x86 assembly (clang, -O2):
<store_dword>:
push   %rbx
mov    %edx,%eax
movzbl %dh,%ebx
movzbl %dl,%ecx
shr    $0x18,%edx
movslq %esi,%rsi
mov    %edx,(%rdi,%rsi,4)
shr    $0x10,%eax
movzbl %al,%eax
mov    %eax,0x4(%rdi,%rsi,4)
mov    %ebx,0x8(%rdi,%rsi,4)
mov    %ecx,0xc(%rdi,%rsi,4)
pop    %rbx
ret

LLVM IR (-O0):
define void @store_dword(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* %6
%8 = and i32 %7, -16777216
%9 = lshr i32 %8, 24
%10 = load i32*, i32** %4
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i32, i32* %10, i64 %12
%14 = getelementptr inbounds i32, i32* %13, i64 0
store i32 %9, i32* %14
%15 = load i32, i32* %6
%16 = and i32 %15, 16711680
%17 = ashr i32 %16, 16
%18 = load i32*, i32** %4
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
%22 = getelementptr inbounds i32, i32* %21, i64 1
store i32 %17, i32* %22
%23 = load i32, i32* %6
%24 = and i32 %23, 65280
%25 = ashr i32 %24, 8
%26 = load i32*, i32** %4
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
%30 = getelementptr inbounds i32, i32* %29, i64 2
store i32 %25, i32* %30
%31 = load i32, i32* %6
%32 = and i32 %31, 255
%33 = load i32*, i32** %4
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %33, i64 %35
%37 = getelementptr inbounds i32, i32* %36, i64 3
store i32 %32, i32* %37
ret void
}

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