#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*/ ff44_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 & 7) == 0)
    wd279x_command_write(val);
  if ((addr & 7) == 1)
    wd279x_track_register_write(val);
  if ((addr & 7) == 2)
    wd279x_sector_register_write(val);
  if ((addr & 7) == 3)
    wd279x_data_register_write(val);
  if (addr & 4)
    ff44_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    $0x7,%eax
cmp    $0x0,%eax
jne    1175 <io_write+0x25>
mov    -0x8(%rbp),%edi
call   1050 <wd279x_command_write@plt>
mov    -0x4(%rbp),%eax
and    $0x7,%eax
cmp    $0x1,%eax
jne    118c <io_write+0x3c>
mov    -0x8(%rbp),%edi
call   1060 <wd279x_track_register_write@plt>
mov    -0x4(%rbp),%eax
and    $0x7,%eax
cmp    $0x2,%eax
jne    11a3 <io_write+0x53>
mov    -0x8(%rbp),%edi
call   1040 <wd279x_sector_register_write@plt>
mov    -0x4(%rbp),%eax
and    $0x7,%eax
cmp    $0x3,%eax
jne    11ba <io_write+0x6a>
mov    -0x8(%rbp),%edi
call   1030 <wd279x_data_register_write@plt>
mov    -0x4(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     11d1 <io_write+0x81>
mov    -0x8(%rbp),%edi
call   1070 <ff44_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    $0x7,%eax
cmp    $0x3,%eax
ja     1196 <io_write+0x46>
lea    0xe98(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %ebx,%edi
call   1050 <wd279x_command_write@plt>
test   $0x4,%bpl
je     119c <io_write+0x4c>
jmp    11b0 <io_write+0x60>
mov    %ebx,%edi
call   1060 <wd279x_track_register_write@plt>
test   $0x4,%bpl
je     119c <io_write+0x4c>
jmp    11b0 <io_write+0x60>
mov    %ebx,%edi
call   1040 <wd279x_sector_register_write@plt>
test   $0x4,%bpl
jne    11b0 <io_write+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %ebx,%edi
call   1030 <wd279x_data_register_write@plt>
test   $0x4,%bpl
je     119c <io_write+0x4c>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1070 <ff44_write@plt>

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, 7
%7 = icmp eq i32 %6, 0
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, 7
%14 = icmp eq i32 %13, 1
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, 7
%21 = icmp eq i32 %20, 2
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, 7
%28 = icmp eq i32 %27, 3
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, 4
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = load i32, i32* %4
%38 = call i32 @ff44_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, 7
switch i32 %3, label %12 [
i32 0, label %4
i32 1, label %6
i32 2, label %8
i32 3, 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, 4
%14 = icmp eq i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = tail call i32 @ff44_write(i32 %1)
br label %17
17: ; preds = %15, %12
ret void
}