#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 uint64_t;
typedef int uint32_t;

/* Variables and functions */
void ux00ddr_start(size_t ahbregaddr, size_t filteraddr, size_t ddrend) {
  uint32_t regdata = (*(volatile uint32_t *)((0 << 2) + (ahbregaddr)));
  regdata |= 0x1;
  (*(volatile uint32_t *)((0 << 2) + (ahbregaddr))) = regdata;
  while (((*(volatile uint32_t *)((132 << 2) + (ahbregaddr))) & (1 << 8)) ==
         0) {
  }
  volatile uint64_t *filterreg = (volatile uint64_t *)filteraddr;
  filterreg[0] = 0x0f00000000000000UL | (ddrend >> 2);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
add    $0x0,%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x8(%rbp),%rax
add    $0x0,%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x210,%rax
mov    (%rax),%eax
and    $0x100,%eax
cmp    $0x0,%eax
jne    1152 <ux00ddr_start+0x52>
jmp    1133 <ux00ddr_start+0x33>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
shr    $0x2,%rax
movabs $0xf00000000000000,%rcx
or     %rcx,%rax
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
orl    $0x1,(%rdi)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
testl  $0x100,0x210(%rdi)
je     1110 <ux00ddr_start+0x10>
shr    $0x2,%rdx
mov    %edx,(%rsi)
ret

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

LLVM IR (-O2):
define void @ux00ddr_start(i64 %0, i64 %1, i64 %2) {
%4 = inttoptr i64 %0 to i32*
%5 = load volatile i32, i32* %4
%6 = or i32 %5, 1
store volatile i32 %6, i32* %4
%7 = add i64 %0, 528
%8 = inttoptr i64 %7 to i32*
br label %9
9: ; preds = %9, %3
%10 = load volatile i32, i32* %8
%11 = and i32 %10, 256
%12 = icmp eq i32 %11, 0
br i1 %12, label %9, label %13
13: ; preds = %9
%14 = inttoptr i64 %1 to i32*
%15 = lshr i64 %2, 2
%16 = trunc i64 %15 to i32
store volatile i32 %16, i32* %14
ret void
}