#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 */
void uDMAChannelAssign(uint32_t ui32Mapping) {
  uint32_t ui32MapReg;
  uint_fast8_t ui8MapShift;
  uint_fast8_t ui8ChannelNum;
  ;
  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
mov    %edi,-0x4(%rbp)
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)
pop    %rbp
ret

x86 assembly (clang, -O2):
<uDMAChannelAssign>:
mov    %edi,%eax
lea    0x0(,%rdi,4),%ecx
mov    %edi,%edx
sar    $0x10,%edx
shr    %eax
and    $0x7c,%eax
mov    $0xf,%esi
shl    %cl,%esi
not    %esi
shl    %cl,%edx
and    0x400ff510(%rax),%esi
or     %esi,%edx
mov    %edx,0x400ff510(%rax)
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, 255
store i32 %7, i32* %5
%8 = load i32, i32* %2
%9 = ashr i32 %8, 16
store i32 %9, i32* %2
%10 = load i32, i32* %5
%11 = sdiv i32 %10, 8
%12 = mul nsw i32 %11, 4
%13 = add nsw i32 1074787600, %12
store i32 %13, i32* %3
%14 = load i32, i32* %5
%15 = srem i32 %14, 8
%16 = mul nsw i32 %15, 4
store i32 %16, i32* %4
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to i32*
%20 = load volatile i32, i32* %19
%21 = load i32, i32* %4
%22 = shl i32 15, %21
%23 = xor i32 %22, -1
%24 = and i32 %20, %23
%25 = load i32, i32* %2
%26 = load i32, i32* %4
%27 = shl i32 %25, %26
%28 = or i32 %24, %27
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = inttoptr i64 %30 to i32*
store volatile i32 %28, i32* %31
ret void
}

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