void IPCLiteCtoMDataWrite_Protected(unsigned long ulFlag,
                                    unsigned long ulStatusFlag) {
  unsigned long *pulAddress;
  unsigned short *pusAddress;
  unsigned long ulWRALLOWtemp;
  while (
      !((*((volatile unsigned long *)(0x400FB700 + 0x000000004))) & ulFlag)) {
  }
  ulWRALLOWtemp = (*((volatile unsigned long *)(0x400FB980)));
  (*((volatile unsigned long *)(0x400FB980))) = 0xA5A5A5A5;
  if ((*((volatile unsigned long *)(0x400FB700 + 0x000000020))) == 0x0000000D) {
    pusAddress = (unsigned short *)(*(
        (volatile unsigned long *)(0x400FB700 + 0x000000024)));
    *pusAddress = (unsigned short)(*(
        (volatile unsigned long *)(0x400FB700 + 0x000000028)));
    (*((volatile unsigned long *)(0x400FB700 + 0x00000002C))) =
        (unsigned long)*pusAddress;
    (*((volatile unsigned long *)(0x400FB700 + 0x000000000))) |=
        (ulStatusFlag | ulFlag);
  } else if (((*((volatile unsigned long *)(0x400FB700 + 0x000000020))) ==
              0x0000000E)) {
    pulAddress = (unsigned long *)(*(
        (volatile unsigned long *)(0x400FB700 + 0x000000024)));
    *pulAddress = (*((volatile unsigned long *)(0x400FB700 + 0x000000028)));
    (*((volatile unsigned long *)(0x400FB700 + 0x00000002C))) = *pulAddress;
    (*((volatile unsigned long *)(0x400FB700 + 0x000000000))) |=
        (ulStatusFlag | ulFlag);
  } else {
    (*((volatile unsigned long *)(0x400FB700 + 0x000000000))) |= (ulFlag);
  }
  (*((volatile unsigned long *)(0x400FB980))) = ulWRALLOWtemp;
}


