#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 /*<<< orphan*/ Copy(unsigned int *, unsigned int *);
int Degree(unsigned int *);
int /*<<< orphan*/ Initialize(unsigned int *);
int /*<<< orphan*/ RightShift(unsigned int *, int);
void LongRightShift(unsigned a[], int sh) {
  int i, u;
  unsigned temp[500];
  if (sh < 16) {
    RightShift(a, sh);
  } else {
    u = sh / 16;
    sh = sh - u * 16;
    i = Degree(a);
    Initialize(temp);
    while (i >= u) {
      temp[i - u] = a[i];
      i--;
    }
    Copy(temp, a);
    RightShift(a, sh);
  }
}


x86 assembly (clang, -O0):
<LongRightShift>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jge    116d <LongRightShift+0x2d>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <RightShift@plt>
jmp    11f1 <LongRightShift+0xb1>
mov    -0xc(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x14(%rbp),%ecx
shl    $0x4,%ecx
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <Degree@plt>
mov    %eax,-0x10(%rbp)
lea    -0x7f0(%rbp),%rdi
call   1050 <Initialize@plt>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     11d5 <LongRightShift+0x95>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x10(%rbp),%eax
sub    -0x14(%rbp),%eax
cltq
mov    %ecx,-0x7f0(%rbp,%rax,4)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    11a1 <LongRightShift+0x61>
lea    -0x7f0(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <Copy@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <RightShift@plt>
add    $0x7f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LongRightShift>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x7d8,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
cmp    $0xf,%esi
jg     117e <LongRightShift+0x2e>
mov    %r14,%rdi
mov    %ebx,%esi
add    $0x7d8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <RightShift@plt>
mov    %ebx,%ebp
shr    $0x4,%ebp
mov    %ebp,%eax
shl    $0x4,%eax
sub    %eax,%ebx
mov    %r14,%rdi
call   1070 <Degree@plt>
mov    %eax,%r15d
mov    %rsp,%rdi
call   1060 <Initialize@plt>
mov    %r15d,%eax
sub    %ebp,%eax
jl     11c8 <LongRightShift+0x78>
movslq %r15d,%rcx
add    %rax,%rbp
mov    %rcx,%rdx
sub    %rbp,%rdx
lea    (%rsp,%rdx,4),%rdi
sub    %rax,%rcx
lea    (%r14,%rcx,4),%rsi
lea    0x4(,%rax,4),%rdx
call   1050 <memcpy@plt>
mov    %rsp,%rdi
mov    %r14,%rsi
call   1040 <Copy@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <RightShift@plt>
add    $0x7d8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @LongRightShift(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [500 x i32]
store i32* %0, i32** %3
store i32 %1, i32* %4
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 16
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32*, i32** %3
%12 = load i32, i32* %4
%13 = call i32 @RightShift(i32* %11, i32 %12)
br label %49
14: ; preds = %2
%15 = load i32, i32* %4
%16 = sdiv i32 %15, 16
store i32 %16, i32* %6
%17 = load i32, i32* %4
%18 = load i32, i32* %6
%19 = mul nsw i32 %18, 16
%20 = sub nsw i32 %17, %19
store i32 %20, i32* %4
%21 = load i32*, i32** %3
%22 = call i32 @Degree(i32* %21)
store i32 %22, i32* %5
%23 = getelementptr inbounds [500 x i32], [500 x i32]* %7, i64 0, i64 0
%24 = call i32 @Initialize(i32* %23)
br label %25
25: ; preds = %29, %14
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = icmp sge i32 %26, %27
br i1 %28, label %29, label %42
29: ; preds = %25
%30 = load i32*, i32** %3
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = load i32, i32* %33
%35 = load i32, i32* %5
%36 = load i32, i32* %6
%37 = sub nsw i32 %35, %36
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [500 x i32], [500 x i32]* %7, i64 0, i64 %38
store i32 %34, i32* %39
%40 = load i32, i32* %5
%41 = add nsw i32 %40, -1
store i32 %41, i32* %5
br label %25
42: ; preds = %25
%43 = getelementptr inbounds [500 x i32], [500 x i32]* %7, i64 0, i64 0
%44 = load i32*, i32** %3
%45 = call i32 @Copy(i32* %43, i32* %44)
%46 = load i32*, i32** %3
%47 = load i32, i32* %4
%48 = call i32 @RightShift(i32* %46, i32 %47)
br label %49
49: ; preds = %42, %10
ret void
}

LLVM IR (-O2):
define void @LongRightShift(i32* %0, i32 %1) {
%3 = alloca [500 x i32]
%4 = bitcast [500 x i32]* %3 to i8*
%5 = icmp slt i32 %1, 16
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @RightShift(i32* %0, i32 %1)
br label %34
8: ; preds = %2
%9 = lshr i32 %1, 4
%10 = mul nsw i32 %9, -16
%11 = add nsw i32 %10, %1
%12 = tail call i32 @Degree(i32* %0)
%13 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 0
%14 = call i32 @Initialize(i32* %13)
%15 = icmp slt i32 %12, %9
br i1 %15, label %31, label %16
16: ; preds = %8
%17 = sext i32 %12 to i64
%18 = lshr i32 %1, 4
%19 = zext i32 %18 to i64
%20 = sub i32 %12, %9
%21 = zext i32 %20 to i64
%22 = add nuw nsw i64 %19, %21
%23 = sub nsw i64 %17, %22
%24 = getelementptr [500 x i32], [500 x i32]* %3, i64 0, i64 %23
%25 = bitcast i32* %24 to i8*
%26 = sub nsw i64 %17, %21
%27 = getelementptr i32, i32* %0, i64 %26
%28 = bitcast i32* %27 to i8*
%29 = shl nuw nsw i64 %21, 2
%30 = add nuw nsw i64 %29, 4
br label %31
31: ; preds = %16, %8
%32 = call i32 @Copy(i32* %13, i32* %0)
%33 = call i32 @RightShift(i32* %0, i32 %11)
br label %34
34: ; preds = %31, %6
ret void
}