#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(char, int);
void set_dma_page(unsigned int dmanr, char pagenr) {
  switch (dmanr) {
  case 0:
    outb(pagenr, 0x87);
    break;
  case 1:
    outb(pagenr, 0x83);
    break;
  case 2:
    outb(pagenr, 0x81);
    break;
  case 3:
    outb(pagenr, 0x82);
    break;
  case 5:
    outb(pagenr & 0xfe, 0x8B);
    break;
  case 6:
    outb(pagenr & 0xfe, 0x89);
    break;
  case 7:
    outb(pagenr & 0xfe, 0x8A);
    break;
  }
}


x86 assembly (clang, -O0):
<set_dma_page>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x7,%rax
ja     11de <set_dma_page+0xce>
mov    -0x10(%rbp),%rax
lea    0xec3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x87,%esi
movsbl -0x5(%rbp),%edi
call   1030 <outb@plt>
jmp    11de <set_dma_page+0xce>
mov    $0x83,%esi
movsbl -0x5(%rbp),%edi
call   1030 <outb@plt>
jmp    11de <set_dma_page+0xce>
mov    $0x81,%esi
movsbl -0x5(%rbp),%edi
call   1030 <outb@plt>
jmp    11de <set_dma_page+0xce>
mov    $0x82,%esi
movsbl -0x5(%rbp),%edi
call   1030 <outb@plt>
jmp    11de <set_dma_page+0xce>
movsbl -0x5(%rbp),%eax
and    $0xfe,%eax
mov    $0x8b,%esi
movsbl %al,%edi
call   1030 <outb@plt>
jmp    11de <set_dma_page+0xce>
movsbl -0x5(%rbp),%eax
and    $0xfe,%eax
mov    $0x89,%esi
movsbl %al,%edi
call   1030 <outb@plt>
jmp    11de <set_dma_page+0xce>
movsbl -0x5(%rbp),%eax
and    $0xfe,%eax
mov    $0x8a,%esi
movsbl %al,%edi
call   1030 <outb@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_dma_page>:
cmp    $0x7,%edi
ja     115f <set_dma_page+0x4f>
mov    %edi,%eax
lea    0xee2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsbl %sil,%edi
mov    $0x87,%esi
jmp    1030 <outb@plt>
movsbl %sil,%edi
mov    $0x83,%esi
jmp    1030 <outb@plt>
movsbl %sil,%edi
mov    $0x81,%esi
jmp    1030 <outb@plt>
movsbl %sil,%edi
mov    $0x82,%esi
jmp    1030 <outb@plt>
ret
and    $0xfe,%sil
movsbl %sil,%edi
mov    $0x89,%esi
jmp    1030 <outb@plt>
and    $0xfe,%sil
movsbl %sil,%edi
mov    $0x8a,%esi
jmp    1030 <outb@plt>
and    $0xfe,%sil
movsbl %sil,%edi
mov    $0x8b,%esi
jmp    1030 <outb@plt>

LLVM IR (-O0):
define void @set_dma_page(i32 %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8
store i32 %0, i32* %3
store i8 %1, i8* %4
%5 = load i32, i32* %3
switch i32 %5, label %36 [
i32 0, label %6
i32 1, label %9
i32 2, label %12
i32 3, label %15
i32 5, label %18
i32 6, label %24
i32 7, label %30
]
6: ; preds = %2
%7 = load i8, i8* %4
%8 = call i32 @outb(i8 signext %7, i32 135)
br label %36
9: ; preds = %2
%10 = load i8, i8* %4
%11 = call i32 @outb(i8 signext %10, i32 131)
br label %36
12: ; preds = %2
%13 = load i8, i8* %4
%14 = call i32 @outb(i8 signext %13, i32 129)
br label %36
15: ; preds = %2
%16 = load i8, i8* %4
%17 = call i32 @outb(i8 signext %16, i32 130)
br label %36
18: ; preds = %2
%19 = load i8, i8* %4
%20 = sext i8 %19 to i32
%21 = and i32 %20, 254
%22 = trunc i32 %21 to i8
%23 = call i32 @outb(i8 signext %22, i32 139)
br label %36
24: ; preds = %2
%25 = load i8, i8* %4
%26 = sext i8 %25 to i32
%27 = and i32 %26, 254
%28 = trunc i32 %27 to i8
%29 = call i32 @outb(i8 signext %28, i32 137)
br label %36
30: ; preds = %2
%31 = load i8, i8* %4
%32 = sext i8 %31 to i32
%33 = and i32 %32, 254
%34 = trunc i32 %33 to i8
%35 = call i32 @outb(i8 signext %34, i32 138)
br label %36
36: ; preds = %2, %30, %24, %18, %15, %12, %9, %6
ret void
}

LLVM IR (-O2):
define void @set_dma_page(i32 %0, i8 signext %1) {
switch i32 %0, label %20 [
i32 0, label %3
i32 1, label %5
i32 2, label %7
i32 3, label %9
i32 5, label %11
i32 6, label %14
i32 7, label %17
]
3: ; preds = %2
%4 = tail call i32 @outb(i8 signext %1, i32 135)
br label %20
5: ; preds = %2
%6 = tail call i32 @outb(i8 signext %1, i32 131)
br label %20
7: ; preds = %2
%8 = tail call i32 @outb(i8 signext %1, i32 129)
br label %20
9: ; preds = %2
%10 = tail call i32 @outb(i8 signext %1, i32 130)
br label %20
11: ; preds = %2
%12 = and i8 %1, -2
%13 = tail call i32 @outb(i8 signext %12, i32 139)
br label %20
14: ; preds = %2
%15 = and i8 %1, -2
%16 = tail call i32 @outb(i8 signext %15, i32 137)
br label %20
17: ; preds = %2
%18 = and i8 %1, -2
%19 = tail call i32 @outb(i8 signext %18, i32 138)
br label %20
20: ; preds = %2, %17, %14, %11, %9, %7, %5, %3
ret void
}