#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 */

/* Variables and functions */
int read_raw_byte(char *, void *, int);
int read_raw_little_endian32(unsigned long *tag, void *_buffer, int offset) {
  char b1, b2, b3, b4;
  offset = read_raw_byte((char *)tag, _buffer, offset);
  b1 = (char)*tag;
  offset = read_raw_byte((char *)tag, _buffer, offset);
  b2 = (char)*tag;
  offset = read_raw_byte((char *)tag, _buffer, offset);
  b3 = (char)*tag;
  offset = read_raw_byte((char *)tag, _buffer, offset);
  b4 = (char)*tag;
  *tag = (((unsigned long)b1 & 0xff)) | (((unsigned long)b2 & 0xff) << 8) |
         (((unsigned long)b3 & 0xff) << 16) |
         (((unsigned long)b4 & 0xff) << 24);
  return offset;
}


x86 assembly (clang, -O0):
<read_raw_little_endian32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <read_raw_byte@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %al,-0x15(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <read_raw_byte@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %al,-0x16(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <read_raw_byte@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %al,-0x17(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <read_raw_byte@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %al,-0x18(%rbp)
movsbq -0x15(%rbp),%rcx
and    $0xff,%rcx
movsbq -0x16(%rbp),%rax
and    $0xff,%rax
shl    $0x8,%rax
or     %rax,%rcx
movsbq -0x17(%rbp),%rax
and    $0xff,%rax
shl    $0x10,%rax
or     %rax,%rcx
movsbq -0x18(%rbp),%rax
and    $0xff,%rax
shl    $0x18,%rax
or     %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_raw_little_endian32>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <read_raw_byte@plt>
movzbl (%rbx),%r15d
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <read_raw_byte@plt>
mov    (%rbx),%r12d
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <read_raw_byte@plt>
mov    (%rbx),%r13d
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <read_raw_byte@plt>
mov    (%rbx),%ecx
shl    $0x8,%r12d
movzwl %r12w,%edx
or     %r15,%rdx
movzbl %r13b,%esi
shl    $0x10,%rsi
or     %rdx,%rsi
shl    $0x18,%ecx
or     %rsi,%rcx
mov    %rcx,(%rbx)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @read_raw_little_endian32(i64* %0, i8* %1, i32 %2) {
%4 = alloca i64*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
store i64* %0, i64** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%11 = load i64*, i64** %4
%12 = bitcast i64* %11 to i8*
%13 = load i8*, i8** %5
%14 = load i32, i32* %6
%15 = call i32 @read_raw_byte(i8* %12, i8* %13, i32 %14)
store i32 %15, i32* %6
%16 = load i64*, i64** %4
%17 = load i64, i64* %16
%18 = trunc i64 %17 to i8
store i8 %18, i8* %7
%19 = load i64*, i64** %4
%20 = bitcast i64* %19 to i8*
%21 = load i8*, i8** %5
%22 = load i32, i32* %6
%23 = call i32 @read_raw_byte(i8* %20, i8* %21, i32 %22)
store i32 %23, i32* %6
%24 = load i64*, i64** %4
%25 = load i64, i64* %24
%26 = trunc i64 %25 to i8
store i8 %26, i8* %8
%27 = load i64*, i64** %4
%28 = bitcast i64* %27 to i8*
%29 = load i8*, i8** %5
%30 = load i32, i32* %6
%31 = call i32 @read_raw_byte(i8* %28, i8* %29, i32 %30)
store i32 %31, i32* %6
%32 = load i64*, i64** %4
%33 = load i64, i64* %32
%34 = trunc i64 %33 to i8
store i8 %34, i8* %9
%35 = load i64*, i64** %4
%36 = bitcast i64* %35 to i8*
%37 = load i8*, i8** %5
%38 = load i32, i32* %6
%39 = call i32 @read_raw_byte(i8* %36, i8* %37, i32 %38)
store i32 %39, i32* %6
%40 = load i64*, i64** %4
%41 = load i64, i64* %40
%42 = trunc i64 %41 to i8
store i8 %42, i8* %10
%43 = load i8, i8* %7
%44 = sext i8 %43 to i64
%45 = and i64 %44, 255
%46 = load i8, i8* %8
%47 = sext i8 %46 to i64
%48 = and i64 %47, 255
%49 = shl i64 %48, 8
%50 = or i64 %45, %49
%51 = load i8, i8* %9
%52 = sext i8 %51 to i64
%53 = and i64 %52, 255
%54 = shl i64 %53, 16
%55 = or i64 %50, %54
%56 = load i8, i8* %10
%57 = sext i8 %56 to i64
%58 = and i64 %57, 255
%59 = shl i64 %58, 24
%60 = or i64 %55, %59
%61 = load i64*, i64** %4
store i64 %60, i64* %61
%62 = load i32, i32* %6
ret i32 %62
}

LLVM IR (-O2):
define i32 @read_raw_little_endian32(i64* %0, i8* %1, i32 %2) {
%4 = bitcast i64* %0 to i8*
%5 = tail call i32 @read_raw_byte(i8* %4, i8* %1, i32 %2)
%6 = load i64, i64* %0
%7 = tail call i32 @read_raw_byte(i8* %4, i8* %1, i32 %5)
%8 = load i64, i64* %0
%9 = tail call i32 @read_raw_byte(i8* %4, i8* %1, i32 %7)
%10 = load i64, i64* %0
%11 = tail call i32 @read_raw_byte(i8* %4, i8* %1, i32 %9)
%12 = load i64, i64* %0
%13 = and i64 %6, 255
%14 = shl i64 %8, 8
%15 = and i64 %14, 65280
%16 = or i64 %15, %13
%17 = shl i64 %10, 16
%18 = and i64 %17, 16711680
%19 = or i64 %16, %18
%20 = shl i64 %12, 24
%21 = and i64 %20, 4278190080
%22 = or i64 %19, %21
store i64 %22, i64* %0
ret i32 %11
}