int cpy_univ(unsigned long value, void *arg) {
  unsigned char **p, *q;
  p = arg;
  q = *p;
  *q++ = (unsigned char)((value >> 24) & 0xff);
  *q++ = (unsigned char)((value >> 16) & 0xff);
  *q++ = (unsigned char)((value >> 8) & 0xff);
  *q = (unsigned char)(value & 0xff);
  *p += 4;
  return 1;
}


x86 assembly (clang, -O0):
<cpy_univ>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
add    $0x4,%rcx
mov    %rcx,(%rax)
mov    $0x1,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpy_univ>:
mov    (%rsi),%rax
bswap  %edi
mov    %edi,(%rax)
addq   $0x4,(%rsi)
mov    $0x1,%eax
ret

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

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