#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ fread_err(unsigned char *, int, int, int /*<<< orphan*/ *);
void ReadDWORDBE(FILE *inf, unsigned long *ptr) {
  unsigned char buffer[4] = {0};
  (assert((inf != NULL) && (ptr != NULL)));
  fread_err(buffer, 4, 1, inf);
  *ptr = ((unsigned long)buffer[0] << 24) | ((unsigned long)buffer[1] << 16) |
         ((unsigned long)buffer[2] << 8) | ((unsigned long)buffer[3]);
}


x86 assembly (clang, -O0):
<ReadDWORDBE>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x15(%rbp)
je     116b <ReadDWORDBE+0x3b>
cmpq   $0x0,-0x10(%rbp)
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0x14(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fread_err@plt>
movzbl -0x14(%rbp),%eax
mov    %eax,%ecx
shl    $0x18,%rcx
movzbl -0x13(%rbp),%eax
shl    $0x10,%rax
or     %rax,%rcx
movzbl -0x12(%rbp),%eax
shl    $0x8,%rax
or     %rax,%rcx
movzbl -0x11(%rbp),%eax
or     %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadDWORDBE>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0x0,0x4(%rsp)
test   %rdi,%rdi
setne  %al
test   %rsi,%rsi
setne  %cl
and    %al,%cl
movzbl %cl,%edi
call   1030 <assert@plt>
lea    0x4(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread_err@plt>
mov    0x4(%rsp),%eax
shl    $0x20,%rax
bswap  %rax
mov    %rax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @ReadDWORDBE(i32* %0, i64* %1) {
%3 = alloca i32*
%4 = alloca i64*
%5 = alloca [4 x i8]
store i32* %0, i32** %3
store i64* %1, i64** %4
%6 = bitcast [4 x i8]* %5 to i8*
%7 = load i32*, i32** %3
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i64*, i64** %4
%11 = icmp ne i64* %10, null
br label %12
12: ; preds = %9, %2
%13 = phi i1 [ false, %2 ], [ %11, %9 ]
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%17 = load i32*, i32** %3
%18 = call i32 @fread_err(i8* %16, i32 4, i32 1, i32* %17)
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%20 = load i8, i8* %19
%21 = zext i8 %20 to i64
%22 = shl i64 %21, 24
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 1
%24 = load i8, i8* %23
%25 = zext i8 %24 to i64
%26 = shl i64 %25, 16
%27 = or i64 %22, %26
%28 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 2
%29 = load i8, i8* %28
%30 = zext i8 %29 to i64
%31 = shl i64 %30, 8
%32 = or i64 %27, %31
%33 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 3
%34 = load i8, i8* %33
%35 = zext i8 %34 to i64
%36 = or i64 %32, %35
%37 = load i64*, i64** %4
store i64 %36, i64* %37
ret void
}

LLVM IR (-O2):
define void @ReadDWORDBE(i32* %0, i64* writeonly %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to [4 x i8]*
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = icmp ne i32* %0, null
%7 = icmp ne i64* %1, null
%8 = and i1 %6, %7
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = call i32 @fread_err(i8* %5, i32 4, i32 1, i32* %0)
%12 = load i8, i8* %5
%13 = zext i8 %12 to i64
%14 = shl nuw nsw i64 %13, 24
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 1
%16 = load i8, i8* %15
%17 = zext i8 %16 to i64
%18 = shl nuw nsw i64 %17, 16
%19 = or i64 %18, %14
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 2
%21 = load i8, i8* %20
%22 = zext i8 %21 to i64
%23 = shl nuw nsw i64 %22, 8
%24 = or i64 %19, %23
%25 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
%26 = load i8, i8* %25
%27 = zext i8 %26 to i64
%28 = or i64 %24, %27
store i64 %28, i64* %1
ret void
}