#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*/ houston_ReadReg(int, unsigned long *, int);
int /*<<< orphan*/ houston_WriteReg(int, unsigned long, int);
void config_tvout_mode(unsigned long tvout_mode) {
  unsigned long cr;
  houston_ReadReg(0x0C, &cr, 2);
  cr |= (0x0008 | 0x0010);
  cr &= ~0x0400;
  if (0x0001 & tvout_mode)
    cr &= ~0x0008;
  if (0x0002 & tvout_mode)
    cr &= ~0x0010;
  if (0x0004 & tvout_mode) {
    cr &= ~(0x0008 | 0x0010);
    cr |= 0x0400;
  }
  houston_WriteReg(0x0C, cr, 2);
}


x86 assembly (clang, -O0):
<config_tvout_mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0xc,%edi
lea    -0x10(%rbp),%rsi
mov    $0x2,%edx
call   1030 <houston_ReadReg@plt>
mov    -0x10(%rbp),%rax
or     $0x18,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
and    $0xfffffffffffffbff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     1177 <config_tvout_mode+0x57>
mov    -0x10(%rbp),%rax
and    $0xfffffffffffffff7,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
and    $0x2,%rax
cmp    $0x0,%rax
je     1195 <config_tvout_mode+0x75>
mov    -0x10(%rbp),%rax
and    $0xffffffffffffffef,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
and    $0x4,%rax
cmp    $0x0,%rax
je     11c1 <config_tvout_mode+0xa1>
mov    -0x10(%rbp),%rax
and    $0xffffffffffffffe7,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
or     $0x400,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    $0xc,%edi
mov    $0x2,%edx
call   1040 <houston_WriteReg@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_tvout_mode>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
mov    $0xc,%edi
mov    $0x2,%edx
call   1030 <houston_ReadReg@plt>
mov    $0xfffffffffffffbe7,%rax
and    0x8(%rsp),%rax
xor    %ecx,%ecx
test   $0x1,%bl
sete   %cl
lea    (%rax,%rcx,8),%rax
add    $0x10,%rax
mov    %rax,%rcx
and    $0xfffffffffffffbef,%rcx
test   $0x2,%bl
cmove  %rax,%rcx
mov    %rcx,%rsi
and    $0xfffffffffffffbe7,%rsi
or     $0x400,%rsi
test   $0x4,%bl
cmove  %rcx,%rsi
mov    %rsi,0x8(%rsp)
mov    $0xc,%edi
mov    $0x2,%edx
call   1040 <houston_WriteReg@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @config_tvout_mode(i64 %0) {
%2 = alloca i64
%3 = alloca i64
store i64 %0, i64* %2
%4 = call i32 @houston_ReadReg(i32 12, i64* %3, i32 2)
%5 = load i64, i64* %3
%6 = or i64 %5, 24
store i64 %6, i64* %3
%7 = load i64, i64* %3
%8 = and i64 %7, -1025
store i64 %8, i64* %3
%9 = load i64, i64* %2
%10 = and i64 1, %9
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = load i64, i64* %3
%14 = and i64 %13, -9
store i64 %14, i64* %3
br label %15
15: ; preds = %12, %1
%16 = load i64, i64* %2
%17 = and i64 2, %16
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i64, i64* %3
%21 = and i64 %20, -17
store i64 %21, i64* %3
br label %22
22: ; preds = %19, %15
%23 = load i64, i64* %2
%24 = and i64 4, %23
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = load i64, i64* %3
%28 = and i64 %27, -25
store i64 %28, i64* %3
%29 = load i64, i64* %3
%30 = or i64 %29, 1024
store i64 %30, i64* %3
br label %31
31: ; preds = %26, %22
%32 = load i64, i64* %3
%33 = call i32 @houston_WriteReg(i32 12, i64 %32, i32 2)
ret void
}

LLVM IR (-O2):
define void @config_tvout_mode(i64 %0) {
%2 = alloca i64
%3 = bitcast i64* %2 to i8*
%4 = call i32 @houston_ReadReg(i32 12, i64* %2, i32 2)
%5 = load i64, i64* %2
%6 = and i64 %5, -1049
%7 = and i64 %0, 1
%8 = icmp eq i64 %7, 0
%9 = select i1 %8, i64 24, i64 16
%10 = or i64 %6, %9
%11 = and i64 %0, 2
%12 = icmp eq i64 %11, 0
%13 = and i64 %10, -1041
%14 = select i1 %12, i64 %10, i64 %13
%15 = and i64 %0, 4
%16 = icmp eq i64 %15, 0
%17 = and i64 %14, -1049
%18 = or i64 %17, 1024
%19 = select i1 %16, i64 %14, i64 %18
store i64 %19, i64* %2
%20 = call i32 @houston_WriteReg(i32 12, i64 %19, i32 2)
ret void
}