void VIM_HIF_SetReg16(unsigned long adr, unsigned short val) {
  unsigned short uTemp;
  if ((adr & 0x1) == 0) {
    ;
    *(volatile unsigned short *)(0x8000000) = (unsigned short)adr;
    ;
    *(volatile unsigned short *)(0x8000100) = val;
  } else {
    ;
    *(volatile unsigned short *)(0x8000000) = (unsigned short)adr - 0x01;
    ;
    uTemp = *(volatile unsigned short *)(0x8000100);
    *(volatile unsigned short *)(0x8000100) = (uTemp & 0xff) | (val << 8);
    ;
    *(volatile unsigned short *)(0x8000000) = (unsigned short)adr + 0x01;
    ;
    uTemp = *(volatile unsigned short *)(0x8000100);
    *(volatile unsigned short *)(0x8000100) = (uTemp & 0xff00) | (val >> 8);
  }
}


x86 assembly (clang, -O0):
<VIM_HIF_SetReg16>:
push   %rbp
mov    %rsp,%rbp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
mov    -0x8(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
jne    1141 <VIM_HIF_SetReg16+0x41>
mov    -0x8(%rbp),%rax
mov    %ax,%cx
mov    $0x8000000,%eax
mov    %cx,(%rax)
mov    -0xa(%rbp),%cx
mov    $0x8000100,%eax
mov    %cx,(%rax)
jmp    11bd <VIM_HIF_SetReg16+0xbd>
mov    -0x8(%rbp),%rax
movzwl %ax,%eax
sub    $0x1,%eax
mov    %ax,%cx
mov    $0x8000000,%eax
mov    %cx,(%rax)
mov    $0x8000100,%eax
mov    (%rax),%ax
mov    %ax,-0xc(%rbp)
movzwl -0xc(%rbp),%eax
and    $0xff,%eax
movzwl -0xa(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %ax,%cx
mov    $0x8000100,%eax
mov    %cx,(%rax)
mov    -0x8(%rbp),%rax
movzwl %ax,%eax
add    $0x1,%eax
mov    %ax,%cx
mov    $0x8000000,%eax
mov    %cx,(%rax)
mov    $0x8000100,%eax
mov    (%rax),%ax
mov    %ax,-0xc(%rbp)
movzwl -0xc(%rbp),%eax
and    $0xff00,%eax
movzwl -0xa(%rbp),%ecx
sar    $0x8,%ecx
or     %ecx,%eax
mov    %ax,%cx
mov    $0x8000100,%eax
mov    %cx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<VIM_HIF_SetReg16>:
test   $0x1,%dil
jne    1117 <VIM_HIF_SetReg16+0x17>
mov    %di,0x8000000
08
mov    %si,0x8000100
08
ret
lea    -0x1(%rdi),%eax
mov    %ax,0x8000000
08
movzwl 0x8000100,%eax
08
movzbl %al,%eax
movzwl %si,%esi
mov    %esi,%ecx
shl    $0x8,%ecx
or     %eax,%ecx
mov    %cx,0x8000100
08
add    $0x1,%edi
mov    %di,0x8000000
08
movzwl 0x8000100,%eax
08
and    $0xffffff00,%eax
shr    $0x8,%esi
or     %eax,%esi
mov    %si,0x8000100
08
ret

LLVM IR (-O0):
define void @VIM_HIF_SetReg16(i64 %0, i16 zeroext %1) {
%3 = alloca i64
%4 = alloca i16
%5 = alloca i16
store i64 %0, i64* %3
store i16 %1, i16* %4
%6 = load i64, i64* %3
%7 = and i64 %6, 1
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i64, i64* %3
%11 = trunc i64 %10 to i16
store volatile i16 %11, i16* inttoptr (i64 134217728 to i16*)
%12 = load i16, i16* %4
store volatile i16 %12, i16* inttoptr (i64 134217984 to i16*)
br label %42
13: ; preds = %2
%14 = load i64, i64* %3
%15 = trunc i64 %14 to i16
%16 = zext i16 %15 to i32
%17 = sub nsw i32 %16, 1
%18 = trunc i32 %17 to i16
store volatile i16 %18, i16* inttoptr (i64 134217728 to i16*)
%19 = load volatile i16, i16* inttoptr (i64 134217984 to i16*)
store i16 %19, i16* %5
%20 = load i16, i16* %5
%21 = zext i16 %20 to i32
%22 = and i32 %21, 255
%23 = load i16, i16* %4
%24 = zext i16 %23 to i32
%25 = shl i32 %24, 8
%26 = or i32 %22, %25
%27 = trunc i32 %26 to i16
store volatile i16 %27, i16* inttoptr (i64 134217984 to i16*)
%28 = load i64, i64* %3
%29 = trunc i64 %28 to i16
%30 = zext i16 %29 to i32
%31 = add nsw i32 %30, 1
%32 = trunc i32 %31 to i16
store volatile i16 %32, i16* inttoptr (i64 134217728 to i16*)
%33 = load volatile i16, i16* inttoptr (i64 134217984 to i16*)
store i16 %33, i16* %5
%34 = load i16, i16* %5
%35 = zext i16 %34 to i32
%36 = and i32 %35, 65280
%37 = load i16, i16* %4
%38 = zext i16 %37 to i32
%39 = ashr i32 %38, 8
%40 = or i32 %36, %39
%41 = trunc i32 %40 to i16
store volatile i16 %41, i16* inttoptr (i64 134217984 to i16*)
br label %42
42: ; preds = %13, %9
ret void
}

LLVM IR (-O2):
define void @VIM_HIF_SetReg16(i64 %0, i16 zeroext %1) {
%3 = and i64 %0, 1
%4 = icmp eq i64 %3, 0
%5 = trunc i64 %0 to i16
br i1 %4, label %6, label %7
6: ; preds = %2
store volatile i16 %5, i16* inttoptr (i64 134217728 to i16*)
br label %18
7: ; preds = %2
%8 = add i16 %5, -1
store volatile i16 %8, i16* inttoptr (i64 134217728 to i16*)
%9 = load volatile i16, i16* inttoptr (i64 134217984 to i16*)
%10 = and i16 %9, 255
%11 = shl i16 %1, 8
%12 = or i16 %10, %11
store volatile i16 %12, i16* inttoptr (i64 134217984 to i16*)
%13 = add i16 %5, 1
store volatile i16 %13, i16* inttoptr (i64 134217728 to i16*)
%14 = load volatile i16, i16* inttoptr (i64 134217984 to i16*)
%15 = and i16 %14, -256
%16 = lshr i16 %1, 8
%17 = or i16 %15, %16
br label %18
18: ; preds = %7, %6
%19 = phi i16 [ %17, %7 ], [ %1, %6 ]
store volatile i16 %19, i16* inttoptr (i64 134217984 to i16*)
ret void
}