#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_enable(int i) {
  unsigned int data;
  unsigned int val;
  init();
  if (i == 1) {
    outb_p(0xF0, 0x2E);
    data = inb_p(0x2F);
    outb_p(0x7F & data, 0x2F);
    outb_p(0xF1, 0x2E);
    val = inb_p(0x2F);
    outb_p(0x7F & val, 0x2F);
    printf("Lan 1-2 lanbypass : enable\n");
  } else if (i == 2) {
    outb_p(0xF0, 0x2E);
    data = inb_p(0x2F);
    outb_p(0xBF & data, 0x2F);
    outb_p(0xF1, 0x2E);
    val = inb_p(0x2F);
    outb_p(0xBF & val, 0x2F);
    printf("Lan 3-4 lanbypass : enable\n");
  } else if (i == 3) {
    data = inb_p(0x480 + 0x0E);
    data = data & 0xFE;
    outb_p(data, 0x480 + 0x0E);
    printf("Lan 5-6 lanbypass : enable\n");
  }
}


x86 assembly (clang, -O0):
<lb_gpio_enable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1040 <init@plt>
cmpl   $0x1,-0x4(%rbp)
jne    11c5 <lb_gpio_enable+0x85>
mov    $0xf0,%edi
mov    $0x2e,%esi
call   1050 <outb_p@plt>
mov    $0x2f,%edi
call   1060 <inb_p@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
and    $0x7f,%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,-0xc(%rbp)
mov    -0xc(%rbp),%edi
and    $0x7f,%edi
mov    $0x2f,%esi
call   1050 <outb_p@plt>
lea    0xe45(%rip),%rdi
call   1030 <printf@plt>
jmp    1283 <lb_gpio_enable+0x143>
cmpl   $0x2,-0x4(%rbp)
jne    123e <lb_gpio_enable+0xfe>
mov    $0xf0,%edi
mov    $0x2e,%esi
call   1050 <outb_p@plt>
mov    $0x2f,%edi
call   1060 <inb_p@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
and    $0xbf,%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,-0xc(%rbp)
mov    -0xc(%rbp),%edi
and    $0xbf,%edi
mov    $0x2f,%esi
call   1050 <outb_p@plt>
lea    0xde8(%rip),%rdi
call   1030 <printf@plt>
jmp    127e <lb_gpio_enable+0x13e>
cmpl   $0x3,-0x4(%rbp)
jne    1279 <lb_gpio_enable+0x139>
mov    $0x48e,%edi
call   1060 <inb_p@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xfe,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x48e,%esi
call   1050 <outb_p@plt>
lea    0xdc4(%rip),%rdi
call   1030 <printf@plt>
jmp    127e <lb_gpio_enable+0x13e>
jmp    1283 <lb_gpio_enable+0x143>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lb_gpio_enable>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1040 <init@plt>
cmp    $0x1,%ebx
je     116e <lb_gpio_enable+0x2e>
cmp    $0x3,%ebx
je     11b7 <lb_gpio_enable+0x77>
cmp    $0x2,%ebx
jne    11e6 <lb_gpio_enable+0xa6>
lea    0xeb4(%rip),%r14
mov    $0xbf,%ebp
jmp    117a <lb_gpio_enable+0x3a>
lea    0xec1(%rip),%r14
mov    $0x7f,%ebp
mov    $0xf0,%edi
mov    $0x2e,%esi
call   1050 <outb_p@plt>
mov    $0x2f,%ebx
mov    $0x2f,%edi
call   1060 <inb_p@plt>
and    %ebp,%eax
mov    %eax,%edi
mov    $0x2f,%esi
call   1050 <outb_p@plt>
mov    $0xf1,%edi
mov    $0x2e,%esi
call   1050 <outb_p@plt>
jmp    11c8 <lb_gpio_enable+0x88>
lea    0xe42(%rip),%r14
mov    $0xfe,%ebp
mov    $0x48e,%ebx
mov    %ebx,%edi
call   1060 <inb_p@plt>
and    %eax,%ebp
mov    %ebp,%edi
mov    %ebx,%esi
call   1050 <outb_p@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <puts@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@str = [27 x i8] c"Lan 5-6 lanbypass : enable\00"
@str.3 = [27 x i8] c"Lan 3-4 lanbypass : enable\00"
@str.4 = [27 x i8] c"Lan 1-2 lanbypass : enable\00"
define void @lb_gpio_enable(i32 %0) {
%2 = tail call i32 (...) @init()
switch i32 %0, label %20 [
i32 1, label %4
i32 2, label %3
i32 3, label %12
]
3: ; preds = %1
br label %4
4: ; preds = %1, %3
%5 = phi i32 [ 191, %3 ], [ 127, %1 ]
%6 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @str.3, i64 0, i64 0), %3 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @str.4, i64 0, i64 0), %1 ]
%7 = tail call i32 @outb_p(i32 240, i32 46)
%8 = tail call i32 @inb_p(i32 47)
%9 = and i32 %8, %5
%10 = tail call i32 @outb_p(i32 %9, i32 47)
%11 = tail call i32 @outb_p(i32 241, i32 46)
br label %12
12: ; preds = %4, %1
%13 = phi i32 [ 1166, %1 ], [ 47, %4 ]
%14 = phi i32 [ 254, %1 ], [ %5, %4 ]
%15 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0), %1 ], [ %6, %4 ]
%16 = tail call i32 @inb_p(i32 %13)
%17 = and i32 %16, %14
%18 = tail call i32 @outb_p(i32 %17, i32 %13)
%19 = tail call i32 @puts(i8* dereferenceable(1) %15)
br label %20
20: ; preds = %12, %1
ret void
}