#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 */
typedef int uint8_t;

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ vdp_control_port_write(int);
int /*<<< orphan*/ vdp_data_port_write(int);
void io_port_write(uint8_t port, uint8_t data) {
  switch (port) {
  case 0xBE:
    vdp_data_port_write(data);
    break;
  case 0xBF:
    vdp_control_port_write(data);
    break;
  case 0x7E:
    break;
  case 0x7F:
    break;
  default:
    fprintf(stderr, "Attempted to write to unknown port 0x%hhX\n", port);
    abort();
  }
}


x86 assembly (clang, -O0):
<io_port_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x7e,%eax
je     11b3 <io_port_write+0x73>
jmp    1162 <io_port_write+0x22>
mov    -0xc(%rbp),%eax
sub    $0x7f,%eax
je     11b8 <io_port_write+0x78>
jmp    1173 <io_port_write+0x33>
mov    -0xc(%rbp),%eax
sub    $0xbe,%eax
je     1199 <io_port_write+0x59>
jmp    1186 <io_port_write+0x46>
mov    -0xc(%rbp),%eax
sub    $0xbf,%eax
je     11a6 <io_port_write+0x66>
jmp    11bd <io_port_write+0x7d>
mov    -0x8(%rbp),%edi
call   1060 <vdp_data_port_write@plt>
jmp    11dc <io_port_write+0x9c>
mov    -0x8(%rbp),%edi
call   1040 <vdp_control_port_write@plt>
jmp    11dc <io_port_write+0x9c>
jmp    11dc <io_port_write+0x9c>
jmp    11dc <io_port_write+0x9c>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xe30(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<io_port_write>:
mov    %edi,%edx
lea    -0x7e(%rdx),%eax
cmp    $0x2,%eax
jb     1161 <io_port_write+0x21>
cmp    $0xbf,%edx
je     1162 <io_port_write+0x22>
cmp    $0xbe,%edx
jne    1169 <io_port_write+0x29>
mov    %esi,%edi
jmp    1060 <vdp_data_port_write@plt>
ret
mov    %esi,%edi
jmp    1040 <vdp_control_port_write@plt>
push   %rax
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
lea    0xe86(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [43 x i8] c"Attempted to write to unknown port 0x%hhX\0A\00"
define void @io_port_write(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
switch i32 %5, label %14 [
i32 190, label %6
i32 191, label %9
i32 126, label %12
i32 127, label %13
]
6: ; preds = %2
%7 = load i32, i32* %4
%8 = call i32 @vdp_data_port_write(i32 %7)
br label %19
9: ; preds = %2
%10 = load i32, i32* %4
%11 = call i32 @vdp_control_port_write(i32 %10)
br label %19
12: ; preds = %2
br label %19
13: ; preds = %2
br label %19
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i32, i32* %3
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = call i32 (...) @abort()
unreachable
19: ; preds = %13, %12, %9, %6
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [43 x i8] c"Attempted to write to unknown port 0x%hhX\0A\00"
define void @io_port_write(i32 %0, i32 %1) {
switch i32 %0, label %7 [
i32 190, label %3
i32 191, label %5
i32 126, label %11
i32 127, label %11
]
3: ; preds = %2
%4 = tail call i32 @vdp_data_port_write(i32 %1)
br label %11
5: ; preds = %2
%6 = tail call i32 @vdp_control_port_write(i32 %1)
br label %11
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %0)
%10 = tail call i32 (...) @abort()
unreachable
11: ; preds = %2, %2, %5, %3
ret void
}