#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 uint32_to_bin(uint32_t v, void *d) {
  uint8_t *p = (uint8_t *)d + 3;
  *p-- = 0xff & v;
  v >>= 8;
  *p-- = 0xff & v;
  v >>= 8;
  *p-- = 0xff & v;
  v >>= 8;
  *p = 0xff & v;
}


x86 assembly (clang, -O0):
<uint32_to_bin>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0xfffffffffffffffc,%rdx
mov    %rdx,-0x18(%rbp)
mov    %ecx,(%rax)
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0xfffffffffffffffc,%rdx
mov    %rdx,-0x18(%rbp)
mov    %ecx,(%rax)
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0xfffffffffffffffc,%rdx
mov    %rdx,-0x18(%rbp)
mov    %ecx,(%rax)
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<uint32_to_bin>:
mov    %edi,%eax
movzbl %al,%ecx
mov    %ecx,0xc(%rsi)
movzbl %ah,%ecx
mov    %ecx,0x8(%rsi)
mov    %edi,%ecx
shr    $0x10,%ecx
movzbl %cl,%ecx
mov    %ecx,0x4(%rsi)
shr    $0x18,%eax
mov    %eax,(%rsi)
ret

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

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