#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 fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int ReadUINT(unsigned long int *x, FILE *f) {
  unsigned char little[4];
  if (x == NULL || f == NULL) {
    return 0;
  }
  if (fread(little, 4, 1, f) != 1) {
    return 0;
  }
  *x = (little[3] << 24 | little[2] << 16 | little[1] << 8 | little[0]);
  return 1;
}


x86 assembly (clang, -O0):
<ReadUINT>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1136 <ReadUINT+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1142 <ReadUINT+0x32>
movl   $0x0,-0x4(%rbp)
jmp    119e <ReadUINT+0x8e>
lea    -0x1c(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     116e <ReadUINT+0x5e>
movl   $0x0,-0x4(%rbp)
jmp    119e <ReadUINT+0x8e>
movzbl -0x19(%rbp),%eax
shl    $0x18,%eax
movzbl -0x1a(%rbp),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
movzbl -0x1b(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
movzbl -0x1c(%rbp),%ecx
or     %ecx,%eax
movslq %eax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadUINT>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
test   %rdi,%rdi
je     1170 <ReadUINT+0x60>
mov    %rsi,%rcx
test   %rsi,%rsi
je     1170 <ReadUINT+0x60>
mov    %rdi,%rbx
lea    0x4(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    1170 <ReadUINT+0x60>
movzbl 0x7(%rsp),%eax
shl    $0x18,%eax
movzbl 0x6(%rsp),%ecx
shl    $0x10,%rcx
cltq
or     %rcx,%rax
movzbl 0x5(%rsp),%ecx
shl    $0x8,%rcx
or     %rax,%rcx
movzbl 0x4(%rsp),%eax
or     %rcx,%rax
mov    %rax,(%rbx)
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @ReadUINT(i64* writeonly %0, i32* %1) {
%3 = alloca [4 x i8]
%4 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%5 = icmp eq i64* %0, null
%6 = icmp eq i32* %1, null
%7 = or i1 %5, %6
br i1 %7, label %30, label %8
8: ; preds = %2
%9 = call i32 @fread(i8* %4, i32 4, i32 1, i32* %1)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %30
11: ; preds = %8
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 3
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = shl nuw i32 %14, 24
%16 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = shl nuw nsw i32 %18, 16
%20 = or i32 %19, %15
%21 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = shl nuw nsw i32 %23, 8
%25 = or i32 %20, %24
%26 = load i8, i8* %4
%27 = zext i8 %26 to i32
%28 = or i32 %25, %27
%29 = sext i32 %28 to i64
store i64 %29, i64* %0
br label %30
30: ; preds = %8, %2, %11
%31 = phi i32 [ 1, %11 ], [ 0, %2 ], [ 0, %8 ]
ret i32 %31
}