#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 */
typedef struct TYPE_16__ TYPE_1__;

/* Type definitions */
struct TYPE_16__ {
  int member_0;
  int member_1;
};
typedef TYPE_1__ __m128i;

/* Variables and functions */
TYPE_1__ _mm_and_si128(TYPE_1__, TYPE_1__);
TYPE_1__ _mm_cmpgt_epi8(TYPE_1__, TYPE_1__);
TYPE_1__ _mm_setzero_si128();
TYPE_1__ _mm_slli_epi16(TYPE_1__, int);
TYPE_1__ _mm_xor_si128(TYPE_1__, TYPE_1__);
__m128i GF_vectmulX(__m128i v) {
  __m128i v1;
  __m128i mask;
  __m128i res;
  __m128i low_bit_mask = {0xfefefefefefefefe, 0xfefefefefefefefe};
  __m128i high_bit_mask = {0x8080808080808080, 0x8080808080808080};
  __m128i modulo_mask = {0x1d1d1d1d1d1d1d1d, 0x1d1d1d1d1d1d1d1d};
  unsigned char A[16] __attribute__((aligned(16)));
  int i;
  mask = _mm_setzero_si128();
  v1 = _mm_and_si128(v, high_bit_mask);
  mask = _mm_cmpgt_epi8(mask, v1);
  mask = _mm_and_si128(mask, modulo_mask);
  res = v;
  res = _mm_slli_epi16(res, 1);
  res = _mm_and_si128(res, low_bit_mask);
  res = _mm_xor_si128(res, mask);
  return res;
}


