#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 */
unsigned long readl(unsigned long *);
void nsp_mmio_multi_read_4(unsigned long base, unsigned int Register, void *buf,
                           unsigned long count) {
  unsigned long *ptr = (unsigned long *)(base + Register);
  unsigned long *tmp = (unsigned long *)buf;
  int i;
  for (i = 0; i < count; i++) {
    *tmp = readl(ptr);
    tmp++;
  }
}


x86 assembly (clang, -O0):
<nsp_mmio_multi_read_4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movslq -0x34(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    117f <nsp_mmio_multi_read_4+0x6f>
mov    -0x28(%rbp),%rdi
call   1030 <readl@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x30(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1144 <nsp_mmio_multi_read_4+0x34>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nsp_mmio_multi_read_4>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rcx,%rcx
je     1145 <nsp_mmio_multi_read_4+0x35>
mov    %rcx,%r15
mov    %rdx,%r14
mov    %esi,%r12d
add    %rdi,%r12
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1030 <readl@plt>
mov    %rax,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1130 <nsp_mmio_multi_read_4+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @nsp_mmio_multi_read_4(i64 %0, i32 %1, i8* %2, i64 %3) {
%5 = alloca i64
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64*
%10 = alloca i64*
%11 = alloca i32
store i64 %0, i64* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i64 %3, i64* %8
%12 = load i64, i64* %5
%13 = load i32, i32* %6
%14 = zext i32 %13 to i64
%15 = add i64 %12, %14
%16 = inttoptr i64 %15 to i64*
store i64* %16, i64** %9
%17 = load i8*, i8** %7
%18 = bitcast i8* %17 to i64*
store i64* %18, i64** %10
store i32 0, i32* %11
br label %19
19: ; preds = %30, %4
%20 = load i32, i32* %11
%21 = sext i32 %20 to i64
%22 = load i64, i64* %8
%23 = icmp ult i64 %21, %22
br i1 %23, label %24, label %33
24: ; preds = %19
%25 = load i64*, i64** %9
%26 = call i64 @readl(i64* %25)
%27 = load i64*, i64** %10
store i64 %26, i64* %27
%28 = load i64*, i64** %10
%29 = getelementptr inbounds i64, i64* %28, i32 1
store i64* %29, i64** %10
br label %30
30: ; preds = %24
%31 = load i32, i32* %11
%32 = add nsw i32 %31, 1
store i32 %32, i32* %11
br label %19
33: ; preds = %19
ret void
}

LLVM IR (-O2):
define void @nsp_mmio_multi_read_4(i64 %0, i32 %1, i8* nocapture writeonly %2, i64 %3) {
%5 = zext i32 %1 to i64
%6 = add i64 %5, %0
%7 = inttoptr i64 %6 to i64*
%8 = icmp eq i64 %3, 0
br i1 %8, label %18, label %9
9: ; preds = %4
%10 = bitcast i8* %2 to i64*
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %16, %11 ]
%13 = phi i64* [ %10, %9 ], [ %15, %11 ]
%14 = tail call i64 @readl(i64* %7)
store i64 %14, i64* %13
%15 = getelementptr inbounds i64, i64* %13, i64 1
%16 = add nuw i64 %12, 1
%17 = icmp eq i64 %16, %3
br i1 %17, label %18, label %11
18: ; preds = %11, %4
ret void
}