#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 read_le_long(FILE *file, long *ret) {
  unsigned char buf[4];
  if (fread(buf, 1, 4, file) != 4)
    return 0;
  *ret = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
  return 0;
}


x86 assembly (clang, -O0):
<read_le_long>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x1c(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
cmp    $0x4,%eax
je     114c <read_le_long+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    117c <read_le_long+0x6c>
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    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_le_long>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%rcx
lea    0xc(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
cmp    $0x4,%eax
jne    1161 <read_le_long+0x51>
movzbl 0xf(%rsp),%eax
shl    $0x18,%eax
movzbl 0xe(%rsp),%ecx
shl    $0x10,%rcx
cltq
or     %rcx,%rax
movzbl 0xd(%rsp),%ecx
shl    $0x8,%rcx
or     %rax,%rcx
movzbl 0xc(%rsp),%eax
or     %rcx,%rax
mov    %rax,(%rbx)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

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