#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 houston_Rev();
int /*<<< orphan*/ houston_WriteReg(int, unsigned long, int);
void config_power(int on) {
  unsigned long reg;
  if (houston_Rev() < 1) {
    if (on) {
      houston_ReadReg(0x0C, &reg, 2);
      reg &= ~(0x0002 | 0x0001);
      houston_WriteReg(0x0C, reg, 2);
      reg |= 0x0001;
      houston_WriteReg(0x0C, reg, 2);
      reg &= ~0x0001;
      houston_WriteReg(0x0C, reg, 2);
    } else {
      houston_ReadReg(0x0C, &reg, 2);
      reg |= 0x0002;
      houston_WriteReg(0x0C, reg, 2);
    }
    return;
  }
  if (on) {
    houston_ReadReg(0x0C, &reg, 2);
    reg &= ~(0x0002 | 0x0001 | 0x0008 | 0x0010);
    houston_WriteReg(0x0C, reg, 2);
    reg |= 0x0001;
    houston_WriteReg(0x0C, reg, 2);
    reg &= ~0x0001;
    houston_WriteReg(0x0C, reg, 2);
    houston_ReadReg(0x34, &reg, 2);
    reg &= ~0x8000;
    houston_WriteReg(0x34, reg, 2);
  } else {
    houston_ReadReg(0x0C, &reg, 2);
    reg |= (0x0002 | 0x0008 | 0x0010);
    houston_WriteReg(0x0C, reg, 2);
    houston_ReadReg(0x34, &reg, 2);
    reg |= 0x8000;
    houston_WriteReg(0x34, reg, 2);
  }
}


