#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 uint32_t;

/* Variables and functions */
void ux00ddr_setuprangeprotection(size_t ahbregaddr, size_t end_addr) {
  (*(volatile uint32_t *)((209 << 2) + (ahbregaddr))) = 0x0;
  size_t end_addr_16Kblocks = ((end_addr >> 14) & 0x7FFFFF) - 1;
  (*(volatile uint32_t *)((210 << 2) + (ahbregaddr))) =
      ((uint32_t)end_addr_16Kblocks);
  (*(volatile uint32_t *)((212 << 2) + (ahbregaddr))) = 0x0;
  (*(volatile uint32_t *)((214 << 2) + (ahbregaddr))) = 0x0;
  (*(volatile uint32_t *)((216 << 2) + (ahbregaddr))) = 0x0;
  (*(volatile uint32_t *)((224 << 2) + (ahbregaddr))) |= (0x3 << 24);
  (*(volatile uint32_t *)((225 << 2) + (ahbregaddr))) = 0xFFFFFFFF;
  (*(volatile uint32_t *)((208 << 2) + (ahbregaddr))) |= (1 << 8);
  (*(volatile uint32_t *)((208 << 2) + (ahbregaddr))) |= (1 << 0);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x344,%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
shr    $0xe,%rax
and    $0x7fffff,%rax
sub    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
add    $0x348,%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x350,%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x358,%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x360,%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x380,%rax
mov    (%rax),%ecx
or     $0x3000000,%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x384,%rax
movl   $0xffffffff,(%rax)
mov    -0x8(%rbp),%rax
add    $0x340,%rax
mov    (%rax),%ecx
or     $0x100,%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x340,%rax
mov    (%rax),%ecx
or     $0x1,%ecx
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
movl   $0x0,0x344(%rdi)
shr    $0xe,%rsi
and    $0x7fffff,%esi
add    $0xffffffff,%esi
mov    %esi,0x348(%rdi)
movl   $0x0,0x350(%rdi)
movl   $0x0,0x358(%rdi)
movl   $0x0,0x360(%rdi)
orl    $0x3000000,0x380(%rdi)
movl   $0xffffffff,0x384(%rdi)
ff ff ff
orl    $0x100,0x340(%rdi)
orl    $0x1,0x340(%rdi)
ret

LLVM IR (-O0):
define void @ux00ddr_setuprangeprotection(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%6 = load i64, i64* %3
%7 = add i64 836, %6
%8 = inttoptr i64 %7 to i32*
store volatile i32 0, i32* %8
%9 = load i64, i64* %4
%10 = lshr i64 %9, 14
%11 = and i64 %10, 8388607
%12 = sub i64 %11, 1
store i64 %12, i64* %5
%13 = load i64, i64* %5
%14 = trunc i64 %13 to i32
%15 = load i64, i64* %3
%16 = add i64 840, %15
%17 = inttoptr i64 %16 to i32*
store volatile i32 %14, i32* %17
%18 = load i64, i64* %3
%19 = add i64 848, %18
%20 = inttoptr i64 %19 to i32*
store volatile i32 0, i32* %20
%21 = load i64, i64* %3
%22 = add i64 856, %21
%23 = inttoptr i64 %22 to i32*
store volatile i32 0, i32* %23
%24 = load i64, i64* %3
%25 = add i64 864, %24
%26 = inttoptr i64 %25 to i32*
store volatile i32 0, i32* %26
%27 = load i64, i64* %3
%28 = add i64 896, %27
%29 = inttoptr i64 %28 to i32*
%30 = load volatile i32, i32* %29
%31 = or i32 %30, 50331648
store volatile i32 %31, i32* %29
%32 = load i64, i64* %3
%33 = add i64 900, %32
%34 = inttoptr i64 %33 to i32*
store volatile i32 -1, i32* %34
%35 = load i64, i64* %3
%36 = add i64 832, %35
%37 = inttoptr i64 %36 to i32*
%38 = load volatile i32, i32* %37
%39 = or i32 %38, 256
store volatile i32 %39, i32* %37
%40 = load i64, i64* %3
%41 = add i64 832, %40
%42 = inttoptr i64 %41 to i32*
%43 = load volatile i32, i32* %42
%44 = or i32 %43, 1
store volatile i32 %44, i32* %42
ret void
}

LLVM IR (-O2):
define void @ux00ddr_setuprangeprotection(i64 %0, i64 %1) {
%3 = add i64 %0, 836
%4 = inttoptr i64 %3 to i32*
store volatile i32 0, i32* %4
%5 = lshr i64 %1, 14
%6 = trunc i64 %5 to i32
%7 = and i32 %6, 8388607
%8 = add nsw i32 %7, -1
%9 = add i64 %0, 840
%10 = inttoptr i64 %9 to i32*
store volatile i32 %8, i32* %10
%11 = add i64 %0, 848
%12 = inttoptr i64 %11 to i32*
store volatile i32 0, i32* %12
%13 = add i64 %0, 856
%14 = inttoptr i64 %13 to i32*
store volatile i32 0, i32* %14
%15 = add i64 %0, 864
%16 = inttoptr i64 %15 to i32*
store volatile i32 0, i32* %16
%17 = add i64 %0, 896
%18 = inttoptr i64 %17 to i32*
%19 = load volatile i32, i32* %18
%20 = or i32 %19, 50331648
store volatile i32 %20, i32* %18
%21 = add i64 %0, 900
%22 = inttoptr i64 %21 to i32*
store volatile i32 -1, i32* %22
%23 = add i64 %0, 832
%24 = inttoptr i64 %23 to i32*
%25 = load volatile i32, i32* %24
%26 = or i32 %25, 256
store volatile i32 %26, i32* %24
%27 = load volatile i32, i32* %24
%28 = or i32 %27, 1
store volatile i32 %28, i32* %24
ret void
}