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

/* Variables and functions */
void put32bit(uint8_t **ptr, uint32_t val) {
  (*ptr)[0] = ((val) >> 24) & 0xFF;
  (*ptr)[1] = ((val) >> 16) & 0xFF;
  (*ptr)[2] = ((val) >> 8) & 0xFF;
  (*ptr)[3] = (val)&0xFF;
  (*ptr) += 4;
}


x86 assembly (clang, -O0):
<put32bit>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
sar    $0x18,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %ecx,(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x10,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %ecx,0x4(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %ecx,0x8(%rax)
mov    -0xc(%rbp),%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %ecx,0xc(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x10,%rcx
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<put32bit>:
push   %rbx
mov    %esi,%eax
mov    %esi,%ecx
movzbl %ah,%ebx
movzbl %al,%esi
shr    $0x18,%eax
mov    (%rdi),%rdx
mov    %eax,(%rdx)
shr    $0x10,%ecx
movzbl %cl,%eax
mov    %eax,0x4(%rdx)
mov    %ebx,0x8(%rdx)
mov    %esi,0xc(%rdx)
add    $0x10,%rdx
mov    %rdx,(%rdi)
pop    %rbx
ret

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

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