#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int fread(unsigned int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int ReadUInt(FILE *fptr, unsigned int *n, int swap) {
  unsigned char *cptr, tmp;
  if (sizeof(int) != 4) {
    fprintf(stderr, "ReadUInt: sizeof(int)=%ld and not 4\n", sizeof(int));
    exit(0);
  }
  if (fread(n, 4, 1, fptr) != 1)
    return (0);
  if (swap) {
    cptr = (unsigned char *)n;
    tmp = cptr[0];
    cptr[0] = cptr[3];
    cptr[3] = tmp;
    tmp = cptr[1];
    cptr[1] = cptr[2];
    cptr[2] = tmp;
  }
  return (1);
}


x86 assembly (clang, -O0):
<ReadUInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     114f <ReadUInt+0x3f>
movl   $0x0,-0x4(%rbp)
jmp    11aa <ReadUInt+0x9a>
cmpl   $0x0,-0x1c(%rbp)
je     11a3 <ReadUInt+0x93>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x29(%rbp)
mov    -0x28(%rbp),%rax
mov    0x3(%rax),%cl
mov    -0x28(%rbp),%rax
mov    %cl,(%rax)
mov    -0x29(%rbp),%cl
mov    -0x28(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x28(%rbp),%rax
mov    0x1(%rax),%al
mov    %al,-0x29(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2(%rax),%cl
mov    -0x28(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x29(%rbp),%cl
mov    -0x28(%rbp),%rax
mov    %cl,0x2(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadUInt>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%rcx
mov    %rsi,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
jne    114e <ReadUInt+0x3e>
test   %ebp,%ebp
je     1149 <ReadUInt+0x39>
mov    (%rbx),%al
mov    0x3(%rbx),%cl
mov    %cl,(%rbx)
mov    %al,0x3(%rbx)
rolw   $0x8,0x1(%rbx)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
define i32 @ReadUInt(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
%10 = load i32*, i32** %6
%11 = load i32*, i32** %5
%12 = call i32 @fread(i32* %10, i32 4, i32 1, i32* %11)
%13 = icmp ne i32 %12, 1
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 0, i32* %4
br label %44
15: ; preds = %3
%16 = load i32, i32* %7
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %43
18: ; preds = %15
%19 = load i32*, i32** %6
%20 = bitcast i32* %19 to i8*
store i8* %20, i8** %8
%21 = load i8*, i8** %8
%22 = getelementptr inbounds i8, i8* %21, i64 0
%23 = load i8, i8* %22
store i8 %23, i8* %9
%24 = load i8*, i8** %8
%25 = getelementptr inbounds i8, i8* %24, i64 3
%26 = load i8, i8* %25
%27 = load i8*, i8** %8
%28 = getelementptr inbounds i8, i8* %27, i64 0
store i8 %26, i8* %28
%29 = load i8, i8* %9
%30 = load i8*, i8** %8
%31 = getelementptr inbounds i8, i8* %30, i64 3
store i8 %29, i8* %31
%32 = load i8*, i8** %8
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = load i8, i8* %33
store i8 %34, i8* %9
%35 = load i8*, i8** %8
%36 = getelementptr inbounds i8, i8* %35, i64 2
%37 = load i8, i8* %36
%38 = load i8*, i8** %8
%39 = getelementptr inbounds i8, i8* %38, i64 1
store i8 %37, i8* %39
%40 = load i8, i8* %9
%41 = load i8*, i8** %8
%42 = getelementptr inbounds i8, i8* %41, i64 2
store i8 %40, i8* %42
br label %43
43: ; preds = %18, %15
store i32 1, i32* %4
br label %44
44: ; preds = %43, %14
%45 = load i32, i32* %4
ret i32 %45
}

LLVM IR (-O2):
@stderr = global i32 0
define i32 @ReadUInt(i32* nocapture %0, i32* nocapture %1, i32 %2) {
%4 = tail call i32 @fread(i32* %1, i32 4, i32 1, i32* %0)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %17
6: ; preds = %3
%7 = icmp eq i32 %2, 0
br i1 %7, label %17, label %8
8: ; preds = %6
%9 = bitcast i32* %1 to i8*
%10 = load i8, i8* %9
%11 = getelementptr inbounds i8, i8* %9, i64 3
%12 = load i8, i8* %11
store i8 %12, i8* %9
store i8 %10, i8* %11
%13 = getelementptr inbounds i8, i8* %9, i64 1
%14 = load i8, i8* %13
%15 = getelementptr inbounds i8, i8* %9, i64 2
%16 = load i8, i8* %15
store i8 %16, i8* %13
store i8 %14, i8* %15
br label %17
17: ; preds = %6, %8, %3
%18 = phi i32 [ 0, %3 ], [ 1, %8 ], [ 1, %6 ]
ret i32 %18
}