#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*/ InPortb(int);
int /*<<< orphan*/ OutPortb(int, int);
int /*<<< orphan*/ OutPortw(int, char);
void RegisterOut(int Controlador, char index, unsigned char valor) {
  switch (Controlador) {
  case 0x3c0:
    InPortb(0x3da);
    OutPortb(0x3c0, index);
    OutPortb(0x3c0, valor);
    break;
  case 0x3c4:
    if (index == 1) {
      OutPortw(0x3c4, 0x0100);
      OutPortw(0x3c4, valor << 8 | 1);
      OutPortw(0x3c4, 0x0300);
      break;
    };
  case 0x3ce:
  case 0x3d4:
  case 0x3d6:
    OutPortw(Controlador, index | valor << 8);
    break;
  case 0x3c2:
  case 0x3c3:
  default:
    OutPortb(Controlador, valor);
    break;
  }
  InPortb(0x3da);
  OutPortb(0x3c0, 0x20);
}


x86 assembly (clang, -O0):
<RegisterOut>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dl,%al
mov    %sil,%cl
mov    %edi,-0x4(%rbp)
mov    %cl,-0x5(%rbp)
mov    %al,-0x6(%rbp)
mov    -0x4(%rbp),%eax
add    $0xfffffc40,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x16,%eax
ja     1204 <RegisterOut+0xd4>
mov    -0x10(%rbp),%rax
lea    0xe98(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x3da,%edi
call   1050 <InPortb@plt>
movsbl -0x5(%rbp),%esi
mov    $0x3c0,%edi
call   1040 <OutPortb@plt>
movzbl -0x6(%rbp),%esi
mov    $0x3c0,%edi
call   1040 <OutPortb@plt>
jmp    1210 <RegisterOut+0xe0>
movsbl -0x5(%rbp),%eax
cmp    $0x1,%eax
jne    11dd <RegisterOut+0xad>
mov    $0x3c4,%edi
xor    %esi,%esi
call   1030 <OutPortw@plt>
movzbl -0x6(%rbp),%eax
shl    $0x8,%eax
or     $0x1,%eax
mov    $0x3c4,%edi
movsbl %al,%esi
call   1030 <OutPortw@plt>
mov    $0x3c4,%edi
xor    %esi,%esi
call   1030 <OutPortw@plt>
jmp    1210 <RegisterOut+0xe0>
jmp    11e2 <RegisterOut+0xb2>
mov    -0x4(%rbp),%edi
movsbl -0x5(%rbp),%eax
movzbl -0x6(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
movsbl %al,%esi
call   1030 <OutPortw@plt>
jmp    1210 <RegisterOut+0xe0>
jmp    1204 <RegisterOut+0xd4>
mov    -0x4(%rbp),%edi
movzbl -0x6(%rbp),%esi
call   1040 <OutPortb@plt>
mov    $0x3da,%edi
call   1050 <InPortb@plt>
mov    $0x3c0,%edi
mov    $0x20,%esi
call   1040 <OutPortb@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RegisterOut>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebx
lea    -0x3c0(%rdi),%eax
ror    %eax
cmp    $0xb,%eax
ja     115f <RegisterOut+0x2f>
mov    %esi,%ebp
lea    0xeb5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsbl %bpl,%esi
call   1030 <OutPortw@plt>
jmp    1189 <RegisterOut+0x59>
movzbl %bl,%esi
jmp    1184 <RegisterOut+0x54>
mov    $0x3da,%edi
call   1050 <InPortb@plt>
movsbl %bpl,%esi
mov    $0x3c0,%edi
call   1040 <OutPortb@plt>
movzbl %bl,%esi
mov    $0x3c0,%edi
call   1040 <OutPortb@plt>
mov    $0x3da,%edi
call   1050 <InPortb@plt>
mov    $0x3c0,%edi
mov    $0x20,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <OutPortb@plt>
cmp    $0x1,%bpl
jne    1154 <RegisterOut+0x24>
mov    $0x3c4,%edi
xor    %esi,%esi
call   1030 <OutPortw@plt>
mov    $0x3c4,%edi
mov    $0x1,%esi
call   1030 <OutPortw@plt>
mov    $0x3c4,%edi
xor    %esi,%esi
jmp    1158 <RegisterOut+0x28>

LLVM IR (-O0):
define void @RegisterOut(i32 %0, i8 signext %1, i8 zeroext %2) {
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8
store i32 %0, i32* %4
store i8 %1, i8* %5
store i8 %2, i8* %6
%7 = load i32, i32* %4
switch i32 %7, label %41 [
i32 960, label %8
i32 964, label %16
i32 974, label %30
i32 980, label %30
i32 982, label %30
i32 962, label %40
i32 963, label %40
]
8: ; preds = %3
%9 = call i32 @InPortb(i32 986)
%10 = load i8, i8* %5
%11 = sext i8 %10 to i32
%12 = call i32 @OutPortb(i32 960, i32 %11)
%13 = load i8, i8* %6
%14 = zext i8 %13 to i32
%15 = call i32 @OutPortb(i32 960, i32 %14)
br label %46
16: ; preds = %3
%17 = load i8, i8* %5
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %29
20: ; preds = %16
%21 = call i32 @OutPortw(i32 964, i8 signext 0)
%22 = load i8, i8* %6
%23 = zext i8 %22 to i32
%24 = shl i32 %23, 8
%25 = or i32 %24, 1
%26 = trunc i32 %25 to i8
%27 = call i32 @OutPortw(i32 964, i8 signext %26)
%28 = call i32 @OutPortw(i32 964, i8 signext 0)
br label %46
29: ; preds = %16
br label %30
30: ; preds = %3, %3, %3, %29
%31 = load i32, i32* %4
%32 = load i8, i8* %5
%33 = sext i8 %32 to i32
%34 = load i8, i8* %6
%35 = zext i8 %34 to i32
%36 = shl i32 %35, 8
%37 = or i32 %33, %36
%38 = trunc i32 %37 to i8
%39 = call i32 @OutPortw(i32 %31, i8 signext %38)
br label %46
40: ; preds = %3, %3
br label %41
41: ; preds = %3, %40
%42 = load i32, i32* %4
%43 = load i8, i8* %6
%44 = zext i8 %43 to i32
%45 = call i32 @OutPortb(i32 %42, i32 %44)
br label %46
46: ; preds = %41, %30, %20, %8
%47 = call i32 @InPortb(i32 986)
%48 = call i32 @OutPortb(i32 960, i32 32)
ret void
}

LLVM IR (-O2):
define void @RegisterOut(i32 %0, i8 signext %1, i8 zeroext %2) {
%4 = add i32 %0, -960
%5 = tail call i32 @llvm.fshl.i32(i32 %4, i32 %4, i32 31)
switch i32 %5, label %20 [
i32 0, label %6
i32 2, label %12
i32 7, label %18
i32 10, label %18
i32 11, label %18
]
6: ; preds = %3
%7 = tail call i32 @InPortb(i32 986)
%8 = sext i8 %1 to i32
%9 = tail call i32 @OutPortb(i32 960, i32 %8)
%10 = zext i8 %2 to i32
%11 = tail call i32 @OutPortb(i32 960, i32 %10)
br label %23
12: ; preds = %3
%13 = icmp eq i8 %1, 1
br i1 %13, label %14, label %18
14: ; preds = %12
%15 = tail call i32 @OutPortw(i32 964, i8 signext 0)
%16 = tail call i32 @OutPortw(i32 964, i8 signext 1)
%17 = tail call i32 @OutPortw(i32 964, i8 signext 0)
br label %23
18: ; preds = %12, %3, %3, %3
%19 = tail call i32 @OutPortw(i32 %0, i8 signext %1)
br label %23
20: ; preds = %3
%21 = zext i8 %2 to i32
%22 = tail call i32 @OutPortb(i32 %0, i32 %21)
br label %23
23: ; preds = %20, %18, %14, %6
%24 = tail call i32 @InPortb(i32 986)
%25 = tail call i32 @OutPortb(i32 960, i32 32)
ret void
}