#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 int32_t;

/* Variables and functions */
void psf_put_be32(uint8_t *ptr, int offset, int32_t value) {
  ptr[offset] = value >> 24;
  ptr[offset + 1] = value >> 16;
  ptr[offset + 2] = value >> 8;
  ptr[offset + 3] = value;
}


x86 assembly (clang, -O0):
<psf_put_be32>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%edx
sar    $0x18,%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%edx
sar    $0x10,%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    $0x8,%edx
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%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):
<psf_put_be32>:
mov    %edx,%eax
sar    $0x18,%eax
movslq %esi,%rcx
mov    %eax,(%rdi,%rcx,4)
mov    %edx,%eax
sar    $0x10,%eax
mov    %eax,0x4(%rdi,%rcx,4)
mov    %edx,%eax
sar    $0x8,%eax
mov    %eax,0x8(%rdi,%rcx,4)
mov    %edx,0xc(%rdi,%rcx,4)
ret

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

LLVM IR (-O2):
define void @psf_put_be32(i32* nocapture writeonly %0, i32 %1, i32 %2) {
%4 = ashr i32 %2, 24
%5 = sext i32 %1 to i64
%6 = getelementptr inbounds i32, i32* %0, i64 %5
store i32 %4, i32* %6
%7 = ashr i32 %2, 16
%8 = add nsw i32 %1, 1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i32, i32* %0, i64 %9
store i32 %7, i32* %10
%11 = ashr i32 %2, 8
%12 = add nsw i32 %1, 2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %0, i64 %13
store i32 %11, i32* %14
%15 = add nsw i32 %1, 3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %0, i64 %16
store i32 %2, i32* %17
ret void
}