unsigned short IPCLiteMtoCDataWrite_Protected(unsigned long ulFlag,
                                              unsigned long ulAddress,
                                              unsigned long ulData,
                                              unsigned short usLength,
                                              unsigned long ulStatusFlag) {
  unsigned short returnStatus;
  if ((*((volatile unsigned long *)(0x400FB700 + 0x000000010))) &
      (ulFlag | ulStatusFlag)) {
    returnStatus = 0x0001;
  } else {
    if (usLength == 0x00000001) {
      (*((volatile unsigned long *)(0x400FB700 + 0x000000030))) = 0x0000000D;
    } else {
      (*((volatile unsigned long *)(0x400FB700 + 0x000000030))) = 0x0000000E;
    }
    (*((volatile unsigned long *)(0x400FB700 + 0x000000034))) = ulAddress;
    (*((volatile unsigned long *)(0x400FB700 + 0x000000038))) = ulData;
    (*((volatile unsigned long *)(0x400FB700 + 0x000000008))) |=
        (ulFlag | ulStatusFlag);
    returnStatus = 0x0000;
  }
  return returnStatus;
}


x86 assembly (clang, -O0):
<IPCLiteMtoCDataWrite_Protected>:
push   %rbp
mov    %rsp,%rbp
mov    %cx,%ax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ax,-0x1a(%rbp)
mov    %r8,-0x28(%rbp)
mov    $0x400fb710,%eax
mov    (%rax),%rax
mov    -0x8(%rbp),%rcx
or     -0x28(%rbp),%rcx
and    %rcx,%rax
cmp    $0x0,%rax
je     1143 <IPCLiteMtoCDataWrite_Protected+0x43>
movw   $0x1,-0x2a(%rbp)
jmp    11a6 <IPCLiteMtoCDataWrite_Protected+0xa6>
movzwl -0x1a(%rbp),%eax
cmp    $0x1,%eax
jne    1161 <IPCLiteMtoCDataWrite_Protected+0x61>
mov    $0x400fb730,%eax
movq   $0xd,(%rax)
jmp    116d <IPCLiteMtoCDataWrite_Protected+0x6d>
mov    $0x400fb730,%eax
movq   $0xe,(%rax)
mov    -0x10(%rbp),%rcx
mov    $0x400fb734,%eax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rcx
mov    $0x400fb738,%eax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
or     -0x28(%rbp),%rax
mov    $0x400fb708,%ecx
mov    (%rcx),%rcx
or     %rax,%rcx
mov    $0x400fb708,%eax
mov    %rcx,(%rax)
movw   $0x0,-0x2a(%rbp)
movzwl -0x2a(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<IPCLiteMtoCDataWrite_Protected>:
or     %r8,%rdi
mov    0x400fb710,%r8
40
mov    $0x1,%ax
and    %rdi,%r8
je     1115 <IPCLiteMtoCDataWrite_Protected+0x15>
ret
xor    %eax,%eax
cmp    $0x1,%cx
sete   %al
mov    $0xe,%ecx
sub    %rax,%rcx
mov    %rcx,0x400fb730
40
mov    %rsi,0x400fb734
40
mov    %rdx,0x400fb738
40
or     %rdi,0x400fb708
40
xor    %eax,%eax
ret

LLVM IR (-O0):
define zeroext i16 @IPCLiteMtoCDataWrite_Protected(i64 %0, i64 %1, i64 %2, i16 zeroext %3, i64 %4) {
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i16
%10 = alloca i64
%11 = alloca i16
store i64 %0, i64* %6
store i64 %1, i64* %7
store i64 %2, i64* %8
store i16 %3, i16* %9
store i64 %4, i64* %10
%12 = load volatile i64, i64* inttoptr (i64 1074771728 to i64*)
%13 = load i64, i64* %6
%14 = load i64, i64* %10
%15 = or i64 %13, %14
%16 = and i64 %12, %15
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %5
store i16 1, i16* %11
br label %33
19: ; preds = %5
%20 = load i16, i16* %9
%21 = zext i16 %20 to i32
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %24
23: ; preds = %19
store volatile i64 13, i64* inttoptr (i64 1074771760 to i64*)
br label %25
24: ; preds = %19
store volatile i64 14, i64* inttoptr (i64 1074771760 to i64*)
br label %25
25: ; preds = %24, %23
%26 = load i64, i64* %7
store volatile i64 %26, i64* inttoptr (i64 1074771764 to i64*)
%27 = load i64, i64* %8
store volatile i64 %27, i64* inttoptr (i64 1074771768 to i64*)
%28 = load i64, i64* %6
%29 = load i64, i64* %10
%30 = or i64 %28, %29
%31 = load volatile i64, i64* inttoptr (i64 1074771720 to i64*)
%32 = or i64 %31, %30
store volatile i64 %32, i64* inttoptr (i64 1074771720 to i64*)
store i16 0, i16* %11
br label %33
33: ; preds = %25, %18
%34 = load i16, i16* %11
ret i16 %34
}

LLVM IR (-O2):
define zeroext i16 @IPCLiteMtoCDataWrite_Protected(i64 %0, i64 %1, i64 %2, i16 zeroext %3, i64 %4) {
%6 = load volatile i64, i64* inttoptr (i64 1074771728 to i64*)
%7 = or i64 %4, %0
%8 = and i64 %6, %7
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = icmp eq i16 %3, 1
%12 = select i1 %11, i64 13, i64 14
store volatile i64 %12, i64* inttoptr (i64 1074771760 to i64*)
store volatile i64 %1, i64* inttoptr (i64 1074771764 to i64*)
store volatile i64 %2, i64* inttoptr (i64 1074771768 to i64*)
%13 = load volatile i64, i64* inttoptr (i64 1074771720 to i64*)
%14 = or i64 %13, %7
store volatile i64 %14, i64* inttoptr (i64 1074771720 to i64*)
br label %15
15: ; preds = %5, %10
%16 = phi i16 [ 0, %10 ], [ 1, %5 ]
ret i16 %16
}