#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 */
scalar_t__ fgetc(int /*<<< orphan*/ *);
uint32_t read4ByteUnsignedInt32(FILE *stream) {
  uint32_t result = (uint32_t)fgetc(stream);
  result <<= 8;
  result |= (uint32_t)fgetc(stream);
  result <<= 8;
  result |= (uint32_t)fgetc(stream);
  result <<= 8;
  result |= (uint32_t)fgetc(stream);
  return result;
}


x86 assembly (clang, -O0):
<read4ByteUnsignedInt32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read4ByteUnsignedInt32>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <fgetc@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <fgetc@plt>
mov    %rax,%r12
shl    $0x10,%r15d
shl    $0x8,%r12d
or     %r15d,%r12d
mov    %r14,%rdi
call   1030 <fgetc@plt>
mov    %rax,%rbx
or     %r12d,%ebx
shl    $0x8,%ebx
mov    %r14,%rdi
call   1030 <fgetc@plt>
or     %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @read4ByteUnsignedInt32(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = call i64 @fgetc(i32* %4)
%6 = trunc i64 %5 to i32
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = shl i32 %7, 8
store i32 %8, i32* %3
%9 = load i32*, i32** %2
%10 = call i64 @fgetc(i32* %9)
%11 = trunc i64 %10 to i32
%12 = load i32, i32* %3
%13 = or i32 %12, %11
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = shl i32 %14, 8
store i32 %15, i32* %3
%16 = load i32*, i32** %2
%17 = call i64 @fgetc(i32* %16)
%18 = trunc i64 %17 to i32
%19 = load i32, i32* %3
%20 = or i32 %19, %18
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = shl i32 %21, 8
store i32 %22, i32* %3
%23 = load i32*, i32** %2
%24 = call i64 @fgetc(i32* %23)
%25 = trunc i64 %24 to i32
%26 = load i32, i32* %3
%27 = or i32 %26, %25
store i32 %27, i32* %3
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
define i32 @read4ByteUnsignedInt32(i32* nocapture %0) {
%2 = tail call i64 @fgetc(i32* %0)
%3 = trunc i64 %2 to i32
%4 = tail call i64 @fgetc(i32* %0)
%5 = trunc i64 %4 to i32
%6 = shl i32 %3, 16
%7 = shl i32 %5, 8
%8 = or i32 %7, %6
%9 = tail call i64 @fgetc(i32* %0)
%10 = trunc i64 %9 to i32
%11 = or i32 %8, %10
%12 = shl i32 %11, 8
%13 = tail call i64 @fgetc(i32* %0)
%14 = trunc i64 %13 to i32
%15 = or i32 %12, %14
ret i32 %15
}