#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 uint32_t *)(0x400FF018))) & (1 << ui32ChannelNum)) {
    ui32Attr |= 0x00000001;
  }
  if ((*((volatile uint32_t *)(0x400FF030))) & (1 << ui32ChannelNum)) {
    ui32Attr |= 0x00000002;
  }
  if ((*((volatile uint32_t *)(0x400FF038))) & (1 << ui32ChannelNum)) {
    ui32Attr |= 0x00000004;
  }
  if ((*((volatile uint32_t *)(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),%eax
mov    -0x4(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     113e <uDMAChannelAttributeGet+0x3e>
mov    -0x8(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x400ff030,%eax
mov    (%rax),%eax
mov    -0x4(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1165 <uDMAChannelAttributeGet+0x65>
mov    -0x8(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x8(%rbp)
mov    $0x400ff038,%eax
mov    (%rax),%eax
mov    -0x4(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     118c <uDMAChannelAttributeGet+0x8c>
mov    -0x8(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0x8(%rbp)
mov    $0x400ff020,%eax
mov    (%rax),%eax
mov    -0x4(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     11b3 <uDMAChannelAttributeGet+0xb3>
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    0x400ff018,%eax
mov    %ecx,%edx
and    $0x1f,%dl
shr    %cl,%eax
and    $0x1,%eax
mov    0x400ff030,%ecx
lea    0x2(%rax),%esi
movzbl %dl,%edx
bt     %edx,%ecx
cmovae %eax,%esi
mov    0x400ff038,%eax
lea    0x4(%rsi),%ecx
bt     %edx,%eax
cmovae %esi,%ecx
mov    0x400ff020,%esi
lea    0x8(%rcx),%eax
bt     %edx,%esi
cmovae %ecx,%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 i32, i32* inttoptr (i64 1074786328 to i32*)
%7 = load i32, i32* %2
%8 = shl i32 1, %7
%9 = and i32 %6, %8
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i32, i32* %3
%13 = or i32 %12, 1
store i32 %13, i32* %3
br label %14
14: ; preds = %11, %1
%15 = load volatile i32, i32* inttoptr (i64 1074786352 to i32*)
%16 = load i32, i32* %2
%17 = shl i32 1, %16
%18 = and i32 %15, %17
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = load i32, i32* %3
%22 = or i32 %21, 2
store i32 %22, i32* %3
br label %23
23: ; preds = %20, %14
%24 = load volatile i32, i32* inttoptr (i64 1074786360 to i32*)
%25 = load i32, i32* %2
%26 = shl i32 1, %25
%27 = and i32 %24, %26
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %23
%30 = load i32, i32* %3
%31 = or i32 %30, 4
store i32 %31, i32* %3
br label %32
32: ; preds = %29, %23
%33 = load volatile i32, i32* inttoptr (i64 1074786336 to i32*)
%34 = load i32, i32* %2
%35 = shl i32 1, %34
%36 = and i32 %33, %35
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %32
%39 = load i32, i32* %3
%40 = or i32 %39, 8
store i32 %40, i32* %3
br label %41
41: ; preds = %38, %32
%42 = load i32, i32* %3
ret i32 %42
}

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