int enableA20() {
  unsigned char KBCOutPortReg;
  int timeout;
  ;
  if (testA20()) {
    ;
    return 1;
  }
  if (testA20()) {
    ;
    return 1;
  };
  while (inb(0x64) & 0x2)
    ;
  outb(0x64, 0xAD);
  while (inb(0x64) & 0x2)
    ;
  outb(0x64, 0xD0);
  while (!(inb(0x64) & 0x1))
    ;
  KBCOutPortReg = inb(0x60);
  while (inb(0x64) & 0x2)
    ;
  outb(0x64, 0xD1);
  while (inb(0x64) & 0x2)
    ;
  outb(0x60, KBCOutPortReg | 0x2);
  while (inb(0x64) & 0x2)
    ;
  outb(0x64, 0xAE);
  for (timeout = 0; timeout < 2000; timeout++) {
    if (testA20()) {
      ;
      return 1;
    }
  };
  __asm__ volatile("inb $0x92, %al\n\t"
                   "or $0x2, %al\n\t"
                   "out %al, $0x92");
  if (testA20()) {
    prints("[enableA20()]: A20 enabled via Fast A20 port.");
    return 1;
  }
  prints("[enableA20()]: A20 could not be enabled.\n");
  return 0;
}


x86 assembly (clang, -O0):
<enableA20>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1060 <testA20@plt>
cmp    $0x0,%eax
je     1164 <enableA20+0x24>
movl   $0x1,-0x4(%rbp)
jmp    132d <enableA20+0x1ed>
mov    $0x0,%al
call   1060 <testA20@plt>
cmp    $0x0,%eax
je     1180 <enableA20+0x40>
movl   $0x1,-0x4(%rbp)
jmp    132d <enableA20+0x1ed>
jmp    1185 <enableA20+0x45>
mov    $0x64,%edi
mov    $0x0,%al
call   1040 <inb@plt>
and    $0x2,%eax
cmp    $0x0,%eax
je     11a2 <enableA20+0x62>
jmp    1185 <enableA20+0x45>
mov    $0x64,%edi
mov    $0xad,%esi
mov    $0x0,%al
call   1030 <outb@plt>
mov    $0x64,%edi
mov    $0x0,%al
call   1040 <inb@plt>
and    $0x2,%eax
cmp    $0x0,%eax
je     11d0 <enableA20+0x90>
jmp    11b3 <enableA20+0x73>
mov    $0x64,%edi
mov    $0xd0,%esi
mov    $0x0,%al
call   1030 <outb@plt>
mov    $0x64,%edi
mov    $0x0,%al
call   1040 <inb@plt>
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1205 <enableA20+0xc5>
jmp    120a <enableA20+0xca>
jmp    11e1 <enableA20+0xa1>
mov    $0x60,%edi
mov    $0x0,%al
call   1040 <inb@plt>
mov    %al,-0x5(%rbp)
mov    $0x64,%edi
mov    $0x0,%al
call   1040 <inb@plt>
and    $0x2,%eax
cmp    $0x0,%eax
je     1236 <enableA20+0xf6>
jmp    1219 <enableA20+0xd9>
mov    $0x64,%edi
mov    $0xd1,%esi
mov    $0x0,%al
call   1030 <outb@plt>
mov    $0x64,%edi
mov    $0x0,%al
call   1040 <inb@plt>
and    $0x2,%eax
cmp    $0x0,%eax
je     1264 <enableA20+0x124>
jmp    1247 <enableA20+0x107>
movzbl -0x5(%rbp),%esi
or     $0x2,%esi
mov    $0x60,%edi
mov    $0x0,%al
call   1030 <outb@plt>
mov    $0x64,%edi
mov    $0x0,%al
call   1040 <inb@plt>
and    $0x2,%eax
cmp    $0x0,%eax
je     1294 <enableA20+0x154>
jmp    1277 <enableA20+0x137>
mov    $0x64,%edi
mov    $0xae,%esi
mov    $0x0,%al
call   1030 <outb@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x7d0,-0xc(%rbp)
jge    12e8 <enableA20+0x1a8>
mov    $0x0,%al
call   1060 <testA20@plt>
cmp    $0x0,%eax
je     12d5 <enableA20+0x195>
movl   $0x1,-0x4(%rbp)
jmp    132d <enableA20+0x1ed>
jmp    12da <enableA20+0x19a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    12ac <enableA20+0x16c>
in     $0x92,%al
or     $0x2,%al
out    %al,$0x92
mov    $0x0,%al
call   1060 <testA20@plt>
cmp    $0x0,%eax
je     1318 <enableA20+0x1d8>
lea    0xcfb(%rip),%rdi
mov    $0x0,%al
call   1050 <prints@plt>
movl   $0x1,-0x4(%rbp)
jmp    132d <enableA20+0x1ed>
lea    0xd0f(%rip),%rdi
mov    $0x0,%al
call   1050 <prints@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<enableA20>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <testA20@plt>
mov    $0x1,%ebx
test   %eax,%eax
jne    12bd <enableA20+0x17d>
xor    %eax,%eax
call   1060 <testA20@plt>
test   %eax,%eax
jne    12bd <enableA20+0x17d>
cs nopw 0x0(%rax,%rax,1)
mov    $0x64,%edi
xor    %eax,%eax
call   1040 <inb@plt>
test   $0x2,%al
jne    1170 <enableA20+0x30>
mov    $0x64,%edi
mov    $0xad,%esi
xor    %eax,%eax
call   1030 <outb@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x64,%edi
xor    %eax,%eax
call   1040 <inb@plt>
test   $0x2,%al
jne    11a0 <enableA20+0x60>
mov    $0x64,%edi
mov    $0xd0,%esi
xor    %eax,%eax
call   1030 <outb@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x64,%edi
xor    %eax,%eax
call   1040 <inb@plt>
test   $0x1,%al
je     11d0 <enableA20+0x90>
mov    $0x60,%edi
xor    %eax,%eax
call   1040 <inb@plt>
mov    %eax,%ebp
xchg   %ax,%ax
mov    $0x64,%edi
xor    %eax,%eax
call   1040 <inb@plt>
test   $0x2,%al
jne    11f0 <enableA20+0xb0>
mov    $0x64,%edi
mov    $0xd1,%esi
xor    %eax,%eax
call   1030 <outb@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x64,%edi
xor    %eax,%eax
call   1040 <inb@plt>
test   $0x2,%al
jne    1220 <enableA20+0xe0>
or     $0x2,%ebp
movzbl %bpl,%esi
mov    $0x60,%edi
xor    %eax,%eax
call   1030 <outb@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x64,%edi
xor    %eax,%eax
call   1040 <inb@plt>
test   $0x2,%al
jne    1250 <enableA20+0x110>
mov    $0x64,%edi
mov    $0xae,%esi
xor    %eax,%eax
call   1030 <outb@plt>
mov    $0x7d0,%ebp
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <testA20@plt>
test   %eax,%eax
jne    12bd <enableA20+0x17d>
add    $0xffffffff,%ebp
jne    1280 <enableA20+0x140>
in     $0x92,%al
or     $0x2,%al
out    %al,$0x92
xor    %eax,%eax
call   1060 <testA20@plt>
xor    %ebx,%ebx
test   %eax,%eax
setne  %bl
lea    0xd83(%rip),%rax
lea    0xd4e(%rip),%rdi
cmove  %rax,%rdi
xor    %eax,%eax
call   1050 <prints@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"[enableA20()]: A20 enabled via Fast A20 port.\00"
@.str.1 = [42 x i8] c"[enableA20()]: A20 could not be enabled.\0A\00"
define i32 @enableA20() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = call i32 (...) @testA20()
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %0
store i32 1, i32* %1
br label %77
7: ; preds = %0
%8 = call i32 (...) @testA20()
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %7
store i32 1, i32* %1
br label %77
11: ; preds = %7
br label %12
12: ; preds = %16, %11
%13 = call i32 (i32, ...) bitcast (i32 (...)* @inb to i32 (i32, ...)*)(i32 100)
%14 = and i32 %13, 2
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
br label %12
17: ; preds = %12
%18 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 100, i32 173)
br label %19
19: ; preds = %23, %17
%20 = call i32 (i32, ...) bitcast (i32 (...)* @inb to i32 (i32, ...)*)(i32 100)
%21 = and i32 %20, 2
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19
br label %19
24: ; preds = %19
%25 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 100, i32 208)
br label %26
26: ; preds = %31, %24
%27 = call i32 (i32, ...) bitcast (i32 (...)* @inb to i32 (i32, ...)*)(i32 100)
%28 = and i32 %27, 1
%29 = icmp ne i32 %28, 0
%30 = xor i1 %29, true
br i1 %30, label %31, label %32
31: ; preds = %26
br label %26
32: ; preds = %26
%33 = call i32 (i32, ...) bitcast (i32 (...)* @inb to i32 (i32, ...)*)(i32 96)
%34 = trunc i32 %33 to i8
store i8 %34, i8* %2
br label %35
35: ; preds = %39, %32
%36 = call i32 (i32, ...) bitcast (i32 (...)* @inb to i32 (i32, ...)*)(i32 100)
%37 = and i32 %36, 2
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %35
br label %35
40: ; preds = %35
%41 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 100, i32 209)
br label %42
42: ; preds = %46, %40
%43 = call i32 (i32, ...) bitcast (i32 (...)* @inb to i32 (i32, ...)*)(i32 100)
%44 = and i32 %43, 2
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %42
br label %42
47: ; preds = %42
%48 = load i8, i8* %2
%49 = zext i8 %48 to i32
%50 = or i32 %49, 2
%51 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 96, i32 %50)
br label %52
52: ; preds = %56, %47
%53 = call i32 (i32, ...) bitcast (i32 (...)* @inb to i32 (i32, ...)*)(i32 100)
%54 = and i32 %53, 2
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %52
br label %52
57: ; preds = %52
%58 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 100, i32 174)
store i32 0, i32* %3
br label %59
59: ; preds = %67, %57
%60 = load i32, i32* %3
%61 = icmp slt i32 %60, 2000
br i1 %61, label %62, label %70
62: ; preds = %59
%63 = call i32 (...) @testA20()
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %66
65: ; preds = %62
store i32 1, i32* %1
br label %77
66: ; preds = %62
br label %67
67: ; preds = %66
%68 = load i32, i32* %3
%69 = add nsw i32 %68, 1
store i32 %69, i32* %3
br label %59
70: ; preds = %59
%71 = call i32 (...) @testA20()
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %75
73: ; preds = %70
%74 = call i32 (i8*, ...) bitcast (i32 (...)* @prints to i32 (i8*, ...)*)(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %77
75: ; preds = %70
%76 = call i32 (i8*, ...) bitcast (i32 (...)* @prints to i32 (i8*, ...)*)(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %77
77: ; preds = %75, %73, %65, %10, %6
%78 = load i32, i32* %1
ret i32 %78
}

LLVM IR (-O2):
@.str = [46 x i8] c"[enableA20()]: A20 enabled via Fast A20 port.\00"
@.str.1 = [42 x i8] c"[enableA20()]: A20 could not be enabled.\0A\00"
define i32 @enableA20() {
%1 = tail call i32 (...) @testA20()
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %58
3: ; preds = %0
%4 = tail call i32 (...) @testA20()
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %58
6: ; preds = %3, %6
%7 = tail call i32 (i32, ...) bitcast (i32 (...)* @inb to i32 (i32, ...)*)(i32 100)
%8 = and i32 %7, 2
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %6
10: ; preds = %6
%11 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 100, i32 173)
br label %12
12: ; preds = %12, %10
%13 = tail call i32 (i32, ...) bitcast (i32 (...)* @inb to i32 (i32, ...)*)(i32 100)
%14 = and i32 %13, 2
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %12
16: ; preds = %12
%17 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 100, i32 208)
br label %18
18: ; preds = %18, %16
%19 = tail call i32 (i32, ...) bitcast (i32 (...)* @inb to i32 (i32, ...)*)(i32 100)
%20 = and i32 %19, 1
%21 = icmp eq i32 %20, 0
br i1 %21, label %18, label %22
22: ; preds = %18
%23 = tail call i32 (i32, ...) bitcast (i32 (...)* @inb to i32 (i32, ...)*)(i32 96)
br label %24
24: ; preds = %24, %22
%25 = tail call i32 (i32, ...) bitcast (i32 (...)* @inb to i32 (i32, ...)*)(i32 100)
%26 = and i32 %25, 2
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %24
28: ; preds = %24
%29 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 100, i32 209)
br label %30
30: ; preds = %30, %28
%31 = tail call i32 (i32, ...) bitcast (i32 (...)* @inb to i32 (i32, ...)*)(i32 100)
%32 = and i32 %31, 2
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %30
34: ; preds = %30
%35 = and i32 %23, 253
%36 = or i32 %35, 2
%37 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 96, i32 %36)
br label %38
38: ; preds = %38, %34
%39 = tail call i32 (i32, ...) bitcast (i32 (...)* @inb to i32 (i32, ...)*)(i32 100)
%40 = and i32 %39, 2
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %38
42: ; preds = %38
%43 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 100, i32 174)
br label %47
44: ; preds = %47
%45 = add nuw nsw i32 %48, 1
%46 = icmp eq i32 %45, 2000
br i1 %46, label %51, label %47
47: ; preds = %42, %44
%48 = phi i32 [ 0, %42 ], [ %45, %44 ]
%49 = tail call i32 (...) @testA20()
%50 = icmp eq i32 %49, 0
br i1 %50, label %44, label %58
51: ; preds = %44
tail call void asm sideeffect "inb $$0x92, %al\0A\09or $$0x2, %al\0A\09out %al, $$0x92", "~{dirflag},~{fpsr},~{flags}"()
%52 = tail call i32 (...) @testA20()
%53 = icmp eq i32 %52, 0
%54 = select i1 %53, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0)
%55 = xor i1 %53, true
%56 = zext i1 %55 to i32
%57 = tail call i32 (i8*, ...) bitcast (i32 (...)* @prints to i32 (i8*, ...)*)(i8* %54)
br label %58
58: ; preds = %47, %51, %3, %0
%59 = phi i32 [ 1, %0 ], [ 1, %3 ], [ %56, %51 ], [ 1, %47 ]
ret i32 %59
}