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

/* Variables and functions */
void be32enc(void *buf, uint32_t u) {
  uint8_t *p = buf;
  p[0] = ((uint8_t)((u >> 24) & 0xff));
  p[1] = ((uint8_t)((u >> 16) & 0xff));
  p[2] = ((uint8_t)((u >> 8) & 0xff));
  p[3] = ((uint8_t)(u & 0xff));
}


x86 assembly (clang, -O0):
<be32enc>:
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
sar    $0x18,%eax
and    $0xff,%eax
movslq %eax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0xc(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
movslq %eax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
movslq %eax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0xc(%rbp),%eax
and    $0xff,%eax
movslq %eax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x18(%rax)
pop    %rbp
ret

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

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

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