#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 /*<<< orphan*/ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ phy_reset(int /*<<< orphan*/ volatile *,
                             int /*<<< orphan*/ const *);
void ux00ddr_writeregmap(size_t ahbregaddr, const uint32_t *ctlsettings,
                         const uint32_t *physettings) {
  volatile uint32_t *ddrctlreg = (volatile uint32_t *)ahbregaddr;
  volatile uint32_t *ddrphyreg =
      ((volatile uint32_t *)ahbregaddr) + (0x2000 / sizeof(uint32_t));
  unsigned int i;
  for (i = 0; i <= 264; i++) {
    uint32_t ctlset = ctlsettings[i];
    ddrctlreg[i] = ctlset;
  }
  phy_reset(ddrphyreg, physettings);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
add    $0x2000,%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x108,-0x2c(%rbp)
ja     1176 <ux00ddr_writeregmap+0x66>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%edx
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1141 <ux00ddr_writeregmap+0x31>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <phy_reset@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
mov    $0x4,%eax
cs nopw 0x0(%rax,%rax,1)
nop
mov    -0x10(%rsi,%rax,4),%ecx
mov    %ecx,-0x10(%rdi,%rax,4)
mov    -0xc(%rsi,%rax,4),%ecx
mov    %ecx,-0xc(%rdi,%rax,4)
mov    -0x8(%rsi,%rax,4),%ecx
mov    %ecx,-0x8(%rdi,%rax,4)
mov    -0x4(%rsi,%rax,4),%ecx
mov    %ecx,-0x4(%rdi,%rax,4)
mov    (%rsi,%rax,4),%ecx
mov    %ecx,(%rdi,%rax,4)
add    $0x5,%rax
cmp    $0x10d,%rax
jne    1120 <ux00ddr_writeregmap+0x10>
add    $0x2000,%rdi
mov    %rdx,%rsi
jmp    1030 <phy_reset@plt>

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

LLVM IR (-O2):
define void @ux00ddr_writeregmap(i64 %0, i32* nocapture %1, i32* %2) {
%4 = inttoptr i64 %0 to i32*
br label %5
5: ; preds = %5, %3
%6 = phi i64 [ 0, %3 ], [ %26, %5 ]
%7 = getelementptr inbounds i32, i32* %1, i64 %6
%8 = load i32, i32* %7
%9 = getelementptr inbounds i32, i32* %4, i64 %6
store volatile i32 %8, i32* %9
%10 = add nuw nsw i64 %6, 1
%11 = getelementptr inbounds i32, i32* %1, i64 %10
%12 = load i32, i32* %11
%13 = getelementptr inbounds i32, i32* %4, i64 %10
store volatile i32 %12, i32* %13
%14 = add nuw nsw i64 %6, 2
%15 = getelementptr inbounds i32, i32* %1, i64 %14
%16 = load i32, i32* %15
%17 = getelementptr inbounds i32, i32* %4, i64 %14
store volatile i32 %16, i32* %17
%18 = add nuw nsw i64 %6, 3
%19 = getelementptr inbounds i32, i32* %1, i64 %18
%20 = load i32, i32* %19
%21 = getelementptr inbounds i32, i32* %4, i64 %18
store volatile i32 %20, i32* %21
%22 = add nuw nsw i64 %6, 4
%23 = getelementptr inbounds i32, i32* %1, i64 %22
%24 = load i32, i32* %23
%25 = getelementptr inbounds i32, i32* %4, i64 %22
store volatile i32 %24, i32* %25
%26 = add nuw nsw i64 %6, 5
%27 = icmp eq i64 %26, 265
br i1 %27, label %28, label %5
28: ; preds = %5
%29 = getelementptr inbounds i32, i32* %4, i64 2048
%30 = tail call i32 @phy_reset(i32* %29, i32* %2)
ret void
}