#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 */
int /*<<< orphan*/ ASSERT(int);
uint32_t uDMAChannelAttributeGet(uint32_t ui32ChannelNum) {
  uint32_t ui32Attr = 0;
  ASSERT((ui32ChannelNum & 0xffff) < 32);
  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
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0xffff,%eax
cmp    $0x20,%eax
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
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     116a <uDMAChannelAttributeGet+0x5a>
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     1191 <uDMAChannelAttributeGet+0x81>
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     11b8 <uDMAChannelAttributeGet+0xa8>
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     11df <uDMAChannelAttributeGet+0xcf>
mov    -0x8(%rbp),%eax
or     $0x8,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uDMAChannelAttributeGet>:
push   %rbx
mov    %edi,%ebx
xor    %edi,%edi
test   $0xffe0,%ebx
sete   %dil
call   1030 <ASSERT@plt>
mov    0x400ff018,%eax
mov    %ebx,%edx
and    $0x1f,%dl
mov    %ebx,%ecx
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
pop    %rbx
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, 65535
%6 = icmp slt i32 %5, 32
%7 = zext i1 %6 to i32
%8 = call i32 @ASSERT(i32 %7)
%9 = load i32, i32* %2
%10 = and i32 %9, 31
store i32 %10, i32* %2
%11 = load volatile i32, i32* inttoptr (i64 1074786328 to i32*)
%12 = load i32, i32* %2
%13 = shl i32 1, %12
%14 = and i32 %11, %13
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %1
%17 = load i32, i32* %3
%18 = or i32 %17, 1
store i32 %18, i32* %3
br label %19
19: ; preds = %16, %1
%20 = load volatile i32, i32* inttoptr (i64 1074786352 to i32*)
%21 = load i32, i32* %2
%22 = shl i32 1, %21
%23 = and i32 %20, %22
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %19
%26 = load i32, i32* %3
%27 = or i32 %26, 2
store i32 %27, i32* %3
br label %28
28: ; preds = %25, %19
%29 = load volatile i32, i32* inttoptr (i64 1074786360 to i32*)
%30 = load i32, i32* %2
%31 = shl i32 1, %30
%32 = and i32 %29, %31
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %28
%35 = load i32, i32* %3
%36 = or i32 %35, 4
store i32 %36, i32* %3
br label %37
37: ; preds = %34, %28
%38 = load volatile i32, i32* inttoptr (i64 1074786336 to i32*)
%39 = load i32, i32* %2
%40 = shl i32 1, %39
%41 = and i32 %38, %40
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %37
%44 = load i32, i32* %3
%45 = or i32 %44, 8
store i32 %45, i32* %3
br label %46
46: ; preds = %43, %37
%47 = load i32, i32* %3
ret i32 %47
}

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