#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 bswap(int);
int enc1(unsigned int v1) {
  int edx;
  int i[2];
  int o[2];
  i[0] = v1 & 0xFFFF;
  i[1] = v1 >> 16;
  o[1] = o[0] = i[0] * 0x3333;
  o[1] += edx = i[1] * 0x3333;
  o[1] += o[0] >> 16;
  edx += o[1] >> 16;
  return bswap(edx);
}


x86 assembly (clang, -O0):
<enc1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xffff,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
shr    $0x10,%eax
mov    %eax,-0xc(%rbp)
imul   $0x3333,-0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    %eax,-0x14(%rbp)
imul   $0x3333,-0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
sar    $0x10,%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sar    $0x10,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <bswap@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<enc1>:
movzwl %di,%eax
shr    $0x10,%edi
imul   $0x3333,%eax,%eax
imul   $0x3333,%edi,%ecx
lea    (%rax,%rcx,1),%edx
shr    $0x10,%eax
add    %edx,%eax
shr    $0x10,%eax
add    %ecx,%eax
mov    %eax,%edi
jmp    1030 <bswap@plt>

LLVM IR (-O0):
define i32 @enc1(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [2 x i32]
%5 = alloca [2 x i32]
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = and i32 %6, 65535
%8 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
store i32 %7, i32* %8
%9 = load i32, i32* %2
%10 = lshr i32 %9, 16
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
store i32 %10, i32* %11
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%13 = load i32, i32* %12
%14 = mul nsw i32 %13, 13107
%15 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
store i32 %14, i32* %15
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
store i32 %14, i32* %16
%17 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%18 = load i32, i32* %17
%19 = mul nsw i32 %18, 13107
store i32 %19, i32* %3
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%21 = load i32, i32* %20
%22 = add nsw i32 %21, %19
store i32 %22, i32* %20
%23 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%24 = load i32, i32* %23
%25 = ashr i32 %24, 16
%26 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%27 = load i32, i32* %26
%28 = add nsw i32 %27, %25
store i32 %28, i32* %26
%29 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%30 = load i32, i32* %29
%31 = ashr i32 %30, 16
%32 = load i32, i32* %3
%33 = add nsw i32 %32, %31
store i32 %33, i32* %3
%34 = load i32, i32* %3
%35 = call i32 @bswap(i32 %34)
ret i32 %35
}

LLVM IR (-O2):
define i32 @enc1(i32 %0) {
%2 = and i32 %0, 65535
%3 = lshr i32 %0, 16
%4 = mul nuw nsw i32 %2, 13107
%5 = mul nuw nsw i32 %3, 13107
%6 = add nuw nsw i32 %4, %5
%7 = lshr i32 %4, 16
%8 = add nuw nsw i32 %6, %7
%9 = lshr i32 %8, 16
%10 = add nuw nsw i32 %9, %5
%11 = tail call i32 @bswap(i32 %10)
ret i32 %11
}