#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 /*<<< orphan*/ writel(unsigned long, unsigned long *);
void nsp_mmio_multi_write_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++) {
    writel(*tmp, ptr);
    tmp++;
  }
}


x86 assembly (clang, -O0):
<nsp_mmio_multi_write_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    117c <nsp_mmio_multi_write_4+0x6c>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <writel@plt>
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_write_4+0x34>
add    $0x40,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define void @nsp_mmio_multi_write_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 = %31, %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 %34
24: ; preds = %19
%25 = load i64*, i64** %10
%26 = load i64, i64* %25
%27 = load i64*, i64** %9
%28 = call i32 @writel(i64 %26, i64* %27)
%29 = load i64*, i64** %10
%30 = getelementptr inbounds i64, i64* %29, i32 1
store i64* %30, i64** %10
br label %31
31: ; preds = %24
%32 = load i32, i32* %11
%33 = add nsw i32 %32, 1
store i32 %33, i32* %11
br label %19
34: ; preds = %19
ret void
}

LLVM IR (-O2):
define void @nsp_mmio_multi_write_4(i64 %0, i32 %1, i8* nocapture %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 %19, label %9
9: ; preds = %4
%10 = bitcast i8* %2 to i64*
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %17, %11 ]
%13 = phi i64* [ %10, %9 ], [ %16, %11 ]
%14 = load i64, i64* %13
%15 = tail call i32 @writel(i64 %14, i64* %7)
%16 = getelementptr inbounds i64, i64* %13, i64 1
%17 = add nuw i64 %12, 1
%18 = icmp eq i64 %17, %3
br i1 %18, label %19, label %11
19: ; preds = %11, %4
ret void
}