#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 */

/* Variables and functions */
int /*<<< orphan*/ DEBUG_ASSERT(int);
unsigned long uDMAChannelAttributeGet(unsigned long ulChannelNum) {
  unsigned long ulAttr = 0;
  DEBUG_ASSERT((ulChannelNum & 0xffff) < 32);
  ulChannelNum &= 0x1f;
  if ((*((volatile unsigned long *)(0x400FF018))) & (1 << ulChannelNum)) {
    ulAttr |= 0x00000001;
  }
  if ((*((volatile unsigned long *)(0x400FF030))) & (1 << ulChannelNum)) {
    ulAttr |= 0x00000002;
  }
  if ((*((volatile unsigned long *)(0x400FF038))) & (1 << ulChannelNum)) {
    ulAttr |= 0x00000004;
  }
  if ((*((volatile unsigned long *)(0x400FF020))) & (1 << ulChannelNum)) {
    ulAttr |= 0x00000008;
  }
  return (ulAttr);
}


x86 assembly (clang, -O0):
<uDMAChannelAttributeGet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
and    $0xffff,%rax
cmp    $0x20,%rax
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x8(%rbp),%rax
and    $0x1f,%rax
mov    %rax,-0x8(%rbp)
mov    $0x400ff018,%eax
mov    (%rax),%rax
mov    -0x8(%rbp),%rcx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
movslq %ecx,%rcx
and    %rcx,%rax
cmp    $0x0,%rax
je     117c <uDMAChannelAttributeGet+0x6c>
mov    -0x10(%rbp),%rax
or     $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    $0x400ff030,%eax
mov    (%rax),%rax
mov    -0x8(%rbp),%rcx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
movslq %ecx,%rcx
and    %rcx,%rax
cmp    $0x0,%rax
je     11ad <uDMAChannelAttributeGet+0x9d>
mov    -0x10(%rbp),%rax
or     $0x2,%rax
mov    %rax,-0x10(%rbp)
mov    $0x400ff038,%eax
mov    (%rax),%rax
mov    -0x8(%rbp),%rcx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
movslq %ecx,%rcx
and    %rcx,%rax
cmp    $0x0,%rax
je     11de <uDMAChannelAttributeGet+0xce>
mov    -0x10(%rbp),%rax
or     $0x4,%rax
mov    %rax,-0x10(%rbp)
mov    $0x400ff020,%eax
mov    (%rax),%rax
mov    -0x8(%rbp),%rcx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
movslq %ecx,%rcx
and    %rcx,%rax
cmp    $0x0,%rax
je     120f <uDMAChannelAttributeGet+0xff>
mov    -0x10(%rbp),%rax
or     $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uDMAChannelAttributeGet>:
push   %rbx
mov    %rdi,%rbx
xor    %edi,%edi
test   $0xffe0,%ebx
sete   %dil
call   1030 <DEBUG_ASSERT@plt>
mov    $0x1,%eax
mov    %ebx,%ecx
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),%rsi
test   %rdx,%rdx
cmove  %rax,%rsi
mov    0x400ff038,%rax
40
and    %rcx,%rax
lea    0x4(%rsi),%rdx
test   %rax,%rax
cmove  %rsi,%rdx
and    0x400ff020,%rcx
40
lea    0x8(%rdx),%rax
test   %rcx,%rcx
cmove  %rdx,%rax
pop    %rbx
ret

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

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