#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 /*<<< orphan*/ __m128i;

/* Variables and functions */
int /*<<< orphan*/ _mm_or_si128(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_slli_epi64(int /*<<< orphan*/, int);
int /*<<< orphan*/ _mm_srli_epi64(int /*<<< orphan*/, size_t);
int /*<<< orphan*/ _mm_srli_si128(int /*<<< orphan*/, int);
__m128i shift_right_in(__m128i a, const size_t num_bytes) {
  size_t count = num_bytes * 8;
  __m128i result, tmp;
  result = _mm_srli_epi64(a, count);
  tmp = _mm_srli_si128(a, 8);
  tmp = _mm_slli_epi64(tmp, 64 - (count));
  result = _mm_or_si128(result, tmp);
  return result;
}


x86 assembly (clang, -O0):
<shift_right_in>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1030 <_mm_srli_epi64@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
call   1040 <_mm_srli_si128@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
mov    $0x40,%eax
sub    -0x18(%rbp),%rax
mov    %eax,%esi
call   1060 <_mm_slli_epi64@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1050 <_mm_or_si128@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shift_right_in>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
shl    $0x3,%rbx
mov    %rbx,%rsi
call   1030 <_mm_srli_epi64@plt>
mov    %eax,%r14d
mov    %ebp,%edi
mov    $0x8,%esi
call   1040 <_mm_srli_si128@plt>
mov    $0x40,%esi
sub    %ebx,%esi
mov    %eax,%edi
call   1060 <_mm_slli_epi64@plt>
mov    %r14d,%edi
mov    %eax,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <_mm_or_si128@plt>

LLVM IR (-O0):
define i32 @shift_right_in(i32 %0, i64 %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i64 %1, i64* %4
%8 = load i64, i64* %4
%9 = mul i64 %8, 8
store i64 %9, i64* %5
%10 = load i32, i32* %3
%11 = load i64, i64* %5
%12 = call i32 @_mm_srli_epi64(i32 %10, i64 %11)
store i32 %12, i32* %6
%13 = load i32, i32* %3
%14 = call i32 @_mm_srli_si128(i32 %13, i32 8)
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = load i64, i64* %5
%17 = sub i64 64, %16
%18 = trunc i64 %17 to i32
%19 = call i32 @_mm_slli_epi64(i32 %15, i32 %18)
store i32 %19, i32* %7
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = call i32 @_mm_or_si128(i32 %20, i32 %21)
store i32 %22, i32* %6
%23 = load i32, i32* %6
ret i32 %23
}

LLVM IR (-O2):
define i32 @shift_right_in(i32 %0, i64 %1) {
%3 = shl i64 %1, 3
%4 = tail call i32 @_mm_srli_epi64(i32 %0, i64 %3)
%5 = tail call i32 @_mm_srli_si128(i32 %0, i32 8)
%6 = trunc i64 %3 to i32
%7 = sub i32 64, %6
%8 = tail call i32 @_mm_slli_epi64(i32 %5, i32 %7)
%9 = tail call i32 @_mm_or_si128(i32 %4, i32 %8)
ret i32 %9
}