#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*/ uint8_t;
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ htonl(int);
int ntohl(int /*<<< orphan*/ const);
void _SHIFT_RIGHT_UINT32(uint8_t *dst_ptr, const uint8_t *src_ptr1,
                         const int src_len1, const uint8_t *src_ptr2,
                         const int src_len2) {
  *(uint32_t *)dst_ptr = htonl(
      ntohl(
          *(const uint32_t *)(src_ptr1 + src_len1 - sizeof(const uint32_t))) >>
      ntohl(*(const uint32_t *)(src_ptr2 + src_len2 - sizeof(const uint32_t))));
}


x86 assembly (clang, -O0):
<_SHIFT_RIGHT_UINT32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    -0x10(%rax,%rcx,4),%edi
call   1040 <ntohl@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    -0x10(%rax,%rcx,4),%edi
call   1040 <ntohl@plt>
mov    -0x28(%rbp),%edi
mov    %eax,%ecx
sar    %cl,%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_SHIFT_RIGHT_UINT32>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8d,%ebx
mov    %rcx,%r14
mov    %rdi,%r15
movslq %edx,%rax
mov    -0x10(%rsi,%rax,4),%edi
call   1040 <ntohl@plt>
mov    %eax,%ebp
movslq %ebx,%rax
mov    -0x10(%r14,%rax,4),%edi
call   1040 <ntohl@plt>
mov    %eax,%ecx
sar    %cl,%ebp
mov    %ebp,%edi
call   1030 <htonl@plt>
mov    %eax,(%r15)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @_SHIFT_RIGHT_UINT32(i32* %0, i32* %1, i32 %2, i32* %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
store i32* %0, i32** %6
store i32* %1, i32** %7
store i32 %2, i32* %8
store i32* %3, i32** %9
store i32 %4, i32* %10
%11 = load i32*, i32** %7
%12 = load i32, i32* %8
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %11, i64 %13
%15 = getelementptr inbounds i32, i32* %14, i64 -4
%16 = load i32, i32* %15
%17 = call i32 @ntohl(i32 %16)
%18 = load i32*, i32** %9
%19 = load i32, i32* %10
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
%22 = getelementptr inbounds i32, i32* %21, i64 -4
%23 = load i32, i32* %22
%24 = call i32 @ntohl(i32 %23)
%25 = ashr i32 %17, %24
%26 = call i32 @htonl(i32 %25)
%27 = load i32*, i32** %6
store i32 %26, i32* %27
ret void
}

LLVM IR (-O2):
define void @_SHIFT_RIGHT_UINT32(i32* nocapture writeonly %0, i32* nocapture %1, i32 %2, i32* nocapture %3, i32 %4) {
%6 = sext i32 %2 to i64
%7 = getelementptr inbounds i32, i32* %1, i64 %6
%8 = getelementptr inbounds i32, i32* %7, i64 -4
%9 = load i32, i32* %8
%10 = tail call i32 @ntohl(i32 %9)
%11 = sext i32 %4 to i64
%12 = getelementptr inbounds i32, i32* %3, i64 %11
%13 = getelementptr inbounds i32, i32* %12, i64 -4
%14 = load i32, i32* %13
%15 = tail call i32 @ntohl(i32 %14)
%16 = ashr i32 %10, %15
%17 = tail call i32 @htonl(i32 %16)
store i32 %17, i32* %0
ret void
}