#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;

/* Variables and functions */
int riva128_mmio_read(int, void *);
uint32_t riva128_mmio_read_l(uint32_t addr, void *p) {
  addr &= 0xffffff;
  return (riva128_mmio_read(addr + 0, p) << 0) |
         (riva128_mmio_read(addr + 1, p) << 8) |
         (riva128_mmio_read(addr + 2, p) << 16) |
         (riva128_mmio_read(addr + 3, p) << 24);
}


x86 assembly (clang, -O0):
<riva128_mmio_read_l>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    $0xffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
add    $0x0,%edi
mov    -0x10(%rbp),%rsi
call   1030 <riva128_mmio_read@plt>
shl    $0x0,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
add    $0x1,%edi
mov    -0x10(%rbp),%rsi
call   1030 <riva128_mmio_read@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
shl    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
add    $0x2,%edi
mov    -0x10(%rbp),%rsi
call   1030 <riva128_mmio_read@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
shl    $0x10,%ecx
or     %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
add    $0x3,%edi
mov    -0x10(%rbp),%rsi
call   1030 <riva128_mmio_read@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
shl    $0x18,%ecx
or     %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<riva128_mmio_read_l>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebx
and    $0xffffff,%ebx
mov    %ebx,%edi
call   1030 <riva128_mmio_read@plt>
mov    %eax,%r15d
lea    0x1(%rbx),%edi
mov    %r14,%rsi
call   1030 <riva128_mmio_read@plt>
mov    %eax,%ebp
shl    $0x8,%ebp
or     %r15d,%ebp
lea    0x2(%rbx),%edi
mov    %r14,%rsi
call   1030 <riva128_mmio_read@plt>
mov    %eax,%r15d
shl    $0x10,%r15d
add    $0x3,%ebx
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <riva128_mmio_read@plt>
shl    $0x18,%eax
or     %r15d,%eax
or     %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @riva128_mmio_read_l(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i32, i32* %3
%6 = and i32 %5, 16777215
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = add nsw i32 %7, 0
%9 = load i8*, i8** %4
%10 = call i32 @riva128_mmio_read(i32 %8, i8* %9)
%11 = shl i32 %10, 0
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
%14 = load i8*, i8** %4
%15 = call i32 @riva128_mmio_read(i32 %13, i8* %14)
%16 = shl i32 %15, 8
%17 = or i32 %11, %16
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 2
%20 = load i8*, i8** %4
%21 = call i32 @riva128_mmio_read(i32 %19, i8* %20)
%22 = shl i32 %21, 16
%23 = or i32 %17, %22
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 3
%26 = load i8*, i8** %4
%27 = call i32 @riva128_mmio_read(i32 %25, i8* %26)
%28 = shl i32 %27, 24
%29 = or i32 %23, %28
ret i32 %29
}

LLVM IR (-O2):
define i32 @riva128_mmio_read_l(i32 %0, i8* %1) {
%3 = and i32 %0, 16777215
%4 = tail call i32 @riva128_mmio_read(i32 %3, i8* %1)
%5 = add nuw nsw i32 %3, 1
%6 = tail call i32 @riva128_mmio_read(i32 %5, i8* %1)
%7 = shl i32 %6, 8
%8 = or i32 %7, %4
%9 = add nuw nsw i32 %3, 2
%10 = tail call i32 @riva128_mmio_read(i32 %9, i8* %1)
%11 = shl i32 %10, 16
%12 = or i32 %8, %11
%13 = add nuw nsw i32 %3, 3
%14 = tail call i32 @riva128_mmio_read(i32 %13, i8* %1)
%15 = shl i32 %14, 24
%16 = or i32 %12, %15
ret i32 %16
}