#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 */

/* Variables and functions */
int _pack2(unsigned short, unsigned short);
unsigned mult_fun_complexOf_ushort(unsigned a, unsigned b) {
  unsigned short are = (unsigned short)(a >> 16);
  unsigned short aim = (unsigned short)(a & 0x0000ffff);
  unsigned short bre = (unsigned short)(b >> 16);
  unsigned short bim = (unsigned short)(b & 0x0000ffff);
  return _pack2(are * bre - aim * bim, aim * bre + are * bim);
}


x86 assembly (clang, -O0):
<mult_fun_complexOf_ushort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
shr    $0x10,%eax
mov    %ax,-0xa(%rbp)
mov    -0x4(%rbp),%eax
and    $0xffff,%eax
mov    %ax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
shr    $0x10,%eax
mov    %ax,-0xe(%rbp)
mov    -0x8(%rbp),%eax
and    $0xffff,%eax
mov    %ax,-0x10(%rbp)
movzwl -0xa(%rbp),%eax
movzwl -0xe(%rbp),%ecx
imul   %ecx,%eax
movzwl -0xc(%rbp),%ecx
movzwl -0x10(%rbp),%edx
imul   %edx,%ecx
sub    %ecx,%eax
mov    %ax,%cx
movzwl -0xc(%rbp),%eax
movzwl -0xe(%rbp),%edx
imul   %edx,%eax
movzwl -0xa(%rbp),%edx
movzwl -0x10(%rbp),%esi
imul   %esi,%edx
add    %edx,%eax
movzwl %cx,%edi
movzwl %ax,%esi
call   1030 <_pack2@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mult_fun_complexOf_ushort>:
mov    %esi,%eax
shr    $0x10,%eax
mov    %eax,%ecx
mov    %esi,%r8d
imul   %edi,%r8d
imul   %edi,%eax
mov    %edi,%edx
shr    $0x10,%edx
imul   %edx,%ecx
sub    %r8d,%ecx
imul   %esi,%edx
add    %eax,%edx
movzwl %cx,%edi
movzwl %dx,%esi
jmp    1030 <_pack2@plt>

LLVM IR (-O0):
define i32 @mult_fun_complexOf_ushort(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i16
%6 = alloca i16
%7 = alloca i16
%8 = alloca i16
store i32 %0, i32* %3
store i32 %1, i32* %4
%9 = load i32, i32* %3
%10 = lshr i32 %9, 16
%11 = trunc i32 %10 to i16
store i16 %11, i16* %5
%12 = load i32, i32* %3
%13 = and i32 %12, 65535
%14 = trunc i32 %13 to i16
store i16 %14, i16* %6
%15 = load i32, i32* %4
%16 = lshr i32 %15, 16
%17 = trunc i32 %16 to i16
store i16 %17, i16* %7
%18 = load i32, i32* %4
%19 = and i32 %18, 65535
%20 = trunc i32 %19 to i16
store i16 %20, i16* %8
%21 = load i16, i16* %5
%22 = zext i16 %21 to i32
%23 = load i16, i16* %7
%24 = zext i16 %23 to i32
%25 = mul nsw i32 %22, %24
%26 = load i16, i16* %6
%27 = zext i16 %26 to i32
%28 = load i16, i16* %8
%29 = zext i16 %28 to i32
%30 = mul nsw i32 %27, %29
%31 = sub nsw i32 %25, %30
%32 = trunc i32 %31 to i16
%33 = load i16, i16* %6
%34 = zext i16 %33 to i32
%35 = load i16, i16* %7
%36 = zext i16 %35 to i32
%37 = mul nsw i32 %34, %36
%38 = load i16, i16* %5
%39 = zext i16 %38 to i32
%40 = load i16, i16* %8
%41 = zext i16 %40 to i32
%42 = mul nsw i32 %39, %41
%43 = add nsw i32 %37, %42
%44 = trunc i32 %43 to i16
%45 = call i32 @_pack2(i16 zeroext %32, i16 zeroext %44)
ret i32 %45
}

LLVM IR (-O2):
define i32 @mult_fun_complexOf_ushort(i32 %0, i32 %1) {
%3 = lshr i32 %0, 16
%4 = lshr i32 %1, 16
%5 = mul nuw nsw i32 %4, %3
%6 = and i32 %0, 65535
%7 = and i32 %1, 65535
%8 = mul nuw nsw i32 %7, %6
%9 = sub nsw i32 %5, %8
%10 = trunc i32 %9 to i16
%11 = mul nuw nsw i32 %4, %6
%12 = mul nuw nsw i32 %7, %3
%13 = add nuw nsw i32 %11, %12
%14 = trunc i32 %13 to i16
%15 = tail call i32 @_pack2(i16 zeroext %10, i16 zeroext %14)
ret i32 %15
}