#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 capimsg_setu32(void *m, int off, __u32 val) {
  ((__u8 *)m)[off] = val & 0xff;
  ((__u8 *)m)[off + 1] = (val >> 8) & 0xff;
  ((__u8 *)m)[off + 2] = (val >> 16) & 0xff;
  ((__u8 *)m)[off + 3] = (val >> 24) & 0xff;
}


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

x86 assembly (clang, -O2):
<capimsg_setu32>:
movzbl %dl,%eax
movslq %esi,%rcx
mov    %eax,(%rdi,%rcx,4)
movzbl %dh,%eax
mov    %eax,0x4(%rdi,%rcx,4)
mov    %edx,%eax
shr    $0x10,%eax
movzbl %al,%eax
mov    %eax,0x8(%rdi,%rcx,4)
shr    $0x18,%edx
mov    %edx,0xc(%rdi,%rcx,4)
ret

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

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