#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 void *uint8_t;
typedef int uint32_t;

/* Variables and functions */
void co_write32p(void const *ptr32, uint32_t value) {
  uint8_t *ptr = (uint8_t *)ptr32;
  *ptr++ = (uint8_t)(value & 0xff);
  *ptr++ = (uint8_t)((value & 0xff00) >> 8);
  *ptr++ = (uint8_t)((value & 0xff0000) >> 16);
  *ptr = (uint8_t)((value & 0xff000000) >> 24);
}


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

x86 assembly (clang, -O2):
<co_write32p>:
mov    %esi,%eax
movzbl %al,%ecx
mov    %rcx,(%rdi)
movzbl %ah,%ecx
mov    %rcx,0x8(%rdi)
mov    %esi,%ecx
shr    $0x10,%ecx
movzbl %cl,%ecx
mov    %rcx,0x10(%rdi)
shr    $0x18,%eax
mov    %rax,0x18(%rdi)
ret

LLVM IR (-O0):
define void @co_write32p(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8**
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = bitcast i8* %6 to i8**
store i8** %7, i8*** %5
%8 = load i32, i32* %4
%9 = and i32 %8, 255
%10 = sext i32 %9 to i64
%11 = inttoptr i64 %10 to i8*
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i32 1
store i8** %13, i8*** %5
store i8* %11, i8** %12
%14 = load i32, i32* %4
%15 = and i32 %14, 65280
%16 = ashr i32 %15, 8
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i8*
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i32 1
store i8** %20, i8*** %5
store i8* %18, i8** %19
%21 = load i32, i32* %4
%22 = and i32 %21, 16711680
%23 = ashr i32 %22, 16
%24 = sext i32 %23 to i64
%25 = inttoptr i64 %24 to i8*
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i32 1
store i8** %27, i8*** %5
store i8* %25, i8** %26
%28 = load i32, i32* %4
%29 = and i32 %28, -16777216
%30 = lshr i32 %29, 24
%31 = zext i32 %30 to i64
%32 = inttoptr i64 %31 to i8*
%33 = load i8**, i8*** %5
store i8* %32, i8** %33
ret void
}

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