#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_s32b(FILE *fp) {
  u_char b[4];
  if (fread(b, 4, 1, fp) != 1)
    die_file_eof(fp);
  return b[3] + (b[2] << 8) + (b[1] << 16) + (b[0] << 24);
}


x86 assembly (clang, -O0):
<read_s32b>:
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_s32b+0x35>
mov    -0x8(%rbp),%rdi
call   1040 <die_file_eof@plt>
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
shl    $0x8,%ecx
add    %ecx,%eax
mov    -0x1c(%rbp),%ecx
shl    $0x10,%ecx
add    %ecx,%eax
mov    -0x20(%rbp),%ecx
shl    $0x18,%ecx
add    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_s32b>:
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_s32b+0x2a>
mov    %rbx,%rdi
call   1040 <die_file_eof@plt>
mov    0x8(%rsp),%ecx
shl    $0x8,%ecx
add    0xc(%rsp),%ecx
mov    (%rsp),%eax
mov    0x4(%rsp),%edx
shl    $0x10,%edx
add    %ecx,%edx
shl    $0x18,%eax
add    %edx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @read_s32b(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 3
%13 = load i32, i32* %12
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 2
%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 1
%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 0
%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_s32b(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 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%11 = load i32, i32* %10
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%13 = load i32, i32* %12
%14 = shl i32 %13, 8
%15 = add nsw i32 %14, %11
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%17 = load i32, i32* %16
%18 = shl i32 %17, 16
%19 = add nsw i32 %15, %18
%20 = load i32, i32* %4
%21 = shl i32 %20, 24
%22 = add nsw i32 %19, %21
ret i32 %22
}