#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;
typedef int uint16_t;

/* Variables and functions */
int wd76c10_read(int, void *);
int /*<<< orphan*/ wd76c10_write(int, int, void *);
void wd76c10_writeb(uint16_t port, uint8_t val, void *priv) {
  uint16_t temp = wd76c10_read(port, priv);
  if (port & 1)
    wd76c10_write(port & ~1, (temp & 0x00ff) | (val << 8), priv);
  else
    wd76c10_write(port, (temp & 0xff00) | val, priv);
}


x86 assembly (clang, -O0):
<wd76c10_writeb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <wd76c10_read@plt>
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1175 <wd76c10_writeb+0x55>
mov    -0x4(%rbp),%edi
and    $0xfffffffe,%edi
mov    -0x14(%rbp),%esi
and    $0xff,%esi
mov    -0x8(%rbp),%eax
shl    $0x8,%eax
or     %eax,%esi
mov    -0x10(%rbp),%rdx
call   1040 <wd76c10_write@plt>
jmp    118d <wd76c10_writeb+0x6d>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
and    $0xff00,%esi
or     -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1040 <wd76c10_write@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wd76c10_writeb>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %esi,%ebp
mov    %edi,%ebx
mov    %rdx,%rsi
call   1030 <wd76c10_read@plt>
test   $0x1,%bl
jne    1145 <wd76c10_writeb+0x25>
and    $0xff00,%eax
or     %ebp,%eax
mov    %ebx,%edi
mov    %eax,%esi
jmp    1154 <wd76c10_writeb+0x34>
and    $0xfffffffe,%ebx
movzbl %al,%eax
shl    $0x8,%ebp
or     %eax,%ebp
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <wd76c10_write@plt>

LLVM IR (-O0):
define void @wd76c10_writeb(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%8 = load i32, i32* %4
%9 = load i8*, i8** %6
%10 = call i32 @wd76c10_read(i32 %8, i8* %9)
store i32 %10, i32* %7
%11 = load i32, i32* %4
%12 = and i32 %11, 1
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %24
14: ; preds = %3
%15 = load i32, i32* %4
%16 = and i32 %15, -2
%17 = load i32, i32* %7
%18 = and i32 %17, 255
%19 = load i32, i32* %5
%20 = shl i32 %19, 8
%21 = or i32 %18, %20
%22 = load i8*, i8** %6
%23 = call i32 @wd76c10_write(i32 %16, i32 %21, i8* %22)
br label %32
24: ; preds = %3
%25 = load i32, i32* %4
%26 = load i32, i32* %7
%27 = and i32 %26, 65280
%28 = load i32, i32* %5
%29 = or i32 %27, %28
%30 = load i8*, i8** %6
%31 = call i32 @wd76c10_write(i32 %25, i32 %29, i8* %30)
br label %32
32: ; preds = %24, %14
ret void
}

LLVM IR (-O2):
define void @wd76c10_writeb(i32 %0, i32 %1, i8* %2) {
%4 = tail call i32 @wd76c10_read(i32 %0, i8* %2)
%5 = and i32 %0, 1
%6 = icmp eq i32 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %3
%8 = and i32 %0, -2
%9 = and i32 %4, 255
%10 = shl i32 %1, 8
%11 = or i32 %9, %10
%12 = tail call i32 @wd76c10_write(i32 %8, i32 %11, i8* %2)
br label %17
13: ; preds = %3
%14 = and i32 %4, 65280
%15 = or i32 %14, %1
%16 = tail call i32 @wd76c10_write(i32 %0, i32 %15, i8* %2)
br label %17
17: ; preds = %13, %7
ret void
}