x86 assembly (clang, -O0):
<config_power>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1030 <houston_Rev@plt>
cmp    $0x1,%eax
jge    1201 <config_power+0xd1>
cmpl   $0x0,-0x4(%rbp)
je     11ca <config_power+0x9a>
mov    $0xc,%edi
lea    -0x10(%rbp),%rsi
mov    $0x2,%edx
call   1040 <houston_ReadReg@plt>
mov    -0x10(%rbp),%rax
and    $0xfffffffffffffffc,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    $0xc,%edi
mov    $0x2,%edx
call   1050 <houston_WriteReg@plt>
mov    -0x10(%rbp),%rax
or     $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    $0xc,%edi
mov    $0x2,%edx
call   1050 <houston_WriteReg@plt>
mov    -0x10(%rbp),%rax
and    $0xfffffffffffffffe,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    $0xc,%edi
mov    $0x2,%edx
call   1050 <houston_WriteReg@plt>
jmp    11fc <config_power+0xcc>
mov    $0xc,%edi
lea    -0x10(%rbp),%rsi
mov    $0x2,%edx
call   1040 <houston_ReadReg@plt>
mov    -0x10(%rbp),%rax
or     $0x2,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    $0xc,%edi
mov    $0x2,%edx
call   1050 <houston_WriteReg@plt>
jmp    131a <config_power+0x1ea>
cmpl   $0x0,-0x4(%rbp)
je     12b4 <config_power+0x184>
mov    $0xc,%edi
lea    -0x10(%rbp),%rsi
mov    $0x2,%edx
call   1040 <houston_ReadReg@plt>
mov    -0x10(%rbp),%rax
and    $0xffffffffffffffe4,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    $0xc,%edi
mov    $0x2,%edx
call   1050 <houston_WriteReg@plt>
mov    -0x10(%rbp),%rax
or     $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    $0xc,%edi
mov    $0x2,%edx
call   1050 <houston_WriteReg@plt>
mov    -0x10(%rbp),%rax
and    $0xfffffffffffffffe,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    $0xc,%edi
mov    $0x2,%edx
call   1050 <houston_WriteReg@plt>
mov    $0x34,%edi
lea    -0x10(%rbp),%rsi
mov    $0x2,%edx
call   1040 <houston_ReadReg@plt>
mov    -0x10(%rbp),%rax
and    $0xffffffffffff7fff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    $0x34,%edi
mov    $0x2,%edx
call   1050 <houston_WriteReg@plt>
jmp    131a <config_power+0x1ea>
mov    $0xc,%edi
lea    -0x10(%rbp),%rsi
mov    $0x2,%edx
call   1040 <houston_ReadReg@plt>
mov    -0x10(%rbp),%rax
or     $0x1a,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    $0xc,%edi
mov    $0x2,%edx
call   1050 <houston_WriteReg@plt>
mov    $0x34,%edi
lea    -0x10(%rbp),%rsi
mov    $0x2,%edx
call   1040 <houston_ReadReg@plt>
mov    -0x10(%rbp),%rax
or     $0x8000,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    $0x34,%edi
mov    $0x2,%edx
call   1050 <houston_WriteReg@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_power>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <houston_Rev@plt>
mov    %eax,%ebp
mov    %rsp,%rsi
mov    $0xc,%edi
mov    $0x2,%edx
call   1040 <houston_ReadReg@plt>
mov    (%rsp),%rsi
test   %ebp,%ebp
jle    11cc <config_power+0x9c>
test   %ebx,%ebx
je     120c <config_power+0xdc>
and    $0xffffffffffffffe4,%rsi
mov    %rsi,(%rsp)
mov    $0xc,%edi
mov    $0x2,%edx
call   1050 <houston_WriteReg@plt>
mov    (%rsp),%rsi
or     $0x1,%rsi
mov    %rsi,(%rsp)
mov    $0xc,%edi
mov    $0x2,%edx
call   1050 <houston_WriteReg@plt>
mov    (%rsp),%rsi
and    $0xfffffffffffffffe,%rsi
mov    %rsi,(%rsp)
mov    $0xc,%edi
mov    $0x2,%edx
call   1050 <houston_WriteReg@plt>
mov    %rsp,%rsi
mov    $0x34,%edi
mov    $0x2,%edx
call   1040 <houston_ReadReg@plt>
mov    $0xffffffffffff7fff,%rsi
and    (%rsp),%rsi
jmp    123e <config_power+0x10e>
test   %ebx,%ebx
je     1249 <config_power+0x119>
and    $0xfffffffffffffffc,%rsi
mov    %rsi,(%rsp)
mov    $0xc,%edi
mov    $0x2,%edx
call   1050 <houston_WriteReg@plt>
mov    (%rsp),%rsi
or     $0x1,%rsi
mov    %rsi,(%rsp)
mov    $0xc,%edi
mov    $0x2,%edx
call   1050 <houston_WriteReg@plt>
mov    (%rsp),%rsi
and    $0xfffffffffffffffe,%rsi
jmp    124d <config_power+0x11d>
or     $0x1a,%rsi
mov    %rsi,(%rsp)
mov    $0xc,%edi
mov    $0x2,%edx
call   1050 <houston_WriteReg@plt>
mov    %rsp,%rsi
mov    $0x34,%edi
mov    $0x2,%edx
call   1040 <houston_ReadReg@plt>
mov    $0x8000,%esi
or     (%rsp),%rsi
mov    %rsi,(%rsp)
mov    $0x34,%edi
jmp    1256 <config_power+0x126>
or     $0x2,%rsi
mov    %rsi,(%rsp)
mov    $0xc,%edi
mov    $0x2,%edx
call   1050 <houston_WriteReg@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @config_power(i32 %0) {
%2 = alloca i32
%3 = alloca i64
store i32 %0, i32* %2
%4 = call i32 (...) @houston_Rev()
%5 = icmp slt i32 %4, 1
br i1 %5, label %6, label %30
6: ; preds = %1
%7 = load i32, i32* %2
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = call i32 @houston_ReadReg(i32 12, i64* %3, i32 2)
%11 = load i64, i64* %3
%12 = and i64 %11, -4
store i64 %12, i64* %3
%13 = load i64, i64* %3
%14 = call i32 @houston_WriteReg(i32 12, i64 %13, i32 2)
%15 = load i64, i64* %3
%16 = or i64 %15, 1
store i64 %16, i64* %3
%17 = load i64, i64* %3
%18 = call i32 @houston_WriteReg(i32 12, i64 %17, i32 2)
%19 = load i64, i64* %3
%20 = and i64 %19, -2
store i64 %20, i64* %3
%21 = load i64, i64* %3
%22 = call i32 @houston_WriteReg(i32 12, i64 %21, i32 2)
br label %29
23: ; preds = %6
%24 = call i32 @houston_ReadReg(i32 12, i64* %3, i32 2)
%25 = load i64, i64* %3
%26 = or i64 %25, 2
store i64 %26, i64* %3
%27 = load i64, i64* %3
%28 = call i32 @houston_WriteReg(i32 12, i64 %27, i32 2)
br label %29
29: ; preds = %23, %9
br label %63
30: ; preds = %1
%31 = load i32, i32* %2
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %52
33: ; preds = %30
%34 = call i32 @houston_ReadReg(i32 12, i64* %3, i32 2)
%35 = load i64, i64* %3
%36 = and i64 %35, -28
store i64 %36, i64* %3
%37 = load i64, i64* %3
%38 = call i32 @houston_WriteReg(i32 12, i64 %37, i32 2)
%39 = load i64, i64* %3
%40 = or i64 %39, 1
store i64 %40, i64* %3
%41 = load i64, i64* %3
%42 = call i32 @houston_WriteReg(i32 12, i64 %41, i32 2)
%43 = load i64, i64* %3
%44 = and i64 %43, -2
store i64 %44, i64* %3
%45 = load i64, i64* %3
%46 = call i32 @houston_WriteReg(i32 12, i64 %45, i32 2)
%47 = call i32 @houston_ReadReg(i32 52, i64* %3, i32 2)
%48 = load i64, i64* %3
%49 = and i64 %48, -32769
store i64 %49, i64* %3
%50 = load i64, i64* %3
%51 = call i32 @houston_WriteReg(i32 52, i64 %50, i32 2)
br label %63
52: ; preds = %30
%53 = call i32 @houston_ReadReg(i32 12, i64* %3, i32 2)
%54 = load i64, i64* %3
%55 = or i64 %54, 26
store i64 %55, i64* %3
%56 = load i64, i64* %3
%57 = call i32 @houston_WriteReg(i32 12, i64 %56, i32 2)
%58 = call i32 @houston_ReadReg(i32 52, i64* %3, i32 2)
%59 = load i64, i64* %3
%60 = or i64 %59, 32768
store i64 %60, i64* %3
%61 = load i64, i64* %3
%62 = call i32 @houston_WriteReg(i32 52, i64 %61, i32 2)
br label %63
63: ; preds = %29, %52, %33
ret void
}

