#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*/ dal_reg_write(unsigned int, unsigned int, unsigned int);
int dal_reg_tbl_write(unsigned int dev_id, unsigned int reg_addr,
                      unsigned int *pvalue, unsigned int width) {
  unsigned int i = 0;
  unsigned int addr = reg_addr;
  unsigned int *src = pvalue;
  for (i = 0; i < width; i++) {
    dal_reg_write(dev_id, addr, *src);
    addr += sizeof(unsigned int);
    src++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<dal_reg_tbl_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1182 <dal_reg_tbl_write+0x72>
mov    -0x4(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%rax
mov    (%rax),%edx
call   1030 <dal_reg_write@plt>
mov    -0x1c(%rbp),%eax
add    $0x4,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1141 <dal_reg_tbl_write+0x31>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dal_reg_tbl_write>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %ecx,%ecx
je     114a <dal_reg_tbl_write+0x3a>
mov    %rdx,%r14
mov    %esi,%ebp
mov    %edi,%r15d
mov    %ecx,%r12d
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r14,%rbx,4),%edx
mov    %r15d,%edi
mov    %ebp,%esi
call   1030 <dal_reg_write@plt>
add    $0x4,%ebp
add    $0x1,%rbx
cmp    %ebx,%r12d
jne    1130 <dal_reg_tbl_write+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @dal_reg_tbl_write(i32 %0, i32 %1, i32* nocapture %2, i32 %3) {
%5 = icmp eq i32 %3, 0
br i1 %5, label %16, label %6
6: ; preds = %4, %6
%7 = phi i32* [ %13, %6 ], [ %2, %4 ]
%8 = phi i32 [ %12, %6 ], [ %1, %4 ]
%9 = phi i32 [ %14, %6 ], [ 0, %4 ]
%10 = load i32, i32* %7
%11 = tail call i32 @dal_reg_write(i32 %0, i32 %8, i32 %10)
%12 = add i32 %8, 4
%13 = getelementptr inbounds i32, i32* %7, i64 1
%14 = add nuw i32 %9, 1
%15 = icmp eq i32 %14, %3
br i1 %15, label %16, label %6
16: ; preds = %6, %4
ret i32 0
}