x86 assembly (clang, -O0):
<IPCLiteCtoMDataWrite_Protected>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x400fb704,%eax
mov    (%rax),%rax
and    -0x8(%rbp),%rax
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    112e <IPCLiteCtoMDataWrite_Protected+0x2e>
jmp    1133 <IPCLiteCtoMDataWrite_Protected+0x33>
jmp    110c <IPCLiteCtoMDataWrite_Protected+0xc>
mov    $0x400fb980,%eax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    $0x400fb980,%eax
mov    $0xa5a5a5a5,%ecx
mov    %rcx,(%rax)
mov    $0x400fb720,%eax
mov    (%rax),%rax
cmp    $0xd,%rax
jne    11ad <IPCLiteCtoMDataWrite_Protected+0xad>
mov    $0x400fb724,%eax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    $0x400fb728,%eax
mov    (%rax),%rax
mov    %ax,%cx
mov    -0x20(%rbp),%rax
mov    %cx,(%rax)
mov    -0x20(%rbp),%rax
movzwl (%rax),%eax
mov    %eax,%ecx
mov    $0x400fb72c,%eax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
or     -0x8(%rbp),%rax
mov    $0x400fb700,%ecx
mov    (%rcx),%rcx
or     %rax,%rcx
mov    $0x400fb700,%eax
mov    %rcx,(%rax)
jmp    1225 <IPCLiteCtoMDataWrite_Protected+0x125>
mov    $0x400fb720,%eax
mov    (%rax),%rax
cmp    $0xe,%rax
jne    1209 <IPCLiteCtoMDataWrite_Protected+0x109>
mov    $0x400fb724,%eax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    $0x400fb728,%eax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
mov    $0x400fb72c,%eax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
or     -0x8(%rbp),%rax
mov    $0x400fb700,%ecx
mov    (%rcx),%rcx
or     %rax,%rcx
mov    $0x400fb700,%eax
mov    %rcx,(%rax)
jmp    1220 <IPCLiteCtoMDataWrite_Protected+0x120>
mov    -0x8(%rbp),%rax
mov    $0x400fb700,%ecx
mov    (%rcx),%rcx
or     %rax,%rcx
mov    $0x400fb700,%eax
mov    %rcx,(%rax)
jmp    1225 <IPCLiteCtoMDataWrite_Protected+0x125>
mov    -0x28(%rbp),%rcx
mov    $0x400fb980,%eax
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<IPCLiteCtoMDataWrite_Protected>:
mov    0x400fb704,%rax
40
and    %rdi,%rax
je     1100 <IPCLiteCtoMDataWrite_Protected>
mov    0x400fb980,%rax
40
mov    $0xa5a5a5a5,%ecx
mov    %rcx,0x400fb980
40
mov    0x400fb720,%rcx
40
cmp    $0xd,%rcx
jne    1150 <IPCLiteCtoMDataWrite_Protected+0x50>
mov    0x400fb724,%rcx
40
mov    0x400fb728,%rdx
40
mov    %dx,(%rcx)
movzwl %dx,%ecx
mov    %rcx,0x400fb72c
40
jmp    1179 <IPCLiteCtoMDataWrite_Protected+0x79>
mov    0x400fb720,%rcx
40
cmp    $0xe,%rcx
jne    1186 <IPCLiteCtoMDataWrite_Protected+0x86>
mov    0x400fb724,%rcx
40
mov    0x400fb728,%rdx
40
mov    %rdx,(%rcx)
mov    %rdx,0x400fb72c
40
or     %rdi,%rsi
mov    0x400fb700,%rdi
40
jmp    118e <IPCLiteCtoMDataWrite_Protected+0x8e>
mov    0x400fb700,%rsi
40
or     %rsi,%rdi
mov    %rdi,0x400fb700
40
mov    %rax,0x400fb980
40
ret

LLVM IR (-O0):
define void @IPCLiteCtoMDataWrite_Protected(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64*
%6 = alloca i16*
%7 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
br label %8
8: ; preds = %14, %2
%9 = load volatile i64, i64* inttoptr (i64 1074771716 to i64*)
%10 = load i64, i64* %3
%11 = and i64 %9, %10
%12 = icmp ne i64 %11, 0
%13 = xor i1 %12, true
br i1 %13, label %14, label %15
14: ; preds = %8
br label %8
15: ; preds = %8
%16 = load volatile i64, i64* inttoptr (i64 1074772352 to i64*)
store i64 %16, i64* %7
store volatile i64 2779096485, i64* inttoptr (i64 1074772352 to i64*)
%17 = load volatile i64, i64* inttoptr (i64 1074771744 to i64*)
%18 = icmp eq i64 %17, 13
br i1 %18, label %19, label %33
19: ; preds = %15
%20 = load volatile i64, i64* inttoptr (i64 1074771748 to i64*)
%21 = inttoptr i64 %20 to i16*
store i16* %21, i16** %6
%22 = load volatile i64, i64* inttoptr (i64 1074771752 to i64*)
%23 = trunc i64 %22 to i16
%24 = load i16*, i16** %6
store i16 %23, i16* %24
%25 = load i16*, i16** %6
%26 = load i16, i16* %25
%27 = zext i16 %26 to i64
store volatile i64 %27, i64* inttoptr (i64 1074771756 to i64*)
%28 = load i64, i64* %4
%29 = load i64, i64* %3
%30 = or i64 %28, %29
%31 = load volatile i64, i64* inttoptr (i64 1074771712 to i64*)
%32 = or i64 %31, %30
store volatile i64 %32, i64* inttoptr (i64 1074771712 to i64*)
br label %53
33: ; preds = %15
%34 = load volatile i64, i64* inttoptr (i64 1074771744 to i64*)
%35 = icmp eq i64 %34, 14
br i1 %35, label %36, label %48
36: ; preds = %33
%37 = load volatile i64, i64* inttoptr (i64 1074771748 to i64*)
%38 = inttoptr i64 %37 to i64*
store i64* %38, i64** %5
%39 = load volatile i64, i64* inttoptr (i64 1074771752 to i64*)
%40 = load i64*, i64** %5
store i64 %39, i64* %40
%41 = load i64*, i64** %5
%42 = load i64, i64* %41
store volatile i64 %42, i64* inttoptr (i64 1074771756 to i64*)
%43 = load i64, i64* %4
%44 = load i64, i64* %3
%45 = or i64 %43, %44
%46 = load volatile i64, i64* inttoptr (i64 1074771712 to i64*)
%47 = or i64 %46, %45
store volatile i64 %47, i64* inttoptr (i64 1074771712 to i64*)
br label %52
48: ; preds = %33
%49 = load i64, i64* %3
%50 = load volatile i64, i64* inttoptr (i64 1074771712 to i64*)
%51 = or i64 %50, %49
store volatile i64 %51, i64* inttoptr (i64 1074771712 to i64*)
br label %52
52: ; preds = %48, %36
br label %53
53: ; preds = %52, %19
%54 = load i64, i64* %7
store volatile i64 %54, i64* inttoptr (i64 1074772352 to i64*)
ret void
}