x86 assembly (clang, -O0):
<GF_vectmulX>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe94(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1030 <_mm_setzero_si128@plt>
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1060 <_mm_and_si128@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <_mm_cmpgt_epi8@plt>
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1060 <_mm_and_si128@plt>
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1070 <_mm_slli_epi16@plt>
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <_mm_and_si128@plt>
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <_mm_xor_si128@plt>
mov    %rax,-0x90(%rbp)
mov    -0x90(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GF_vectmulX>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <_mm_setzero_si128@plt>
mov    %rax,%rbx
movabs $0x8080808080808080,%rsi
80 80 80
mov    %r14,%rdi
call   1060 <_mm_and_si128@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <_mm_cmpgt_epi8@plt>
movabs $0x1d1d1d1d1d1d1d1d,%rsi
1d 1d 1d
mov    %rax,%rdi
call   1060 <_mm_and_si128@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x1,%esi
call   1070 <_mm_slli_epi16@plt>
movabs $0xfefefefefefefefe,%rsi
fe fe fe
mov    %rax,%rdi
call   1060 <_mm_and_si128@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <_mm_xor_si128@plt>

LLVM IR (-O0):
%struct.TYPE_16__ = type { i32, i32 }
@__const.GF_vectmulX.low_bit_mask = %struct.TYPE_16__ { i32 -16843010, i32 -16843010 }
@__const.GF_vectmulX.high_bit_mask = %struct.TYPE_16__ { i32 -2139062144, i32 -2139062144 }
@__const.GF_vectmulX.modulo_mask = %struct.TYPE_16__ { i32 488447261, i32 488447261 }
define i64 @GF_vectmulX(i64 %0) {
%2 = alloca %struct.TYPE_16__
%3 = alloca %struct.TYPE_16__
%4 = alloca %struct.TYPE_16__
%5 = alloca %struct.TYPE_16__
%6 = alloca %struct.TYPE_16__
%7 = alloca %struct.TYPE_16__
%8 = alloca %struct.TYPE_16__
%9 = alloca [16 x i8]
%10 = alloca i32
%11 = alloca %struct.TYPE_16__
%12 = alloca %struct.TYPE_16__
%13 = alloca %struct.TYPE_16__
%14 = alloca %struct.TYPE_16__
%15 = alloca %struct.TYPE_16__
%16 = alloca %struct.TYPE_16__
%17 = alloca %struct.TYPE_16__
%18 = bitcast %struct.TYPE_16__* %3 to i64*
store i64 %0, i64* %18
%19 = bitcast %struct.TYPE_16__* %6 to i8*
%20 = bitcast %struct.TYPE_16__* %7 to i8*
%21 = bitcast %struct.TYPE_16__* %8 to i8*
%22 = call i64 (...) @_mm_setzero_si128()
%23 = bitcast %struct.TYPE_16__* %11 to i64*
store i64 %22, i64* %23
%24 = bitcast %struct.TYPE_16__* %5 to i8*
%25 = bitcast %struct.TYPE_16__* %11 to i8*
%26 = bitcast %struct.TYPE_16__* %3 to i64*
%27 = load i64, i64* %26
%28 = bitcast %struct.TYPE_16__* %7 to i64*
%29 = load i64, i64* %28
%30 = call i64 @_mm_and_si128(i64 %27, i64 %29)
%31 = bitcast %struct.TYPE_16__* %12 to i64*
store i64 %30, i64* %31
%32 = bitcast %struct.TYPE_16__* %4 to i8*
%33 = bitcast %struct.TYPE_16__* %12 to i8*
%34 = bitcast %struct.TYPE_16__* %5 to i64*
%35 = load i64, i64* %34
%36 = bitcast %struct.TYPE_16__* %4 to i64*
%37 = load i64, i64* %36
%38 = call i64 @_mm_cmpgt_epi8(i64 %35, i64 %37)
%39 = bitcast %struct.TYPE_16__* %13 to i64*
store i64 %38, i64* %39
%40 = bitcast %struct.TYPE_16__* %5 to i8*
%41 = bitcast %struct.TYPE_16__* %13 to i8*
%42 = bitcast %struct.TYPE_16__* %5 to i64*
%43 = load i64, i64* %42
%44 = bitcast %struct.TYPE_16__* %8 to i64*
%45 = load i64, i64* %44
%46 = call i64 @_mm_and_si128(i64 %43, i64 %45)
%47 = bitcast %struct.TYPE_16__* %14 to i64*
store i64 %46, i64* %47
%48 = bitcast %struct.TYPE_16__* %5 to i8*
%49 = bitcast %struct.TYPE_16__* %14 to i8*
%50 = bitcast %struct.TYPE_16__* %2 to i8*
%51 = bitcast %struct.TYPE_16__* %3 to i8*
%52 = bitcast %struct.TYPE_16__* %2 to i64*
%53 = load i64, i64* %52
%54 = call i64 @_mm_slli_epi16(i64 %53, i32 1)
%55 = bitcast %struct.TYPE_16__* %15 to i64*
store i64 %54, i64* %55
%56 = bitcast %struct.TYPE_16__* %2 to i8*
%57 = bitcast %struct.TYPE_16__* %15 to i8*
%58 = bitcast %struct.TYPE_16__* %2 to i64*
%59 = load i64, i64* %58
%60 = bitcast %struct.TYPE_16__* %6 to i64*
%61 = load i64, i64* %60
%62 = call i64 @_mm_and_si128(i64 %59, i64 %61)
%63 = bitcast %struct.TYPE_16__* %16 to i64*
store i64 %62, i64* %63
%64 = bitcast %struct.TYPE_16__* %2 to i8*
%65 = bitcast %struct.TYPE_16__* %16 to i8*
%66 = bitcast %struct.TYPE_16__* %2 to i64*
%67 = load i64, i64* %66
%68 = bitcast %struct.TYPE_16__* %5 to i64*
%69 = load i64, i64* %68
%70 = call i64 @_mm_xor_si128(i64 %67, i64 %69)
%71 = bitcast %struct.TYPE_16__* %17 to i64*
store i64 %70, i64* %71
%72 = bitcast %struct.TYPE_16__* %2 to i8*
%73 = bitcast %struct.TYPE_16__* %17 to i8*
%74 = bitcast %struct.TYPE_16__* %2 to i64*
%75 = load i64, i64* %74
ret i64 %75
}

LLVM IR (-O2):
define i64 @GF_vectmulX(i64 %0) {
%2 = tail call i64 (...) @_mm_setzero_si128()
%3 = tail call i64 @_mm_and_si128(i64 %0, i64 -9187201950435737472)
%4 = tail call i64 @_mm_cmpgt_epi8(i64 %2, i64 %3)
%5 = tail call i64 @_mm_and_si128(i64 %4, i64 2097865012304223517)
%6 = tail call i64 @_mm_slli_epi16(i64 %0, i32 1)
%7 = tail call i64 @_mm_and_si128(i64 %6, i64 -72340172838076674)
%8 = tail call i64 @_mm_xor_si128(i64 %7, i64 %5)
ret i64 %8
}