void irq_remap(void) {
  outb(0x20, 0x10 | 0x01);
  do {
    asm volatile("jmp 1f\n\t"
                 "1:\n\t"
                 "    jmp 2f\n\t"
                 "2:");
  } while (0);
  outb(0xA0, 0x10 | 0x01);
  do {
    asm volatile("jmp 1f\n\t"
                 "1:\n\t"
                 "    jmp 2f\n\t"
                 "2:");
  } while (0);
  outb((0x20 + 1), 0x20);
  do {
    asm volatile("jmp 1f\n\t"
                 "1:\n\t"
                 "    jmp 2f\n\t"
                 "2:");
  } while (0);
  outb((0xA0 + 1), 0x28);
  do {
    asm volatile("jmp 1f\n\t"
                 "1:\n\t"
                 "    jmp 2f\n\t"
                 "2:");
  } while (0);
  outb((0x20 + 1), 0x04);
  do {
    asm volatile("jmp 1f\n\t"
                 "1:\n\t"
                 "    jmp 2f\n\t"
                 "2:");
  } while (0);
  outb((0xA0 + 1), 0x02);
  do {
    asm volatile("jmp 1f\n\t"
                 "1:\n\t"
                 "    jmp 2f\n\t"
                 "2:");
  } while (0);
  outb((0x20 + 1), 0x01);
  do {
    asm volatile("jmp 1f\n\t"
                 "1:\n\t"
                 "    jmp 2f\n\t"
                 "2:");
  } while (0);
  outb((0xA0 + 1), 0x01);
  do {
    asm volatile("jmp 1f\n\t"
                 "1:\n\t"
                 "    jmp 2f\n\t"
                 "2:");
  } while (0);
}


x86 assembly (clang, -O0):
<irq_remap>:
push   %rbp
mov    %rsp,%rbp
mov    $0x20,%edi
mov    $0x11,%esi
mov    $0x0,%al
call   1030 <outb@plt>
jmp    112a <irq_remap+0x1a>
jmp    112f <irq_remap+0x1f>
mov    $0xa0,%edi
mov    $0x11,%esi
mov    $0x0,%al
call   1030 <outb@plt>
jmp    1145 <irq_remap+0x35>
jmp    114a <irq_remap+0x3a>
mov    $0x21,%edi
mov    $0x20,%esi
mov    $0x0,%al
call   1030 <outb@plt>
jmp    1160 <irq_remap+0x50>
jmp    1165 <irq_remap+0x55>
mov    $0xa1,%edi
mov    $0x28,%esi
mov    $0x0,%al
call   1030 <outb@plt>
jmp    117b <irq_remap+0x6b>
jmp    1180 <irq_remap+0x70>
mov    $0x21,%edi
mov    $0x4,%esi
mov    $0x0,%al
call   1030 <outb@plt>
jmp    1196 <irq_remap+0x86>
jmp    119b <irq_remap+0x8b>
mov    $0xa1,%edi
mov    $0x2,%esi
mov    $0x0,%al
call   1030 <outb@plt>
jmp    11b1 <irq_remap+0xa1>
jmp    11b6 <irq_remap+0xa6>
mov    $0x21,%edi
mov    $0x1,%esi
mov    $0x0,%al
call   1030 <outb@plt>
jmp    11cc <irq_remap+0xbc>
jmp    11d1 <irq_remap+0xc1>
mov    $0xa1,%edi
mov    $0x1,%esi
mov    $0x0,%al
call   1030 <outb@plt>
jmp    11e7 <irq_remap+0xd7>
jmp    11ec <irq_remap+0xdc>
pop    %rbp
ret

