#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*/ outb(unsigned int, unsigned int);
int /*<<< orphan*/ set_dma_page(unsigned int, unsigned int);
void set_dma_addr(unsigned int dmanr, unsigned int a) {
  set_dma_page(dmanr, a >> 16);
  if (dmanr <= 3) {
    outb(a & 0xff, ((dmanr & 3) << 1) + 0x00);
    outb((a >> 8) & 0xff, ((dmanr & 3) << 1) + 0x00);
  } else {
    outb((a >> 1) & 0xff, ((dmanr & 3) << 2) + 0xC0);
    outb((a >> 9) & 0xff, ((dmanr & 3) << 2) + 0xC0);
  }
}


x86 assembly (clang, -O0):
<set_dma_addr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
shr    $0x10,%esi
call   1030 <set_dma_page@plt>
cmpl   $0x3,-0x4(%rbp)
ja     1182 <set_dma_addr+0x62>
mov    -0x8(%rbp),%edi
and    $0xff,%edi
mov    -0x4(%rbp),%esi
and    $0x3,%esi
shl    $0x1,%esi
add    $0x0,%esi
call   1040 <outb@plt>
mov    -0x8(%rbp),%edi
shr    $0x8,%edi
and    $0xff,%edi
mov    -0x4(%rbp),%esi
and    $0x3,%esi
shl    $0x1,%esi
add    $0x0,%esi
call   1040 <outb@plt>
jmp    11c2 <set_dma_addr+0xa2>
mov    -0x8(%rbp),%edi
shr    $0x1,%edi
and    $0xff,%edi
mov    -0x4(%rbp),%esi
and    $0x3,%esi
shl    $0x2,%esi
add    $0xc0,%esi
call   1040 <outb@plt>
mov    -0x8(%rbp),%edi
shr    $0x9,%edi
and    $0xff,%edi
mov    -0x4(%rbp),%esi
and    $0x3,%esi
shl    $0x2,%esi
add    $0xc0,%esi
call   1040 <outb@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_dma_addr>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
shr    $0x10,%esi
call   1030 <set_dma_page@plt>
cmp    $0x3,%ebx
ja     114b <set_dma_addr+0x2b>
movzbl %bpl,%edi
add    %ebx,%ebx
and    $0x6,%ebx
mov    %ebx,%esi
call   1040 <outb@plt>
mov    $0x8,%ecx
jmp    1168 <set_dma_addr+0x48>
mov    %ebp,%eax
shr    %eax
movzbl %al,%edi
and    $0x3,%ebx
lea    0xc0(,%rbx,4),%ebx
mov    %ebx,%esi
call   1040 <outb@plt>
mov    $0x9,%ecx
shr    %cl,%ebp
movzbl %bpl,%edi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <outb@plt>

LLVM IR (-O0):
define void @set_dma_addr(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = load i32, i32* %4
%7 = lshr i32 %6, 16
%8 = call i32 @set_dma_page(i32 %5, i32 %7)
%9 = load i32, i32* %3
%10 = icmp ule i32 %9, 3
br i1 %10, label %11, label %27
11: ; preds = %2
%12 = load i32, i32* %4
%13 = and i32 %12, 255
%14 = load i32, i32* %3
%15 = and i32 %14, 3
%16 = shl i32 %15, 1
%17 = add i32 %16, 0
%18 = call i32 @outb(i32 %13, i32 %17)
%19 = load i32, i32* %4
%20 = lshr i32 %19, 8
%21 = and i32 %20, 255
%22 = load i32, i32* %3
%23 = and i32 %22, 3
%24 = shl i32 %23, 1
%25 = add i32 %24, 0
%26 = call i32 @outb(i32 %21, i32 %25)
br label %44
27: ; preds = %2
%28 = load i32, i32* %4
%29 = lshr i32 %28, 1
%30 = and i32 %29, 255
%31 = load i32, i32* %3
%32 = and i32 %31, 3
%33 = shl i32 %32, 2
%34 = add i32 %33, 192
%35 = call i32 @outb(i32 %30, i32 %34)
%36 = load i32, i32* %4
%37 = lshr i32 %36, 9
%38 = and i32 %37, 255
%39 = load i32, i32* %3
%40 = and i32 %39, 3
%41 = shl i32 %40, 2
%42 = add i32 %41, 192
%43 = call i32 @outb(i32 %38, i32 %42)
br label %44
44: ; preds = %27, %11
ret void
}

LLVM IR (-O2):
define void @set_dma_addr(i32 %0, i32 %1) {
%3 = lshr i32 %1, 16
%4 = tail call i32 @set_dma_page(i32 %0, i32 %3)
%5 = icmp ult i32 %0, 4
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = and i32 %1, 255
%8 = shl nuw nsw i32 %0, 1
%9 = and i32 %8, 6
%10 = tail call i32 @outb(i32 %7, i32 %9)
br label %18
11: ; preds = %2
%12 = lshr i32 %1, 1
%13 = and i32 %12, 255
%14 = shl i32 %0, 2
%15 = and i32 %14, 12
%16 = or i32 %15, 192
%17 = tail call i32 @outb(i32 %13, i32 %16)
br label %18
18: ; preds = %11, %6
%19 = phi i32 [ 9, %11 ], [ 8, %6 ]
%20 = phi i32 [ %16, %11 ], [ %9, %6 ]
%21 = lshr i32 %1, %19
%22 = and i32 %21, 255
%23 = tail call i32 @outb(i32 %22, i32 %20)
ret void
}