#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 int32_t;

/* Variables and functions */
void prv_extract_int16(int32_t in, int32_t *a, int32_t *b) {
  *a = in & 0xffff;
  *b = (in >> 16) & 0xffff;
  if (*a & 0x8000)
    *a |= 0xffff0000;
  if (*b & 0x8000)
    *b |= 0xffff0000;
}


x86 assembly (clang, -O0):
<prv_extract_int16>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%ecx
and    $0xffff,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x4(%rbp),%ecx
sar    $0x10,%ecx
and    $0xffff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
je     1152 <prv_extract_int16+0x52>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
or     $0xffff0000,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
je     1174 <prv_extract_int16+0x74>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
or     $0xffff0000,%ecx
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<prv_extract_int16>:
movzwl %di,%eax
mov    %eax,(%rsi)
shr    $0x10,%edi
mov    %edi,(%rdx)
mov    (%rsi),%eax
test   $0x8000,%eax
jne    111c <prv_extract_int16+0x1c>
test   $0x8000,%edi
jne    112d <prv_extract_int16+0x2d>
ret
or     $0xffff0000,%eax
mov    %eax,(%rsi)
mov    (%rdx),%edi
test   $0x8000,%edi
je     111b <prv_extract_int16+0x1b>
or     $0xffff0000,%edi
mov    %edi,(%rdx)
ret

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

LLVM IR (-O2):
define void @prv_extract_int16(i32 %0, i32* nocapture %1, i32* nocapture %2) {
%4 = and i32 %0, 65535
store i32 %4, i32* %1
%5 = lshr i32 %0, 16
store i32 %5, i32* %2
%6 = load i32, i32* %1
%7 = and i32 %6, 32768
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = or i32 %6, -65536
store i32 %10, i32* %1
%11 = load i32, i32* %2
br label %12
12: ; preds = %9, %3
%13 = phi i32 [ %11, %9 ], [ %5, %3 ]
%14 = and i32 %13, 32768
%15 = icmp eq i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = or i32 %13, -65536
store i32 %17, i32* %2
br label %18
18: ; preds = %16, %12
ret void
}