#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*/ DEBUG_ASSERT(int);
void uDMAChannelAssign(unsigned long ulMapping) {
  unsigned long ulMapReg;
  unsigned long ulMapShift;
  unsigned long ulChannelNum;
  DEBUG_ASSERT((ulMapping & 0xffffff00) < 0x00050000);
  DEBUG_ASSERT(!((((*((volatile unsigned long *)(0x400FE000))) & 0x70000000) ==
                  0x00000000) ||
                 (((*((volatile unsigned long *)(0x400FE000))) &
                   (0x70000000 | 0x00FF0000)) == (0x10000000 | 0x00000000))));
  DEBUG_ASSERT(!(((*((volatile unsigned long *)(0x400FE000))) &
                  (0x70000000 | 0x00FF0000)) == (0x10000000 | 0x00010000)));
  DEBUG_ASSERT(!(((*((volatile unsigned long *)(0x400FE000))) &
                  (0x70000000 | 0x00FF0000)) == (0x10000000 | 0x00030000)));
  DEBUG_ASSERT(!(((*((volatile unsigned long *)(0x400FE000))) &
                  (0x70000000 | 0x00FF0000)) == (0x10000000 | 0x00040000)));
  DEBUG_ASSERT(!(((*((volatile unsigned long *)(0x400FE000))) &
                  (0x70000000 | 0x00FF0000)) == (0x10000000 | 0x00060000)));
  ulChannelNum = ulMapping & 0xff;
  ulMapping = ulMapping >> 16;
  ulMapReg = 0x400FF510 + ((ulChannelNum / 8) * 4);
  ulMapShift = (ulChannelNum % 8) * 4;
  (*((volatile unsigned long *)(ulMapReg))) =
      ((*((volatile unsigned long *)(ulMapReg))) & ~(0xf << ulMapShift)) |
      ulMapping << ulMapShift;
}


x86 assembly (clang, -O0):
<uDMAChannelAssign>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movabs $0xffffff00,%rax
and    -0x8(%rbp),%rax
cmp    $0x50000,%rax
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    $0x400fe000,%eax
mov    (%rax),%rcx
and    $0x70000000,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x21(%rbp)
je     1175 <uDMAChannelAssign+0x65>
mov    $0x400fe000,%eax
mov    (%rax),%rax
and    $0x70ff0000,%rax
cmp    $0x10000000,%rax
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    $0x400fe000,%eax
mov    (%rax),%rax
and    $0x70ff0000,%rax
cmp    $0x10010000,%rax
sete   %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    $0x400fe000,%eax
mov    (%rax),%rax
and    $0x70ff0000,%rax
cmp    $0x10030000,%rax
sete   %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    $0x400fe000,%eax
mov    (%rax),%rax
and    $0x70ff0000,%rax
cmp    $0x10040000,%rax
sete   %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    $0x400fe000,%eax
mov    (%rax),%rax
and    $0x70ff0000,%rax
cmp    $0x10060000,%rax
sete   %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x8(%rbp),%rax
and    $0xff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
shr    $0x10,%rax
mov    %rax,-0x8(%rbp)
mov    -0x20(%rbp),%rax
shr    $0x3,%rax
shl    $0x2,%rax
add    $0x400ff510,%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rax
and    $0x7,%rax
shl    $0x2,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
mov    $0xf,%edx
shl    %cl,%edx
mov    %edx,%ecx
xor    $0xffffffff,%ecx
movslq %ecx,%rcx
and    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    %cl,%rax
mov    -0x30(%rbp),%rcx
or     %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uDMAChannelAssign>:
push   %rbx
mov    %rdi,%rbx
mov    %ebx,%eax
and    $0xffff0000,%eax
xor    %edi,%edi
cmp    $0x50000,%eax
setb   %dil
call   1030 <DEBUG_ASSERT@plt>
testq  $0x70000000,0x400fe000
je     1153 <uDMAChannelAssign+0x43>
mov    0x400fe000,%rax
40
and    $0x70ff0000,%eax
xor    %edi,%edi
cmp    $0x10000000,%eax
setne  %dil
jmp    1155 <uDMAChannelAssign+0x45>
xor    %edi,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    0x400fe000,%rax
40
and    $0x70ff0000,%eax
xor    %edi,%edi
cmp    $0x10010000,%eax
setne  %dil
call   1030 <DEBUG_ASSERT@plt>
mov    0x400fe000,%rax
40
and    $0x70ff0000,%eax
xor    %edi,%edi
cmp    $0x10030000,%eax
setne  %dil
call   1030 <DEBUG_ASSERT@plt>
mov    0x400fe000,%rax
40
and    $0x70ff0000,%eax
xor    %edi,%edi
cmp    $0x10040000,%eax
setne  %dil
call   1030 <DEBUG_ASSERT@plt>
mov    0x400fe000,%rax
40
and    $0x70ff0000,%eax
xor    %edi,%edi
cmp    $0x10060000,%eax
setne  %dil
call   1030 <DEBUG_ASSERT@plt>
mov    %rbx,%rax
shr    $0x10,%rax
mov    %rbx,%rdx
shl    $0x2,%ebx
mov    $0xf,%esi
mov    %ebx,%ecx
shl    %cl,%esi
shr    %rdx
and    $0x7c,%edx
and    $0x1c,%bl
not    %esi
movslq %esi,%rsi
mov    %ebx,%ecx
shl    %cl,%rax
and    0x400ff510(%rdx),%rsi
or     %rsi,%rax
mov    %rax,0x400ff510(%rdx)
pop    %rbx
ret

