#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 */
unsigned long ReadGx(int);
int /*<<< orphan*/ WriteGx(int, unsigned long);
int PLAL_EnableVga(void) {
  unsigned long reg;
  reg = ReadGx(0x8304);
  reg &= ~0x00c0;
  reg |= 0x0080;
  WriteGx(0x8304, reg);
  reg = ReadGx(0x10024);
  reg &= ~0x0400;
  WriteGx(0x10024, reg);
  reg = ReadGx(0x8308);
  reg &= ~0x0020;
  WriteGx(0x8308, reg);
  reg |= 0x0020;
  WriteGx(0x8308, reg);
  reg = ReadGx(0x10028);
  reg &= ~(1 << 6);
  WriteGx(0x10028, reg);
  return 0;
}


x86 assembly (clang, -O0):
<PLAL_EnableVga>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x8304,%edi
call   1030 <ReadGx@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
and    $0xffffffffffffff3f,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
or     $0x80,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
mov    $0x8304,%edi
call   1040 <WriteGx@plt>
mov    $0x10024,%edi
call   1030 <ReadGx@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
and    $0xfffffffffffffbff,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
mov    $0x10024,%edi
call   1040 <WriteGx@plt>
mov    $0x8308,%edi
call   1030 <ReadGx@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
and    $0xffffffffffffffdf,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
mov    $0x8308,%edi
call   1040 <WriteGx@plt>
mov    -0x8(%rbp),%rax
or     $0x20,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
mov    $0x8308,%edi
call   1040 <WriteGx@plt>
mov    $0x10028,%edi
call   1030 <ReadGx@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
and    $0xffffffffffffffbf,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
mov    $0x10028,%edi
call   1040 <WriteGx@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PLAL_EnableVga>:
push   %rbx
mov    $0x8304,%edi
call   1030 <ReadGx@plt>
and    $0xffffffffffffff3f,%rax
lea    0x80(%rax),%rsi
mov    $0x8304,%edi
call   1040 <WriteGx@plt>
mov    $0x10024,%edi
call   1030 <ReadGx@plt>
and    $0xfffffffffffffbff,%rax
mov    $0x10024,%edi
mov    %rax,%rsi
call   1040 <WriteGx@plt>
mov    $0x8308,%edi
call   1030 <ReadGx@plt>
mov    %rax,%rbx
mov    %rax,%rsi
and    $0xffffffffffffffdf,%rsi
mov    $0x8308,%edi
call   1040 <WriteGx@plt>
or     $0x20,%rbx
mov    $0x8308,%edi
mov    %rbx,%rsi
call   1040 <WriteGx@plt>
mov    $0x10028,%edi
call   1030 <ReadGx@plt>
and    $0xffffffffffffffbf,%rax
mov    $0x10028,%edi
mov    %rax,%rsi
call   1040 <WriteGx@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @PLAL_EnableVga() {
%1 = alloca i64
%2 = call i64 @ReadGx(i32 33540)
store i64 %2, i64* %1
%3 = load i64, i64* %1
%4 = and i64 %3, -193
store i64 %4, i64* %1
%5 = load i64, i64* %1
%6 = or i64 %5, 128
store i64 %6, i64* %1
%7 = load i64, i64* %1
%8 = call i32 @WriteGx(i32 33540, i64 %7)
%9 = call i64 @ReadGx(i32 65572)
store i64 %9, i64* %1
%10 = load i64, i64* %1
%11 = and i64 %10, -1025
store i64 %11, i64* %1
%12 = load i64, i64* %1
%13 = call i32 @WriteGx(i32 65572, i64 %12)
%14 = call i64 @ReadGx(i32 33544)
store i64 %14, i64* %1
%15 = load i64, i64* %1
%16 = and i64 %15, -33
store i64 %16, i64* %1
%17 = load i64, i64* %1
%18 = call i32 @WriteGx(i32 33544, i64 %17)
%19 = load i64, i64* %1
%20 = or i64 %19, 32
store i64 %20, i64* %1
%21 = load i64, i64* %1
%22 = call i32 @WriteGx(i32 33544, i64 %21)
%23 = call i64 @ReadGx(i32 65576)
store i64 %23, i64* %1
%24 = load i64, i64* %1
%25 = and i64 %24, -65
store i64 %25, i64* %1
%26 = load i64, i64* %1
%27 = call i32 @WriteGx(i32 65576, i64 %26)
ret i32 0
}

LLVM IR (-O2):
define i32 @PLAL_EnableVga() {
%1 = tail call i64 @ReadGx(i32 33540)
%2 = and i64 %1, -193
%3 = or i64 %2, 128
%4 = tail call i32 @WriteGx(i32 33540, i64 %3)
%5 = tail call i64 @ReadGx(i32 65572)
%6 = and i64 %5, -1025
%7 = tail call i32 @WriteGx(i32 65572, i64 %6)
%8 = tail call i64 @ReadGx(i32 33544)
%9 = and i64 %8, -33
%10 = tail call i32 @WriteGx(i32 33544, i64 %9)
%11 = or i64 %8, 32
%12 = tail call i32 @WriteGx(i32 33544, i64 %11)
%13 = tail call i64 @ReadGx(i32 65576)
%14 = and i64 %13, -65
%15 = tail call i32 @WriteGx(i32 65576, i64 %14)
ret i32 0
}