#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*/ ff40_write(int);
int /*<<< orphan*/ wd279x_command_write(int);
int /*<<< orphan*/ wd279x_data_register_write(int);
int /*<<< orphan*/ wd279x_sector_register_write(int);
int /*<<< orphan*/ wd279x_track_register_write(int);
void io_write(int addr, int val) {
  if ((addr & 15) == 8)
    wd279x_command_write(val);
  if ((addr & 15) == 9)
    wd279x_track_register_write(val);
  if ((addr & 15) == 10)
    wd279x_sector_register_write(val);
  if ((addr & 15) == 11)
    wd279x_data_register_write(val);
  if (!(addr & 8))
    ff40_write(val);
}


x86 assembly (clang, -O0):
<io_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0xf,%eax
cmp    $0x8,%eax
jne    1175 <io_write+0x25>
mov    -0x8(%rbp),%edi
call   1060 <wd279x_command_write@plt>
mov    -0x4(%rbp),%eax
and    $0xf,%eax
cmp    $0x9,%eax
jne    118c <io_write+0x3c>
mov    -0x8(%rbp),%edi
call   1070 <wd279x_track_register_write@plt>
mov    -0x4(%rbp),%eax
and    $0xf,%eax
cmp    $0xa,%eax
jne    11a3 <io_write+0x53>
mov    -0x8(%rbp),%edi
call   1040 <wd279x_sector_register_write@plt>
mov    -0x4(%rbp),%eax
and    $0xf,%eax
cmp    $0xb,%eax
jne    11ba <io_write+0x6a>
mov    -0x8(%rbp),%edi
call   1030 <wd279x_data_register_write@plt>
mov    -0x4(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
jne    11d1 <io_write+0x81>
mov    -0x8(%rbp),%edi
call   1050 <ff40_write@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<io_write>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
mov    %edi,%eax
and    $0xf,%eax
add    $0xfffffff8,%eax
cmp    $0x3,%eax
ja     1199 <io_write+0x49>
lea    0xe95(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %ebx,%edi
call   1060 <wd279x_command_write@plt>
test   $0x8,%bpl
je     119f <io_write+0x4f>
jmp    11b9 <io_write+0x69>
mov    %ebx,%edi
call   1070 <wd279x_track_register_write@plt>
test   $0x8,%bpl
je     119f <io_write+0x4f>
jmp    11b9 <io_write+0x69>
mov    %ebx,%edi
call   1040 <wd279x_sector_register_write@plt>
test   $0x8,%bpl
jne    11b9 <io_write+0x69>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <ff40_write@plt>
mov    %ebx,%edi
call   1030 <wd279x_data_register_write@plt>
test   $0x8,%bpl
je     119f <io_write+0x4f>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @io_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
%6 = and i32 %5, 15
%7 = icmp eq i32 %6, 8
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* %4
%10 = call i32 @wd279x_command_write(i32 %9)
br label %11
11: ; preds = %8, %2
%12 = load i32, i32* %3
%13 = and i32 %12, 15
%14 = icmp eq i32 %13, 9
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i32, i32* %4
%17 = call i32 @wd279x_track_register_write(i32 %16)
br label %18
18: ; preds = %15, %11
%19 = load i32, i32* %3
%20 = and i32 %19, 15
%21 = icmp eq i32 %20, 10
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i32, i32* %4
%24 = call i32 @wd279x_sector_register_write(i32 %23)
br label %25
25: ; preds = %22, %18
%26 = load i32, i32* %3
%27 = and i32 %26, 15
%28 = icmp eq i32 %27, 11
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i32, i32* %4
%31 = call i32 @wd279x_data_register_write(i32 %30)
br label %32
32: ; preds = %29, %25
%33 = load i32, i32* %3
%34 = and i32 %33, 8
%35 = icmp ne i32 %34, 0
br i1 %35, label %39, label %36
36: ; preds = %32
%37 = load i32, i32* %4
%38 = call i32 @ff40_write(i32 %37)
br label %39
39: ; preds = %36, %32
ret void
}

LLVM IR (-O2):
define void @io_write(i32 %0, i32 %1) {
%3 = and i32 %0, 15
switch i32 %3, label %12 [
i32 8, label %4
i32 9, label %6
i32 10, label %8
i32 11, label %10
]
4: ; preds = %2
%5 = tail call i32 @wd279x_command_write(i32 %1)
br label %12
6: ; preds = %2
%7 = tail call i32 @wd279x_track_register_write(i32 %1)
br label %12
8: ; preds = %2
%9 = tail call i32 @wd279x_sector_register_write(i32 %1)
br label %12
10: ; preds = %2
%11 = tail call i32 @wd279x_data_register_write(i32 %1)
br label %12
12: ; preds = %8, %6, %4, %2, %10
%13 = and i32 %0, 8
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 @ff40_write(i32 %1)
br label %17
17: ; preds = %15, %12
ret void
}