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

/* Variables and functions */
int EOF;
int fgetc(int /*<<< orphan*/ *);
int read4b(FILE *fp, uint32_t *d) {
  int c;
  *d = 0;
  c = fgetc(fp);
  if (c == EOF)
    return -1;
  *d += (uint32_t)c;
  c = fgetc(fp);
  if (c == EOF)
    return -1;
  *d += (uint32_t)c << 8;
  c = fgetc(fp);
  if (c == EOF)
    return -1;
  *d += (uint32_t)c << 16;
  c = fgetc(fp);
  if (c == EOF)
    return -1;
  *d += (uint32_t)c << 24;
  return 0;
}


x86 assembly (clang, -O0):
<read4b>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2ea8(%rip),%rcx
cmp    (%rcx),%eax
jne    1154 <read4b+0x44>
movl   $0xffffffff,-0x4(%rbp)
jmp    120e <read4b+0xfe>
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2e73(%rip),%rcx
cmp    (%rcx),%eax
jne    1189 <read4b+0x79>
movl   $0xffffffff,-0x4(%rbp)
jmp    120e <read4b+0xfe>
mov    -0x1c(%rbp),%ecx
shl    $0x8,%ecx
mov    -0x18(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2e3b(%rip),%rcx
cmp    (%rcx),%eax
jne    11c1 <read4b+0xb1>
movl   $0xffffffff,-0x4(%rbp)
jmp    120e <read4b+0xfe>
mov    -0x1c(%rbp),%ecx
shl    $0x10,%ecx
mov    -0x18(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2e03(%rip),%rcx
cmp    (%rcx),%eax
jne    11f9 <read4b+0xe9>
movl   $0xffffffff,-0x4(%rbp)
jmp    120e <read4b+0xfe>
mov    -0x1c(%rbp),%ecx
shl    $0x18,%ecx
mov    -0x18(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read4b>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%rbp
movl   $0x0,(%rsi)
call   1030 <fgetc@plt>
mov    0x2eb9(%rip),%r15
mov    $0xffffffff,%r14d
cmp    (%r15),%eax
je     1175 <read4b+0x65>
add    %eax,(%rbx)
mov    %rbp,%rdi
call   1030 <fgetc@plt>
cmp    (%r15),%eax
je     1175 <read4b+0x65>
shl    $0x8,%eax
add    %eax,(%rbx)
mov    %rbp,%rdi
call   1030 <fgetc@plt>
cmp    (%r15),%eax
je     1175 <read4b+0x65>
shl    $0x10,%eax
add    %eax,(%rbx)
mov    %rbp,%rdi
call   1030 <fgetc@plt>
cmp    (%r15),%eax
je     1175 <read4b+0x65>
shl    $0x18,%eax
add    %eax,(%rbx)
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @read4b(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
%7 = load i32*, i32** %5
store i32 0, i32* %7
%8 = load i32*, i32** %4
%9 = call i32 @fgetc(i32* %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = load i32, i32* @EOF
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 -1, i32* %3
br label %55
14: ; preds = %2
%15 = load i32, i32* %6
%16 = load i32*, i32** %5
%17 = load i32, i32* %16
%18 = add nsw i32 %17, %15
store i32 %18, i32* %16
%19 = load i32*, i32** %4
%20 = call i32 @fgetc(i32* %19)
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = load i32, i32* @EOF
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %25
24: ; preds = %14
store i32 -1, i32* %3
br label %55
25: ; preds = %14
%26 = load i32, i32* %6
%27 = shl i32 %26, 8
%28 = load i32*, i32** %5
%29 = load i32, i32* %28
%30 = add nsw i32 %29, %27
store i32 %30, i32* %28
%31 = load i32*, i32** %4
%32 = call i32 @fgetc(i32* %31)
store i32 %32, i32* %6
%33 = load i32, i32* %6
%34 = load i32, i32* @EOF
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %37
36: ; preds = %25
store i32 -1, i32* %3
br label %55
37: ; preds = %25
%38 = load i32, i32* %6
%39 = shl i32 %38, 16
%40 = load i32*, i32** %5
%41 = load i32, i32* %40
%42 = add nsw i32 %41, %39
store i32 %42, i32* %40
%43 = load i32*, i32** %4
%44 = call i32 @fgetc(i32* %43)
store i32 %44, i32* %6
%45 = load i32, i32* %6
%46 = load i32, i32* @EOF
%47 = icmp eq i32 %45, %46
br i1 %47, label %48, label %49
48: ; preds = %37
store i32 -1, i32* %3
br label %55
49: ; preds = %37
%50 = load i32, i32* %6
%51 = shl i32 %50, 24
%52 = load i32*, i32** %5
%53 = load i32, i32* %52
%54 = add nsw i32 %53, %51
store i32 %54, i32* %52
store i32 0, i32* %3
br label %55
55: ; preds = %49, %48, %36, %24, %13
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @read4b(i32* nocapture %0, i32* nocapture %1) {
store i32 0, i32* %1
%3 = tail call i32 @fgetc(i32* %0)
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %30, label %6
6: ; preds = %2
%7 = load i32, i32* %1
%8 = add nsw i32 %7, %3
store i32 %8, i32* %1
%9 = tail call i32 @fgetc(i32* %0)
%10 = load i32, i32* @EOF
%11 = icmp eq i32 %9, %10
br i1 %11, label %30, label %12
12: ; preds = %6
%13 = shl i32 %9, 8
%14 = load i32, i32* %1
%15 = add nsw i32 %14, %13
store i32 %15, i32* %1
%16 = tail call i32 @fgetc(i32* %0)
%17 = load i32, i32* @EOF
%18 = icmp eq i32 %16, %17
br i1 %18, label %30, label %19
19: ; preds = %12
%20 = shl i32 %16, 16
%21 = load i32, i32* %1
%22 = add nsw i32 %21, %20
store i32 %22, i32* %1
%23 = tail call i32 @fgetc(i32* %0)
%24 = load i32, i32* @EOF
%25 = icmp eq i32 %23, %24
br i1 %25, label %30, label %26
26: ; preds = %19
%27 = shl i32 %23, 24
%28 = load i32, i32* %1
%29 = add nsw i32 %28, %27
store i32 %29, i32* %1
br label %30
30: ; preds = %19, %12, %6, %2, %26
%31 = phi i32 [ 0, %26 ], [ -1, %2 ], [ -1, %6 ], [ -1, %12 ], [ -1, %19 ]
ret i32 %31
}