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

/* Variables and functions */
int /*<<< orphan*/ ASSERT(int);
void uDMAChannelAssign(uint32_t ui32Mapping) {
  uint32_t ui32MapReg;
  uint_fast8_t ui8MapShift;
  uint_fast8_t ui8ChannelNum;
  ASSERT((ui32Mapping & 0xffffff00) < 0x00090000);
  ui8ChannelNum = ui32Mapping & 0xff;
  ui32Mapping = ui32Mapping >> 16;
  ui32MapReg = 0x400FF510 + (uint32_t)((ui8ChannelNum / 8) * 4);
  ui8MapShift = (ui8ChannelNum % 8) * 4;
  (*((volatile uint32_t *)(ui32MapReg))) =
      ((*((volatile uint32_t *)(ui32MapReg))) & ~(0xf << ui8MapShift)) |
      ui32Mapping << ui8MapShift;
}


x86 assembly (clang, -O0):
<uDMAChannelAssign>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xffffff00,%eax
cmp    $0x90000,%eax
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
mov    -0x4(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
shl    $0x2,%eax
add    $0x400ff510,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
shl    $0x2,%edx
mov    %edx,-0xc(%rbp)
movslq -0x8(%rbp),%rax
mov    (%rax),%eax
mov    -0xc(%rbp),%ecx
mov    $0xf,%edx
shl    %cl,%edx
mov    %edx,%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    %cl,%eax
mov    -0x14(%rbp),%ecx
or     %eax,%ecx
movslq -0x8(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uDMAChannelAssign>:
push   %rbx
mov    %edi,%ebx
xor    %edi,%edi
cmp    $0x90000,%ebx
setb   %dil
call   1030 <ASSERT@plt>
mov    %ebx,%eax
sar    $0x10,%eax
mov    %ebx,%edx
shr    %edx
and    $0x7c,%edx
shl    $0x2,%ebx
mov    $0xf,%esi
mov    %ebx,%ecx
shl    %cl,%esi
not    %esi
shl    %cl,%eax
and    0x400ff510(%rdx),%esi
or     %esi,%eax
mov    %eax,0x400ff510(%rdx)
pop    %rbx
ret

LLVM IR (-O0):
define void @uDMAChannelAssign(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = and i32 %6, -256
%8 = icmp ult i32 %7, 589824
%9 = zext i1 %8 to i32
%10 = call i32 @ASSERT(i32 %9)
%11 = load i32, i32* %2
%12 = and i32 %11, 255
store i32 %12, i32* %5
%13 = load i32, i32* %2
%14 = ashr i32 %13, 16
store i32 %14, i32* %2
%15 = load i32, i32* %5
%16 = sdiv i32 %15, 8
%17 = mul nsw i32 %16, 4
%18 = add nsw i32 1074787600, %17
store i32 %18, i32* %3
%19 = load i32, i32* %5
%20 = srem i32 %19, 8
%21 = mul nsw i32 %20, 4
store i32 %21, i32* %4
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = inttoptr i64 %23 to i32*
%25 = load volatile i32, i32* %24
%26 = load i32, i32* %4
%27 = shl i32 15, %26
%28 = xor i32 %27, -1
%29 = and i32 %25, %28
%30 = load i32, i32* %2
%31 = load i32, i32* %4
%32 = shl i32 %30, %31
%33 = or i32 %29, %32
%34 = load i32, i32* %3
%35 = sext i32 %34 to i64
%36 = inttoptr i64 %35 to i32*
store volatile i32 %33, i32* %36
ret void
}

LLVM IR (-O2):
define void @uDMAChannelAssign(i32 %0) {
%2 = icmp ult i32 %0, 589824
%3 = zext i1 %2 to i32
%4 = tail call i32 @ASSERT(i32 %3)
%5 = ashr i32 %0, 16
%6 = lshr i32 %0, 1
%7 = and i32 %6, 124
%8 = add nuw nsw i32 %7, 1074787600
%9 = shl i32 %0, 2
%10 = and i32 %9, 28
%11 = zext i32 %8 to i64
%12 = inttoptr i64 %11 to i32*
%13 = load volatile i32, i32* %12
%14 = shl nuw i32 15, %10
%15 = xor i32 %14, -1
%16 = and i32 %13, %15
%17 = shl i32 %5, %10
%18 = or i32 %16, %17
store volatile i32 %18, i32* %12
ret void
}