#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 unsigned int uint32_t;
typedef int uint16_t;

/* Variables and functions */
int ReadUint16BE(int const *);
int ReadUint16LE(int const *);
unsigned int ReadUint32BE(int const *);
unsigned int ReadUint32LE(int const *);
int /*<<< orphan*/ WriteUint16BE(int, int *);
int /*<<< orphan*/ WriteUint16LE(int, int *);
int /*<<< orphan*/ WriteUint32BE(unsigned int, int *);
int /*<<< orphan*/ WriteUint32LE(unsigned int, int *);
int /*<<< orphan*/ assert(int);
scalar_t__ memcmp(int const *, int const *, int);
int /*<<< orphan*/ puts(char *);
int main(void) {
  const uint8_t data16_le[] = {0xcd, 0xab};
  const uint8_t data16_be[] = {0xab, 0xcd};
  uint16_t le16 = ReadUint16LE(data16_le);
  assert(0xabcd == le16);
  uint16_t be16 = ReadUint16BE(data16_be);
  assert(0xabcd == be16);
  uint8_t out16_le[2] = {0};
  WriteUint16LE(le16, out16_le);
  assert(memcmp(out16_le, data16_le, 2) == 0);
  uint8_t out16_be[2] = {0};
  WriteUint16BE(be16, out16_be);
  assert(memcmp(out16_be, data16_be, 2) == 0);
  const uint8_t data32_le[] = {0xd2, 0x02, 0x96, 0x49};
  const uint8_t data32_be[] = {0x49, 0x96, 0x02, 0xd2};
  uint32_t le32 = ReadUint32LE(data32_le);
  assert(1234567890u == le32);
  assert(0x499602d2u == le32);
  uint32_t be32 = ReadUint32BE(data32_be);
  assert(1234567890u == be32);
  assert(0x499602d2u == be32);
  uint8_t out32_le[4] = {0};
  WriteUint32LE(le32, out32_le);
  assert(memcmp(out32_le, data32_le, 4) == 0);
  uint8_t out32_be[4] = {0};
  WriteUint32BE(1234567890u, out32_be);
  assert(memcmp(data32_be, out32_be, 4) == 0);
  puts("ok");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe27(%rip),%rax
mov    %rax,-0xc(%rbp)
mov    0xe24(%rip),%rax
mov    %rax,-0x14(%rbp)
lea    -0xc(%rbp),%rdi
call   10a0 <ReadUint16LE@plt>
mov    %eax,-0x18(%rbp)
mov    $0xabcd,%eax
cmp    -0x18(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
lea    -0x14(%rbp),%rdi
call   1040 <ReadUint16BE@plt>
mov    %eax,-0x1c(%rbp)
mov    $0xabcd,%eax
cmp    -0x1c(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
lea    -0x24(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
mov    -0x18(%rbp),%edi
lea    -0x24(%rbp),%rsi
call   10d0 <WriteUint16LE@plt>
lea    -0x24(%rbp),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x2,%edx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
lea    -0x2c(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
mov    -0x1c(%rbp),%edi
lea    -0x2c(%rbp),%rsi
call   1070 <WriteUint16BE@plt>
lea    -0x2c(%rbp),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x2,%edx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    0xd61(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xd5e(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xd5b(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xd58(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    -0x40(%rbp),%rdi
call   10b0 <ReadUint32LE@plt>
mov    %eax,-0x54(%rbp)
mov    $0x499602d2,%eax
cmp    -0x54(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    $0x499602d2,%eax
cmp    -0x54(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
lea    -0x50(%rbp),%rdi
call   10c0 <ReadUint32BE@plt>
mov    %eax,-0x58(%rbp)
mov    $0x499602d2,%eax
cmp    -0x58(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    $0x499602d2,%eax
cmp    -0x58(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
mov    -0x54(%rbp),%edi
lea    -0x70(%rbp),%rsi
call   1090 <WriteUint32LE@plt>
lea    -0x70(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x4,%edx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
lea    -0x80(%rbp),%rsi
mov    $0x499602d2,%edi
call   10e0 <WriteUint32BE@plt>
lea    -0x50(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x4,%edx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
lea    0xc69(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x60,%rsp
movabs $0xab000000cd,%rax
mov    %rax,0x18(%rsp)
movabs $0xcd000000ab,%rax
mov    %rax,0x10(%rsp)
lea    0x18(%rsp),%r15
mov    %r15,%rdi
call   1090 <ReadUint16LE@plt>
mov    %eax,%ebx
xor    %edi,%edi
cmp    $0xabcd,%eax
sete   %dil
call   1070 <assert@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1040 <ReadUint16BE@plt>
mov    %eax,%ebp
xor    %edi,%edi
cmp    $0xabcd,%eax
sete   %dil
call   1070 <assert@plt>
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%r12
mov    %ebx,%edi
mov    %r12,%rsi
call   10c0 <WriteUint16LE@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x2,%edx
call   1050 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
movq   $0x0,(%rsp)
mov    %rsp,%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <WriteUint16BE@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   1050 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
movaps 0xd88(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xd8c(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
lea    0x50(%rsp),%r15
mov    %r15,%rdi
call   10a0 <ReadUint32LE@plt>
mov    %eax,%ebp
xor    %ebx,%ebx
cmp    $0x499602d2,%eax
sete   %bl
mov    %ebx,%edi
call   1070 <assert@plt>
mov    %ebx,%edi
call   1070 <assert@plt>
lea    0x40(%rsp),%r14
mov    %r14,%rdi
call   10b0 <ReadUint32BE@plt>
xor    %ebx,%ebx
cmp    $0x499602d2,%eax
sete   %bl
mov    %ebx,%edi
call   1070 <assert@plt>
mov    %ebx,%edi
call   1070 <assert@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
lea    0x30(%rsp),%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1080 <WriteUint32LE@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
lea    0x20(%rsp),%rbx
mov    $0x499602d2,%edi
mov    %rbx,%rsi
call   10d0 <WriteUint32BE@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
lea    0xcd7(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.data16_le = [2 x i32] [i32 205, i32 171]
@__const.main.data16_be = [2 x i32] [i32 171, i32 205]
@__const.main.data32_le = [4 x i32] [i32 210, i32 2, i32 150, i32 73]
@__const.main.data32_be = [4 x i32] [i32 73, i32 150, i32 2, i32 210]
@.str = [3 x i8] c"ok\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = alloca [2 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca [2 x i32]
%7 = alloca [2 x i32]
%8 = alloca [4 x i32]
%9 = alloca [4 x i32]
%10 = alloca i32
%11 = alloca i32
%12 = alloca [4 x i32]
%13 = alloca [4 x i32]
store i32 0, i32* %1
%14 = bitcast [2 x i32]* %2 to i8*
%15 = bitcast [2 x i32]* %3 to i8*
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%17 = call i32 @ReadUint16LE(i32* %16)
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = icmp eq i32 43981, %18
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%23 = call i32 @ReadUint16BE(i32* %22)
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = icmp eq i32 43981, %24
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = bitcast [2 x i32]* %6 to i8*
%29 = load i32, i32* %4
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%31 = call i32 @WriteUint16LE(i32 %29, i32* %30)
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%33 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%34 = call i64 @memcmp(i32* %32, i32* %33, i32 2)
%35 = icmp eq i64 %34, 0
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = bitcast [2 x i32]* %7 to i8*
%39 = load i32, i32* %5
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%41 = call i32 @WriteUint16BE(i32 %39, i32* %40)
%42 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%43 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%44 = call i64 @memcmp(i32* %42, i32* %43, i32 2)
%45 = icmp eq i64 %44, 0
%46 = zext i1 %45 to i32
%47 = call i32 @assert(i32 %46)
%48 = bitcast [4 x i32]* %8 to i8*
%49 = bitcast [4 x i32]* %9 to i8*
%50 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 0
%51 = call i32 @ReadUint32LE(i32* %50)
store i32 %51, i32* %10
%52 = load i32, i32* %10
%53 = icmp eq i32 1234567890, %52
%54 = zext i1 %53 to i32
%55 = call i32 @assert(i32 %54)
%56 = load i32, i32* %10
%57 = icmp eq i32 1234567890, %56
%58 = zext i1 %57 to i32
%59 = call i32 @assert(i32 %58)
%60 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 0
%61 = call i32 @ReadUint32BE(i32* %60)
store i32 %61, i32* %11
%62 = load i32, i32* %11
%63 = icmp eq i32 1234567890, %62
%64 = zext i1 %63 to i32
%65 = call i32 @assert(i32 %64)
%66 = load i32, i32* %11
%67 = icmp eq i32 1234567890, %66
%68 = zext i1 %67 to i32
%69 = call i32 @assert(i32 %68)
%70 = bitcast [4 x i32]* %12 to i8*
%71 = load i32, i32* %10
%72 = getelementptr inbounds [4 x i32], [4 x i32]* %12, i64 0, i64 0
%73 = call i32 @WriteUint32LE(i32 %71, i32* %72)
%74 = getelementptr inbounds [4 x i32], [4 x i32]* %12, i64 0, i64 0
%75 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 0
%76 = call i64 @memcmp(i32* %74, i32* %75, i32 4)
%77 = icmp eq i64 %76, 0
%78 = zext i1 %77 to i32
%79 = call i32 @assert(i32 %78)
%80 = bitcast [4 x i32]* %13 to i8*
%81 = getelementptr inbounds [4 x i32], [4 x i32]* %13, i64 0, i64 0
%82 = call i32 @WriteUint32BE(i32 1234567890, i32* %81)
%83 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 0
%84 = getelementptr inbounds [4 x i32], [4 x i32]* %13, i64 0, i64 0
%85 = call i64 @memcmp(i32* %83, i32* %84, i32 4)
%86 = icmp eq i64 %85, 0
%87 = zext i1 %86 to i32
%88 = call i32 @assert(i32 %87)
%89 = call i32 @puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.data32_le = [4 x i32] [i32 210, i32 2, i32 150, i32 73]
@__const.main.data32_be = [4 x i32] [i32 73, i32 150, i32 2, i32 210]
@.str = [3 x i8] c"ok\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca [4 x i32]
%6 = alloca [4 x i32]
%7 = alloca [4 x i32]
%8 = alloca [4 x i32]
%9 = bitcast i64* %1 to i8*
store i64 734439407821, i64* %1
%10 = bitcast i64* %2 to i8*
store i64 880468295851, i64* %2
%11 = bitcast i64* %1 to i32*
%12 = call i32 @ReadUint16LE(i32* %11)
%13 = icmp eq i32 %12, 43981
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = bitcast i64* %2 to i32*
%17 = call i32 @ReadUint16BE(i32* %16)
%18 = icmp eq i32 %17, 43981
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%22 = bitcast i64* %3 to i32*
%23 = call i32 @WriteUint16LE(i32 %12, i32* %22)
%24 = call i64 @memcmp(i32* %22, i32* %11, i32 2)
%25 = icmp eq i64 %24, 0
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%29 = bitcast i64* %4 to i32*
%30 = call i32 @WriteUint16BE(i32 %17, i32* %29)
%31 = call i64 @memcmp(i32* %29, i32* %16, i32 2)
%32 = icmp eq i64 %31, 0
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = bitcast [4 x i32]* %5 to i8*
%36 = bitcast [4 x i32]* %6 to i8*
%37 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 0
%38 = call i32 @ReadUint32LE(i32* %37)
%39 = icmp eq i32 %38, 1234567890
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
%42 = call i32 @assert(i32 %40)
%43 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%44 = call i32 @ReadUint32BE(i32* %43)
%45 = icmp eq i32 %44, 1234567890
%46 = zext i1 %45 to i32
%47 = call i32 @assert(i32 %46)
%48 = call i32 @assert(i32 %46)
%49 = bitcast [4 x i32]* %7 to i8*
%50 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 0
%51 = call i32 @WriteUint32LE(i32 %38, i32* %50)
%52 = call i64 @memcmp(i32* %50, i32* %37, i32 4)
%53 = icmp eq i64 %52, 0
%54 = zext i1 %53 to i32
%55 = call i32 @assert(i32 %54)
%56 = bitcast [4 x i32]* %8 to i8*
%57 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 0
%58 = call i32 @WriteUint32BE(i32 1234567890, i32* %57)
%59 = call i64 @memcmp(i32* %43, i32* %57, i32 4)
%60 = icmp eq i64 %59, 0
%61 = zext i1 %60 to i32
%62 = call i32 @assert(i32 %61)
%63 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
ret i32 0
}