#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 int inb_p(int);
int /*<<< orphan*/ init();
int /*<<< orphan*/ outb_p(unsigned int, int);
int /*<<< orphan*/ printf(char *);
void lb_gpio_power(int i) {
  unsigned int b;
  unsigned int data;
  unsigned int val;
  init();
  if (i == 1) {
    outb_p(0xF0, 0x2E);
    data = inb_p(0x2F);
    b = 0x20 | data;
    b = 0xEF & b;
    outb_p(b, 0x2F);
    outb_p(0xF1, 0x2E);
    val = inb_p(0x2F);
    b = 0x20 | val;
    b = 0xEF & b;
    outb_p(b, 0x2F);
    printf("Power on/off lanbypass : enable\n");
  } else {
    outb_p(0xF0, 0x2E);
    data = inb_p(0x2F);
    b = 0x10 | data;
    b = 0xDF & b;
    outb_p(b, 0x2F);
    outb_p(0xF1, 0x2E);
    val = inb_p(0x2F);
    b = 0x10 | val;
    b = 0xDF & b;
    outb_p(b, 0x2F);
    printf("Power on/off lanbypass : disable\n");
  }
}


x86 assembly (clang, -O0):
<lb_gpio_power>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1040 <init@plt>
cmpl   $0x1,-0x4(%rbp)
jne    11e7 <lb_gpio_power+0xa7>
mov    $0xf0,%edi
mov    $0x2e,%esi
call   1050 <outb_p@plt>
mov    $0x2f,%edi
call   1060 <inb_p@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0x20,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xef,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x2f,%esi
call   1050 <outb_p@plt>
mov    $0xf1,%edi
mov    $0x2e,%esi
call   1050 <outb_p@plt>
mov    $0x2f,%edi
call   1060 <inb_p@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
or     $0x20,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xef,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x2f,%esi
call   1050 <outb_p@plt>
lea    0xe23(%rip),%rdi
call   1030 <printf@plt>
jmp    126d <lb_gpio_power+0x12d>
mov    $0xf0,%edi
mov    $0x2e,%esi
call   1050 <outb_p@plt>
mov    $0x2f,%edi
call   1060 <inb_p@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0x10,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xdf,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x2f,%esi
call   1050 <outb_p@plt>
mov    $0xf1,%edi
mov    $0x2e,%esi
call   1050 <outb_p@plt>
mov    $0x2f,%edi
call   1060 <inb_p@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
or     $0x10,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xdf,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x2f,%esi
call   1050 <outb_p@plt>
lea    0xdb9(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lb_gpio_power>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1040 <init@plt>
mov    $0xf0,%edi
mov    $0x2e,%esi
call   1050 <outb_p@plt>
mov    $0x2f,%edi
call   1060 <inb_p@plt>
and    $0xcf,%eax
xor    %ebx,%ebx
cmp    $0x1,%ebp
sete   %bl
lea    0xea7(%rip),%rcx
lea    0xe7f(%rip),%r14
cmove  %rcx,%r14
shl    $0x4,%ebx
lea    (%rax,%rbx,1),%edi
add    $0x10,%edi
mov    $0x2f,%esi
call   1050 <outb_p@plt>
mov    $0xf1,%edi
mov    $0x2e,%esi
call   1050 <outb_p@plt>
mov    $0x2f,%edi
call   1060 <inb_p@plt>
and    $0xcf,%eax
lea    (%rax,%rbx,1),%edi
add    $0x10,%edi
mov    $0x2f,%esi
call   1050 <outb_p@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"Power on/off lanbypass : enable\0A\00"
@.str.1 = [34 x i8] c"Power on/off lanbypass : disable\0A\00"
define void @lb_gpio_power(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = call i32 (...) @init()
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %27
9: ; preds = %1
%10 = call i32 @outb_p(i32 240, i32 46)
%11 = call i32 @inb_p(i32 47)
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = or i32 32, %12
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = and i32 239, %14
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = call i32 @outb_p(i32 %16, i32 47)
%18 = call i32 @outb_p(i32 241, i32 46)
%19 = call i32 @inb_p(i32 47)
store i32 %19, i32* %5
%20 = load i32, i32* %5
%21 = or i32 32, %20
store i32 %21, i32* %3
%22 = load i32, i32* %3
%23 = and i32 239, %22
store i32 %23, i32* %3
%24 = load i32, i32* %3
%25 = call i32 @outb_p(i32 %24, i32 47)
%26 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %45
27: ; preds = %1
%28 = call i32 @outb_p(i32 240, i32 46)
%29 = call i32 @inb_p(i32 47)
store i32 %29, i32* %4
%30 = load i32, i32* %4
%31 = or i32 16, %30
store i32 %31, i32* %3
%32 = load i32, i32* %3
%33 = and i32 223, %32
store i32 %33, i32* %3
%34 = load i32, i32* %3
%35 = call i32 @outb_p(i32 %34, i32 47)
%36 = call i32 @outb_p(i32 241, i32 46)
%37 = call i32 @inb_p(i32 47)
store i32 %37, i32* %5
%38 = load i32, i32* %5
%39 = or i32 16, %38
store i32 %39, i32* %3
%40 = load i32, i32* %3
%41 = and i32 223, %40
store i32 %41, i32* %3
%42 = load i32, i32* %3
%43 = call i32 @outb_p(i32 %42, i32 47)
%44 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %45
45: ; preds = %27, %9
ret void
}

LLVM IR (-O2):
@str = [33 x i8] c"Power on/off lanbypass : disable\00"
@str.2 = [32 x i8] c"Power on/off lanbypass : enable\00"
define void @lb_gpio_power(i32 %0) {
%2 = tail call i32 (...) @init()
%3 = icmp eq i32 %0, 1
%4 = tail call i32 @outb_p(i32 240, i32 46)
%5 = tail call i32 @inb_p(i32 47)
%6 = and i32 %5, 207
%7 = select i1 %3, i32 32, i32 16
%8 = select i1 %3, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @str.2, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0)
%9 = or i32 %6, %7
%10 = tail call i32 @outb_p(i32 %9, i32 47)
%11 = tail call i32 @outb_p(i32 241, i32 46)
%12 = tail call i32 @inb_p(i32 47)
%13 = and i32 %12, 207
%14 = or i32 %13, %7
%15 = tail call i32 @outb_p(i32 %14, i32 47)
%16 = tail call i32 @puts(i8* dereferenceable(1) %8)
ret void
}