x86 assembly (clang, -O2):
<irq_remap>:
push   %rax
mov    $0x20,%edi
mov    $0x11,%esi
xor    %eax,%eax
call   1030 <outb@plt>
jmp    1124 <irq_remap+0x14>
jmp    1126 <irq_remap+0x16>
mov    $0xa0,%edi
mov    $0x11,%esi
xor    %eax,%eax
call   1030 <outb@plt>
jmp    1139 <irq_remap+0x29>
jmp    113b <irq_remap+0x2b>
mov    $0x21,%edi
mov    $0x20,%esi
xor    %eax,%eax
call   1030 <outb@plt>
jmp    114e <irq_remap+0x3e>
jmp    1150 <irq_remap+0x40>
mov    $0xa1,%edi
mov    $0x28,%esi
xor    %eax,%eax
call   1030 <outb@plt>
jmp    1163 <irq_remap+0x53>
jmp    1165 <irq_remap+0x55>
mov    $0x21,%edi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <outb@plt>
jmp    1178 <irq_remap+0x68>
jmp    117a <irq_remap+0x6a>
mov    $0xa1,%edi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <outb@plt>
jmp    118d <irq_remap+0x7d>
jmp    118f <irq_remap+0x7f>
mov    $0x21,%edi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <outb@plt>
jmp    11a2 <irq_remap+0x92>
jmp    11a4 <irq_remap+0x94>
mov    $0xa1,%edi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <outb@plt>
jmp    11b7 <irq_remap+0xa7>
jmp    11b9 <irq_remap+0xa9>
pop    %rax
ret

LLVM IR (-O0):
define void @irq_remap() {
%1 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 32, i32 17)
br label %2
2: ; preds = %0
br label %3
3: ; preds = %2
%4 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 160, i32 17)
br label %5
5: ; preds = %3
br label %6
6: ; preds = %5
%7 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 33, i32 32)
br label %8
8: ; preds = %6
br label %9
9: ; preds = %8
%10 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 161, i32 40)
br label %11
11: ; preds = %9
br label %12
12: ; preds = %11
%13 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 33, i32 4)
br label %14
14: ; preds = %12
br label %15
15: ; preds = %14
%16 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 161, i32 2)
br label %17
17: ; preds = %15
br label %18
18: ; preds = %17
%19 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 33, i32 1)
br label %20
20: ; preds = %18
br label %21
21: ; preds = %20
%22 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 161, i32 1)
br label %23
23: ; preds = %21
br label %24
24: ; preds = %23
ret void
}

LLVM IR (-O2):
define void @irq_remap() {
%1 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 32, i32 17)
tail call void asm sideeffect "jmp 1f\0A\091:\0A\09 jmp 2f\0A\092:", "~{dirflag},~{fpsr},~{flags}"()
%2 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 160, i32 17)
tail call void asm sideeffect "jmp 1f\0A\091:\0A\09 jmp 2f\0A\092:", "~{dirflag},~{fpsr},~{flags}"()
%3 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 33, i32 32)
tail call void asm sideeffect "jmp 1f\0A\091:\0A\09 jmp 2f\0A\092:", "~{dirflag},~{fpsr},~{flags}"()
%4 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 161, i32 40)
tail call void asm sideeffect "jmp 1f\0A\091:\0A\09 jmp 2f\0A\092:", "~{dirflag},~{fpsr},~{flags}"()
%5 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 33, i32 4)
tail call void asm sideeffect "jmp 1f\0A\091:\0A\09 jmp 2f\0A\092:", "~{dirflag},~{fpsr},~{flags}"()
%6 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 161, i32 2)
tail call void asm sideeffect "jmp 1f\0A\091:\0A\09 jmp 2f\0A\092:", "~{dirflag},~{fpsr},~{flags}"()
%7 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 33, i32 1)
tail call void asm sideeffect "jmp 1f\0A\091:\0A\09 jmp 2f\0A\092:", "~{dirflag},~{fpsr},~{flags}"()
%8 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 161, i32 1)
tail call void asm sideeffect "jmp 1f\0A\091:\0A\09 jmp 2f\0A\092:", "~{dirflag},~{fpsr},~{flags}"()
ret void
}