#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;
struct ByteStream {
  int dummy;
};

/* Variables and functions */
int ByteStream_read_byte(struct ByteStream *);
uint32_t ByteStream_read_u32(struct ByteStream *self) {
  return (ByteStream_read_byte(self) << 24) |
         (ByteStream_read_byte(self) << 16) |
         (ByteStream_read_byte(self) << 8) | ByteStream_read_byte(self);
}


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

x86 assembly (clang, -O2):
<ByteStream_read_u32>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <ByteStream_read_byte@plt>
mov    %eax,%ebp
shl    $0x18,%ebp
mov    %r14,%rdi
call   1030 <ByteStream_read_byte@plt>
mov    %eax,%ebx
shl    $0x10,%ebx
or     %ebp,%ebx
mov    %r14,%rdi
call   1030 <ByteStream_read_byte@plt>
mov    %eax,%ebp
shl    $0x8,%ebp
mov    %r14,%rdi
call   1030 <ByteStream_read_byte@plt>
or     %ebp,%eax
or     %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.ByteStream = type { i32 }
define i32 @ByteStream_read_u32(%struct.ByteStream* %0) {
%2 = alloca %struct.ByteStream*
store %struct.ByteStream* %0, %struct.ByteStream** %2
%3 = load %struct.ByteStream*, %struct.ByteStream** %2
%4 = call i32 @ByteStream_read_byte(%struct.ByteStream* %3)
%5 = shl i32 %4, 24
%6 = load %struct.ByteStream*, %struct.ByteStream** %2
%7 = call i32 @ByteStream_read_byte(%struct.ByteStream* %6)
%8 = shl i32 %7, 16
%9 = or i32 %5, %8
%10 = load %struct.ByteStream*, %struct.ByteStream** %2
%11 = call i32 @ByteStream_read_byte(%struct.ByteStream* %10)
%12 = shl i32 %11, 8
%13 = or i32 %9, %12
%14 = load %struct.ByteStream*, %struct.ByteStream** %2
%15 = call i32 @ByteStream_read_byte(%struct.ByteStream* %14)
%16 = or i32 %13, %15
ret i32 %16
}

LLVM IR (-O2):
%struct.ByteStream = type { i32 }
define i32 @ByteStream_read_u32(%struct.ByteStream* %0) {
%2 = tail call i32 @ByteStream_read_byte(%struct.ByteStream* %0)
%3 = shl i32 %2, 24
%4 = tail call i32 @ByteStream_read_byte(%struct.ByteStream* %0)
%5 = shl i32 %4, 16
%6 = or i32 %5, %3
%7 = tail call i32 @ByteStream_read_byte(%struct.ByteStream* %0)
%8 = shl i32 %7, 8
%9 = or i32 %6, %8
%10 = tail call i32 @ByteStream_read_byte(%struct.ByteStream* %0)
%11 = or i32 %9, %10
ret i32 %11
}