#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 */
uint32_t uDMAChannelAttributeGet(uint32_t ui32ChannelNum) {
  uint32_t ui32Attr = 0;
  ;
  ui32ChannelNum &= 0x1f;
  if ((*((volatile unsigned long *)(0x400FF018))) & (1 << ui32ChannelNum)) {
    ui32Attr |= 0x00000001;
  }
  if ((*((volatile unsigned long *)(0x400FF030))) & (1 << ui32ChannelNum)) {
    ui32Attr |= 0x00000002;
  }
  if ((*((volatile unsigned long *)(0x400FF038))) & (1 << ui32ChannelNum)) {
    ui32Attr |= 0x00000004;
  }
  if ((*((volatile unsigned long *)(0x400FF020))) & (1 << ui32ChannelNum)) {
    ui32Attr |= 0x00000008;
  }
  return (ui32Attr);
}


x86 assembly (clang, -O0):
<uDMAChannelAttributeGet>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1f,%eax
mov    %eax,-0x4(%rbp)
mov    $0x400ff018,%eax
mov    (%rax),%rax
mov    -0x4(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
movslq %ecx,%rcx
and    %rcx,%rax
cmp    $0x0,%rax
je     1144 <uDMAChannelAttributeGet+0x44>
mov    -0x8(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x400ff030,%eax
mov    (%rax),%rax
mov    -0x4(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
movslq %ecx,%rcx
and    %rcx,%rax
cmp    $0x0,%rax
je     1171 <uDMAChannelAttributeGet+0x71>
mov    -0x8(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x8(%rbp)
mov    $0x400ff038,%eax
mov    (%rax),%rax
mov    -0x4(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
movslq %ecx,%rcx
and    %rcx,%rax
cmp    $0x0,%rax
je     119e <uDMAChannelAttributeGet+0x9e>
mov    -0x8(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0x8(%rbp)
mov    $0x400ff020,%eax
mov    (%rax),%rax
mov    -0x4(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
movslq %ecx,%rcx
and    %rcx,%rax
cmp    $0x0,%rax
je     11cb <uDMAChannelAttributeGet+0xcb>
mov    -0x8(%rbp),%eax
or     $0x8,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<uDMAChannelAttributeGet>:
mov    %edi,%ecx
mov    $0x1,%eax
shl    %cl,%eax
movslq %eax,%rcx
xor    %eax,%eax
mov    0x400ff018,%rdx
40
and    %rcx,%rdx
setne  %al
mov    0x400ff030,%rdx
40
and    %rcx,%rdx
lea    0x2(%rax),%esi
test   %rdx,%rdx
cmove  %eax,%esi
mov    0x400ff038,%rax
40
and    %rcx,%rax
lea    0x4(%rsi),%edx
test   %rax,%rax
cmove  %esi,%edx
and    0x400ff020,%rcx
40
lea    0x8(%rdx),%eax
test   %rcx,%rcx
cmove  %edx,%eax
ret

LLVM IR (-O0):
define i32 @uDMAChannelAttributeGet(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%4 = load i32, i32* %2
%5 = and i32 %4, 31
store i32 %5, i32* %2
%6 = load volatile i64, i64* inttoptr (i64 1074786328 to i64*)
%7 = load i32, i32* %2
%8 = shl i32 1, %7
%9 = sext i32 %8 to i64
%10 = and i64 %6, %9
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = load i32, i32* %3
%14 = or i32 %13, 1
store i32 %14, i32* %3
br label %15
15: ; preds = %12, %1
%16 = load volatile i64, i64* inttoptr (i64 1074786352 to i64*)
%17 = load i32, i32* %2
%18 = shl i32 1, %17
%19 = sext i32 %18 to i64
%20 = and i64 %16, %19
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %15
%23 = load i32, i32* %3
%24 = or i32 %23, 2
store i32 %24, i32* %3
br label %25
25: ; preds = %22, %15
%26 = load volatile i64, i64* inttoptr (i64 1074786360 to i64*)
%27 = load i32, i32* %2
%28 = shl i32 1, %27
%29 = sext i32 %28 to i64
%30 = and i64 %26, %29
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %25
%33 = load i32, i32* %3
%34 = or i32 %33, 4
store i32 %34, i32* %3
br label %35
35: ; preds = %32, %25
%36 = load volatile i64, i64* inttoptr (i64 1074786336 to i64*)
%37 = load i32, i32* %2
%38 = shl i32 1, %37
%39 = sext i32 %38 to i64
%40 = and i64 %36, %39
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %35
%43 = load i32, i32* %3
%44 = or i32 %43, 8
store i32 %44, i32* %3
br label %45
45: ; preds = %42, %35
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
define i32 @uDMAChannelAttributeGet(i32 %0) {
%2 = and i32 %0, 31
%3 = load volatile i64, i64* inttoptr (i64 1074786328 to i64*)
%4 = shl nuw i32 1, %2
%5 = sext i32 %4 to i64
%6 = and i64 %3, %5
%7 = icmp ne i64 %6, 0
%8 = zext i1 %7 to i32
%9 = load volatile i64, i64* inttoptr (i64 1074786352 to i64*)
%10 = and i64 %9, %5
%11 = icmp eq i64 %10, 0
%12 = or i32 %8, 2
%13 = select i1 %11, i32 %8, i32 %12
%14 = load volatile i64, i64* inttoptr (i64 1074786360 to i64*)
%15 = and i64 %14, %5
%16 = icmp eq i64 %15, 0
%17 = or i32 %13, 4
%18 = select i1 %16, i32 %13, i32 %17
%19 = load volatile i64, i64* inttoptr (i64 1074786336 to i64*)
%20 = and i64 %19, %5
%21 = icmp eq i64 %20, 0
%22 = or i32 %18, 8
%23 = select i1 %21, i32 %18, i32 %22
ret i32 %23
}