#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 */
scalar_t__ ReadGx(int);
int /*<<< orphan*/ WriteGx(int, unsigned int);
int PLAL_FinalEnableTVout(unsigned long vga_mode) {
  unsigned int reg;
  reg = (int)ReadGx(0x10024);
  reg |= 0x0400;
  WriteGx(0x10024, reg);
  reg = (int)ReadGx(0x8304);
  reg &= ~0x00c0;
  WriteGx(0x8304, reg);
  reg |= 0x0080;
  WriteGx(0x8304, reg);
  reg = (int)ReadGx(0x10004);
  reg |= (0x0800 | 0x0400 | 0x0080 | 0x0040);
  WriteGx(0x10004, reg);
  return 0;
}


x86 assembly (clang, -O0):
<PLAL_FinalEnableTVout>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x10024,%edi
call   1030 <ReadGx@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0x400,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
mov    $0x10024,%edi
call   1040 <WriteGx@plt>
mov    $0x8304,%edi
call   1030 <ReadGx@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xffffff3f,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
mov    $0x8304,%edi
call   1040 <WriteGx@plt>
mov    -0xc(%rbp),%eax
or     $0x80,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
mov    $0x8304,%edi
call   1040 <WriteGx@plt>
mov    $0x10004,%edi
call   1030 <ReadGx@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0xcc0,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
mov    $0x10004,%edi
call   1040 <WriteGx@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PLAL_FinalEnableTVout>:
push   %rbx
mov    $0x10024,%edi
call   1030 <ReadGx@plt>
or     $0x400,%eax
mov    $0x10024,%edi
mov    %eax,%esi
call   1040 <WriteGx@plt>
mov    $0x8304,%edi
call   1030 <ReadGx@plt>
mov    %rax,%rbx
and    $0xffffff3f,%ebx
mov    $0x8304,%edi
mov    %ebx,%esi
call   1040 <WriteGx@plt>
or     $0x80,%ebx
mov    $0x8304,%edi
mov    %ebx,%esi
call   1040 <WriteGx@plt>
mov    $0x10004,%edi
call   1030 <ReadGx@plt>
or     $0xcc0,%eax
mov    $0x10004,%edi
mov    %eax,%esi
call   1040 <WriteGx@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @PLAL_FinalEnableTVout(i64 %0) {
%2 = alloca i64
%3 = alloca i32
store i64 %0, i64* %2
%4 = call i64 @ReadGx(i32 65572)
%5 = trunc i64 %4 to i32
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = or i32 %6, 1024
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = call i32 @WriteGx(i32 65572, i32 %8)
%10 = call i64 @ReadGx(i32 33540)
%11 = trunc i64 %10 to i32
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = and i32 %12, -193
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = call i32 @WriteGx(i32 33540, i32 %14)
%16 = load i32, i32* %3
%17 = or i32 %16, 128
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = call i32 @WriteGx(i32 33540, i32 %18)
%20 = call i64 @ReadGx(i32 65540)
%21 = trunc i64 %20 to i32
store i32 %21, i32* %3
%22 = load i32, i32* %3
%23 = or i32 %22, 3264
store i32 %23, i32* %3
%24 = load i32, i32* %3
%25 = call i32 @WriteGx(i32 65540, i32 %24)
ret i32 0
}

LLVM IR (-O2):
define i32 @PLAL_FinalEnableTVout(i64 %0) {
%2 = tail call i64 @ReadGx(i32 65572)
%3 = trunc i64 %2 to i32
%4 = or i32 %3, 1024
%5 = tail call i32 @WriteGx(i32 65572, i32 %4)
%6 = tail call i64 @ReadGx(i32 33540)
%7 = trunc i64 %6 to i32
%8 = and i32 %7, -193
%9 = tail call i32 @WriteGx(i32 33540, i32 %8)
%10 = or i32 %8, 128
%11 = tail call i32 @WriteGx(i32 33540, i32 %10)
%12 = tail call i64 @ReadGx(i32 65540)
%13 = trunc i64 %12 to i32
%14 = or i32 %13, 3264
%15 = tail call i32 @WriteGx(i32 65540, i32 %14)
ret i32 0
}