#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_read(unsigned int, unsigned int, unsigned int *);
int dal_reg_tbl_read(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 *dst = pvalue;
  for (i = 0; i < width; i++) {
    dal_reg_read(dev_id, addr, dst);
    addr += sizeof(unsigned int);
    dst++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<dal_reg_tbl_read>:
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    1180 <dal_reg_tbl_read+0x70>
mov    -0x4(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1030 <dal_reg_read@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_read+0x31>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dal_reg_tbl_read>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %ecx,%ecx
je     114a <dal_reg_tbl_read+0x3a>
mov    %ecx,%r14d
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %edi,%r15d
cs nopw 0x0(%rax,%rax,1)
mov    %r15d,%edi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1030 <dal_reg_read@plt>
add    $0x4,%ebp
add    $0x4,%rbx
add    $0xffffffff,%r14d
jne    1130 <dal_reg_tbl_read+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @dal_reg_tbl_read(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 = %29, %4
%15 = load i32, i32* %9
%16 = load i32, i32* %8
%17 = icmp ult i32 %15, %16
br i1 %17, label %18, label %32
18: ; preds = %14
%19 = load i32, i32* %5
%20 = load i32, i32* %10
%21 = load i32*, i32** %11
%22 = call i32 @dal_reg_read(i32 %19, i32 %20, i32* %21)
%23 = load i32, i32* %10
%24 = zext i32 %23 to i64
%25 = add i64 %24, 4
%26 = trunc i64 %25 to i32
store i32 %26, i32* %10
%27 = load i32*, i32** %11
%28 = getelementptr inbounds i32, i32* %27, i32 1
store i32* %28, i32** %11
br label %29
29: ; preds = %18
%30 = load i32, i32* %9
%31 = add i32 %30, 1
store i32 %31, i32* %9
br label %14
32: ; preds = %14
ret i32 0
}

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