#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 unsigned long *)(ui32MapReg))) =
      ((*((volatile unsigned long *)(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),%rax
mov    -0xc(%rbp),%ecx
mov    $0xf,%edx
shl    %cl,%edx
mov    %edx,%ecx
xor    $0xffffffff,%ecx
movslq %ecx,%rcx
and    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    %cl,%eax
mov    -0x18(%rbp),%rcx
cltq
or     %rax,%rcx
movslq -0x8(%rbp),%rax
mov    %rcx,(%rax)
pop    %rbp
ret

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