LLVM IR (-O2):
define void @IPCLiteCtoMDataWrite_Protected(i64 %0, i64 %1) {
br label %3
3: ; preds = %3, %2
%4 = load volatile i64, i64* inttoptr (i64 1074771716 to i64*)
%5 = and i64 %4, %0
%6 = icmp eq i64 %5, 0
br i1 %6, label %3, label %7
7: ; preds = %3
%8 = load volatile i64, i64* inttoptr (i64 1074772352 to i64*)
store volatile i64 2779096485, i64* inttoptr (i64 1074772352 to i64*)
%9 = load volatile i64, i64* inttoptr (i64 1074771744 to i64*)
%10 = icmp eq i64 %9, 13
br i1 %10, label %11, label %19
11: ; preds = %7
%12 = load volatile i64, i64* inttoptr (i64 1074771748 to i64*)
%13 = inttoptr i64 %12 to i16*
%14 = load volatile i64, i64* inttoptr (i64 1074771752 to i64*)
%15 = trunc i64 %14 to i16
store i16 %15, i16* %13
%16 = and i64 %14, 65535
store volatile i64 %16, i64* inttoptr (i64 1074771756 to i64*)
%17 = or i64 %1, %0
%18 = load volatile i64, i64* inttoptr (i64 1074771712 to i64*)
br label %30
19: ; preds = %7
%20 = load volatile i64, i64* inttoptr (i64 1074771744 to i64*)
%21 = icmp eq i64 %20, 14
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = load volatile i64, i64* inttoptr (i64 1074771748 to i64*)
%24 = inttoptr i64 %23 to i64*
%25 = load volatile i64, i64* inttoptr (i64 1074771752 to i64*)
store i64 %25, i64* %24
store volatile i64 %25, i64* inttoptr (i64 1074771756 to i64*)
%26 = or i64 %1, %0
%27 = load volatile i64, i64* inttoptr (i64 1074771712 to i64*)
br label %30
28: ; preds = %19
%29 = load volatile i64, i64* inttoptr (i64 1074771712 to i64*)
br label %30
30: ; preds = %22, %28, %11
%31 = phi i64 [ %27, %22 ], [ %0, %28 ], [ %18, %11 ]
%32 = phi i64 [ %26, %22 ], [ %29, %28 ], [ %17, %11 ]
%33 = or i64 %32, %31
store volatile i64 %33, i64* inttoptr (i64 1074771712 to i64*)
store volatile i64 %8, i64* inttoptr (i64 1074772352 to i64*)
ret void
}