unsigned short IPCLiteMtoCGetResult(void *pvData, unsigned short usLength,
                                    unsigned long ulStatusFlag) {
  unsigned short returnStatus;
  if ((*((volatile unsigned long *)(0x400FB700 + 0x000000010))) &
      ulStatusFlag) {
    returnStatus = 0x0001;
  } else {
    if (usLength == 0x00000001) {
      *(unsigned short *)pvData =
          (*((volatile unsigned long *)(0x400FB700 + 0x00000003C)));
    } else if (usLength == 0x00000002) {
      *(unsigned long *)pvData =
          (*((volatile unsigned long *)(0x400FB700 + 0x00000003C)));
    }
    returnStatus = 0x0000;
  }
  return returnStatus;
}


x86 assembly (clang, -O0):
<IPCLiteMtoCGetResult>:
push   %rbp
mov    %rsp,%rbp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x400fb710,%eax
mov    (%rax),%rax
and    -0x18(%rbp),%rax
cmp    $0x0,%rax
je     1134 <IPCLiteMtoCGetResult+0x34>
movw   $0x1,-0x1a(%rbp)
jmp    117f <IPCLiteMtoCGetResult+0x7f>
movzwl -0xa(%rbp),%eax
cmp    $0x1,%eax
jne    1158 <IPCLiteMtoCGetResult+0x58>
mov    $0x400fb73c,%eax
mov    (%rax),%rax
mov    %ax,%cx
mov    -0x8(%rbp),%rax
mov    %cx,(%rax)
jmp    1179 <IPCLiteMtoCGetResult+0x79>
movzwl -0xa(%rbp),%eax
cmp    $0x2,%eax
jne    1174 <IPCLiteMtoCGetResult+0x74>
mov    $0x400fb73c,%eax
mov    (%rax),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
jmp    1179 <IPCLiteMtoCGetResult+0x79>
movw   $0x0,-0x1a(%rbp)
movzwl -0x1a(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<IPCLiteMtoCGetResult>:
mov    $0x1,%ax
and    0x400fb710,%rdx
40
je     110f <IPCLiteMtoCGetResult+0xf>
ret
cmp    $0x2,%si
je     1129 <IPCLiteMtoCGetResult+0x29>
cmp    $0x1,%si
jne    1126 <IPCLiteMtoCGetResult+0x26>
mov    0x400fb73c,%rax
40
mov    %ax,(%rdi)
xor    %eax,%eax
ret
mov    0x400fb73c,%rax
40
mov    %rax,(%rdi)
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define zeroext i16 @IPCLiteMtoCGetResult(i8* nocapture writeonly %0, i16 zeroext %1, i64 %2) {
%4 = load volatile i64, i64* inttoptr (i64 1074771728 to i64*)
%5 = and i64 %4, %2
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %3
switch i16 %1, label %15 [
i16 1, label %8
i16 2, label %12
]
8: ; preds = %7
%9 = load volatile i64, i64* inttoptr (i64 1074771772 to i64*)
%10 = trunc i64 %9 to i16
%11 = bitcast i8* %0 to i16*
store i16 %10, i16* %11
br label %15
12: ; preds = %7
%13 = load volatile i64, i64* inttoptr (i64 1074771772 to i64*)
%14 = bitcast i8* %0 to i64*
store i64 %13, i64* %14
br label %15
15: ; preds = %8, %12, %7, %3
%16 = phi i16 [ 1, %3 ], [ 0, %7 ], [ 0, %12 ], [ 0, %8 ]
ret i16 %16
}