LLVM IR (-O2):
define void @config_power(i32 %0) {
%2 = alloca i64
%3 = bitcast i64* %2 to i8*
%4 = tail call i32 (...) @houston_Rev()
%5 = icmp slt i32 %4, 1
%6 = icmp eq i32 %0, 0
%7 = call i32 @houston_ReadReg(i32 12, i64* %2, i32 2)
%8 = load i64, i64* %2
br i1 %5, label %9, label %22
9: ; preds = %1
br i1 %6, label %19, label %10
10: ; preds = %9
%11 = and i64 %8, -4
store i64 %11, i64* %2
%12 = call i32 @houston_WriteReg(i32 12, i64 %11, i32 2)
%13 = load i64, i64* %2
%14 = or i64 %13, 1
store i64 %14, i64* %2
%15 = call i32 @houston_WriteReg(i32 12, i64 %14, i32 2)
%16 = load i64, i64* %2
%17 = and i64 %16, -2
store i64 %17, i64* %2
%18 = call i32 @houston_WriteReg(i32 12, i64 %17, i32 2)
br label %43
19: ; preds = %9
%20 = or i64 %8, 2
store i64 %20, i64* %2
%21 = call i32 @houston_WriteReg(i32 12, i64 %20, i32 2)
br label %43
22: ; preds = %1
br i1 %6, label %36, label %23
23: ; preds = %22
%24 = and i64 %8, -28
store i64 %24, i64* %2
%25 = call i32 @houston_WriteReg(i32 12, i64 %24, i32 2)
%26 = load i64, i64* %2
%27 = or i64 %26, 1
store i64 %27, i64* %2
%28 = call i32 @houston_WriteReg(i32 12, i64 %27, i32 2)
%29 = load i64, i64* %2
%30 = and i64 %29, -2
store i64 %30, i64* %2
%31 = call i32 @houston_WriteReg(i32 12, i64 %30, i32 2)
%32 = call i32 @houston_ReadReg(i32 52, i64* %2, i32 2)
%33 = load i64, i64* %2
%34 = and i64 %33, -32769
store i64 %34, i64* %2
%35 = call i32 @houston_WriteReg(i32 52, i64 %34, i32 2)
br label %43
36: ; preds = %22
%37 = or i64 %8, 26
store i64 %37, i64* %2
%38 = call i32 @houston_WriteReg(i32 12, i64 %37, i32 2)
%39 = call i32 @houston_ReadReg(i32 52, i64* %2, i32 2)
%40 = load i64, i64* %2
%41 = or i64 %40, 32768
store i64 %41, i64* %2
%42 = call i32 @houston_WriteReg(i32 52, i64 %41, i32 2)
br label %43
43: ; preds = %23, %36, %10, %19
ret void
}