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

/* Variables and functions */
int /*<<< orphan*/ die_file_eof(int /*<<< orphan*/ *);
int fread(int *, int, int, int /*<<< orphan*/ *);
int read_s32l(FILE *fp) {
  u_char b[4];
  if (fread(b, 4, 1, fp) != 1)
    die_file_eof(fp);
  return b[0] + (b[1] << 8) + (b[2] << 16) + (b[3] << 24);
}


x86 assembly (clang, -O0):
<read_s32l>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     1155 <read_s32l+0x35>
mov    -0x8(%rbp),%rdi
call   1040 <die_file_eof@plt>
mov    -0x20(%rbp),%eax
mov    -0x1c(%rbp),%ecx
shl    $0x8,%ecx
add    %ecx,%eax
mov    -0x18(%rbp),%ecx
shl    $0x10,%ecx
add    %ecx,%eax
mov    -0x14(%rbp),%ecx
shl    $0x18,%ecx
add    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_s32l>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %rsp,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     114a <read_s32l+0x2a>
mov    %rbx,%rdi
call   1040 <die_file_eof@plt>
mov    0x4(%rsp),%eax
mov    0x8(%rsp),%ecx
shl    $0x8,%eax
add    (%rsp),%eax
shl    $0x10,%ecx
add    %eax,%ecx
mov    0xc(%rsp),%eax
shl    $0x18,%eax
add    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @read_s32l(i32* %0) {
%2 = alloca i32*
%3 = alloca [4 x i32]
store i32* %0, i32** %2
%4 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%5 = load i32*, i32** %2
%6 = call i32 @fread(i32* %4, i32 4, i32 1, i32* %5)
%7 = icmp ne i32 %6, 1
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i32*, i32** %2
%10 = call i32 @die_file_eof(i32* %9)
br label %11
11: ; preds = %8, %1
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%13 = load i32, i32* %12
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 1
%15 = load i32, i32* %14
%16 = shl i32 %15, 8
%17 = add nsw i32 %13, %16
%18 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 2
%19 = load i32, i32* %18
%20 = shl i32 %19, 16
%21 = add nsw i32 %17, %20
%22 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 3
%23 = load i32, i32* %22
%24 = shl i32 %23, 24
%25 = add nsw i32 %21, %24
ret i32 %25
}

LLVM IR (-O2):
define i32 @read_s32l(i32* %0) {
%2 = alloca [4 x i32]
%3 = bitcast [4 x i32]* %2 to i8*
%4 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%5 = call i32 @fread(i32* %4, i32 4, i32 1, i32* %0)
%6 = icmp eq i32 %5, 1
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = tail call i32 @die_file_eof(i32* %0)
br label %9
9: ; preds = %7, %1
%10 = load i32, i32* %4
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%12 = load i32, i32* %11
%13 = shl i32 %12, 8
%14 = add nsw i32 %13, %10
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%16 = load i32, i32* %15
%17 = shl i32 %16, 16
%18 = add nsw i32 %14, %17
%19 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%20 = load i32, i32* %19
%21 = shl i32 %20, 24
%22 = add nsw i32 %18, %21
ret i32 %22
}