#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 */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, int, int, int, int);
void WriteUint32BE(uint32_t in, uint8_t *out) {
  assert(out != NULL);
  out[0] = in >> 24;
  out[1] = (in >> 16) & 0xff;
  out[2] = (in >> 8) & 0xff;
  out[3] = in & 0xFF;
  printf("W 32 BE: 0x%08x -> \"0x%02x%02x%02x%02x\"\n", in, out[0], out[1],
         out[2], out[3]);
}


x86 assembly (clang, -O0):
<WriteUint32BE>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x4(%rbp),%ecx
sar    $0x18,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x4(%rbp),%ecx
sar    $0x10,%ecx
and    $0xff,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x4(%rbp),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x4(%rbp),%ecx
and    $0xff,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r8d
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%r9d
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WriteUint32BE>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %edi,%edi
test   %rsi,%rsi
setne  %dil
call   1040 <assert@plt>
mov    %ebp,%ecx
mov    %ebp,%edx
sar    $0x18,%edx
mov    %edx,(%rbx)
mov    %ebp,%eax
shr    $0x10,%eax
movzbl %al,%ebp
mov    %ebp,0x4(%rbx)
movzbl %ch,%eax
mov    %eax,0x8(%rbx)
movzbl %cl,%r9d
mov    %r9d,0xc(%rbx)
lea    0xea1(%rip),%rdi
mov    %ecx,%esi
mov    %ebp,%ecx
mov    %eax,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [41 x i8] c"W 32 BE: 0x%08x -> \220x%02x%02x%02x%02x\22\0A\00"
define void @WriteUint32BE(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 = icmp ne i32* %5, null
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = load i32, i32* %3
%10 = ashr i32 %9, 24
%11 = load i32*, i32** %4
%12 = getelementptr inbounds i32, i32* %11, i64 0
store i32 %10, i32* %12
%13 = load i32, i32* %3
%14 = ashr i32 %13, 16
%15 = and i32 %14, 255
%16 = load i32*, i32** %4
%17 = getelementptr inbounds i32, i32* %16, i64 1
store i32 %15, i32* %17
%18 = load i32, i32* %3
%19 = ashr i32 %18, 8
%20 = and i32 %19, 255
%21 = load i32*, i32** %4
%22 = getelementptr inbounds i32, i32* %21, i64 2
store i32 %20, i32* %22
%23 = load i32, i32* %3
%24 = and i32 %23, 255
%25 = load i32*, i32** %4
%26 = getelementptr inbounds i32, i32* %25, i64 3
store i32 %24, i32* %26
%27 = load i32, i32* %3
%28 = load i32*, i32** %4
%29 = getelementptr inbounds i32, i32* %28, i64 0
%30 = load i32, i32* %29
%31 = load i32*, i32** %4
%32 = getelementptr inbounds i32, i32* %31, i64 1
%33 = load i32, i32* %32
%34 = load i32*, i32** %4
%35 = getelementptr inbounds i32, i32* %34, i64 2
%36 = load i32, i32* %35
%37 = load i32*, i32** %4
%38 = getelementptr inbounds i32, i32* %37, i64 3
%39 = load i32, i32* %38
%40 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %27, i32 %30, i32 %33, i32 %36, i32 %39)
ret void
}

LLVM IR (-O2):
@.str = [41 x i8] c"W 32 BE: 0x%08x -> \220x%02x%02x%02x%02x\22\0A\00"
define void @WriteUint32BE(i32 %0, i32* %1) {
%3 = icmp ne i32* %1, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = ashr i32 %0, 24
store i32 %6, i32* %1
%7 = lshr i32 %0, 16
%8 = and i32 %7, 255
%9 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %8, i32* %9
%10 = lshr i32 %0, 8
%11 = and i32 %10, 255
%12 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %11, i32* %12
%13 = and i32 %0, 255
%14 = getelementptr inbounds i32, i32* %1, i64 3
store i32 %13, i32* %14
%15 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %6, i32 %8, i32 %11, i32 %13)
ret void
}