LLVM IR (-O0):
define void @uDMAChannelAssign(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i64 %0, i64* %2
%6 = load i64, i64* %2
%7 = and i64 %6, 4294967040
%8 = icmp ult i64 %7, 327680
%9 = zext i1 %8 to i32
%10 = call i32 @DEBUG_ASSERT(i32 %9)
%11 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%12 = and i64 %11, 1879048192
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %1
%15 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%16 = and i64 %15, 1895759872
%17 = icmp eq i64 %16, 268435456
br label %18
18: ; preds = %14, %1
%19 = phi i1 [ true, %1 ], [ %17, %14 ]
%20 = xor i1 %19, true
%21 = zext i1 %20 to i32
%22 = call i32 @DEBUG_ASSERT(i32 %21)
%23 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%24 = and i64 %23, 1895759872
%25 = icmp eq i64 %24, 268500992
%26 = xor i1 %25, true
%27 = zext i1 %26 to i32
%28 = call i32 @DEBUG_ASSERT(i32 %27)
%29 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%30 = and i64 %29, 1895759872
%31 = icmp eq i64 %30, 268632064
%32 = xor i1 %31, true
%33 = zext i1 %32 to i32
%34 = call i32 @DEBUG_ASSERT(i32 %33)
%35 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%36 = and i64 %35, 1895759872
%37 = icmp eq i64 %36, 268697600
%38 = xor i1 %37, true
%39 = zext i1 %38 to i32
%40 = call i32 @DEBUG_ASSERT(i32 %39)
%41 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%42 = and i64 %41, 1895759872
%43 = icmp eq i64 %42, 268828672
%44 = xor i1 %43, true
%45 = zext i1 %44 to i32
%46 = call i32 @DEBUG_ASSERT(i32 %45)
%47 = load i64, i64* %2
%48 = and i64 %47, 255
store i64 %48, i64* %5
%49 = load i64, i64* %2
%50 = lshr i64 %49, 16
store i64 %50, i64* %2
%51 = load i64, i64* %5
%52 = udiv i64 %51, 8
%53 = mul i64 %52, 4
%54 = add i64 1074787600, %53
store i64 %54, i64* %3
%55 = load i64, i64* %5
%56 = urem i64 %55, 8
%57 = mul i64 %56, 4
store i64 %57, i64* %4
%58 = load i64, i64* %3
%59 = inttoptr i64 %58 to i64*
%60 = load volatile i64, i64* %59
%61 = load i64, i64* %4
%62 = trunc i64 %61 to i32
%63 = shl i32 15, %62
%64 = xor i32 %63, -1
%65 = sext i32 %64 to i64
%66 = and i64 %60, %65
%67 = load i64, i64* %2
%68 = load i64, i64* %4
%69 = shl i64 %67, %68
%70 = or i64 %66, %69
%71 = load i64, i64* %3
%72 = inttoptr i64 %71 to i64*
store volatile i64 %70, i64* %72
ret void
}

LLVM IR (-O2):
define void @uDMAChannelAssign(i64 %0) {
%2 = and i64 %0, 4294901760
%3 = icmp ult i64 %2, 327680
%4 = zext i1 %3 to i32
%5 = tail call i32 @DEBUG_ASSERT(i32 %4)
%6 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%7 = and i64 %6, 1879048192
%8 = icmp eq i64 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %1
%10 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%11 = and i64 %10, 1895759872
%12 = icmp ne i64 %11, 268435456
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %9, %1
%15 = phi i32 [ 0, %1 ], [ %13, %9 ]
%16 = tail call i32 @DEBUG_ASSERT(i32 %15)
%17 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%18 = and i64 %17, 1895759872
%19 = icmp ne i64 %18, 268500992
%20 = zext i1 %19 to i32
%21 = tail call i32 @DEBUG_ASSERT(i32 %20)
%22 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%23 = and i64 %22, 1895759872
%24 = icmp ne i64 %23, 268632064
%25 = zext i1 %24 to i32
%26 = tail call i32 @DEBUG_ASSERT(i32 %25)
%27 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%28 = and i64 %27, 1895759872
%29 = icmp ne i64 %28, 268697600
%30 = zext i1 %29 to i32
%31 = tail call i32 @DEBUG_ASSERT(i32 %30)
%32 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%33 = and i64 %32, 1895759872
%34 = icmp ne i64 %33, 268828672
%35 = zext i1 %34 to i32
%36 = tail call i32 @DEBUG_ASSERT(i32 %35)
%37 = lshr i64 %0, 16
%38 = lshr i64 %0, 1
%39 = and i64 %38, 124
%40 = add nuw nsw i64 %39, 1074787600
%41 = shl i64 %0, 2
%42 = and i64 %41, 28
%43 = inttoptr i64 %40 to i64*
%44 = load volatile i64, i64* %43
%45 = trunc i64 %42 to i32
%46 = shl nuw i32 15, %45
%47 = xor i32 %46, -1
%48 = sext i32 %47 to i64
%49 = and i64 %44, %48
%50 = shl i64 %37, %42
%51 = or i64 %49, %50
store volatile i64 %51, i64* %43
ret void
}