#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 int64_t;

/* Variables and functions */
void compress_v(int64_t t[1024], int64_t *v) {
  int i;
  int64_t temp;
  for (i = 0; i < 1024; i++) {
    temp = v[i];
    while (temp < 0)
      temp += 8058881;
    while (temp >= 8058881)
      temp -= 8058881;
    t[i] = ((int64_t)(temp)) >> 21;
  }
}


x86 assembly (clang, -O0):
<compress_v>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x400,-0x14(%rbp)
jge    1189 <compress_v+0x89>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1148 <compress_v+0x48>
mov    -0x18(%rbp),%eax
add    $0x7af801,%eax
mov    %eax,-0x18(%rbp)
jmp    112e <compress_v+0x2e>
jmp    114d <compress_v+0x4d>
cmpl   $0x7af801,-0x18(%rbp)
jl     116a <compress_v+0x6a>
mov    -0x18(%rbp),%eax
sub    $0x7af801,%eax
mov    %eax,-0x18(%rbp)
jmp    114d <compress_v+0x4d>
mov    -0x18(%rbp),%edx
sar    $0x15,%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1113 <compress_v+0x13>
pop    %rbp
ret

x86 assembly (clang, -O2):
<compress_v>:
lea    0x1000(%rsi),%rax
cmp    %rdi,%rax
jbe    11a9 <compress_v+0xa9>
lea    0x1000(%rdi),%rax
cmp    %rsi,%rax
jbe    11a9 <compress_v+0xa9>
xor    %r8d,%r8d
jmp    116c <compress_v+0x6c>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ecx,%eax
sub    %edx,%eax
add    $0x7af800,%eax
imul   $0x429e58d9,%rax,%rdx
shr    $0x35,%rdx
imul   $0x7af801,%edx,%r9d
mov    %eax,%edx
sub    %r9d,%edx
sub    %eax,%edx
add    %ecx,%edx
sar    $0x15,%edx
mov    %edx,(%rdi,%r8,4)
add    $0x1,%r8
cmp    $0x400,%r8
je     12c6 <compress_v+0x1c6>
mov    (%rsi,%r8,4),%edx
test   %edx,%edx
mov    $0x0,%ecx
cmovg  %edx,%ecx
xor    %eax,%eax
sub    %edx,%ecx
setne  %al
sub    %eax,%ecx
imul   $0x429e58d9,%rcx,%rcx
shr    $0x35,%rcx
add    %eax,%ecx
imul   $0x7af801,%ecx,%ecx
add    %edx,%ecx
mov    %ecx,%edx
cmp    $0x7af800,%ecx
jl     1130 <compress_v+0x30>
mov    $0x7af800,%edx
jmp    1130 <compress_v+0x30>
xor    %eax,%eax
pxor   %xmm0,%xmm0
pcmpeqd %xmm8,%xmm8
movdqa 0xe44(%rip),%xmm2
movdqa 0xe4c(%rip),%xmm3
movdqa 0xe54(%rip),%xmm4
nopl   0x0(%rax)
movdqu (%rsi,%rax,4),%xmm6
movdqa %xmm6,%xmm5
pcmpgtd %xmm0,%xmm5
pand   %xmm6,%xmm5
psubd  %xmm6,%xmm5
movdqa %xmm5,%xmm7
pcmpeqd %xmm0,%xmm7
pxor   %xmm8,%xmm7
paddd  %xmm7,%xmm5
pshufd $0xf5,%xmm5,%xmm1
pmuludq %xmm2,%xmm5
pshufd $0xed,%xmm5,%xmm5
pmuludq %xmm2,%xmm1
pshufd $0xed,%xmm1,%xmm1
punpckldq %xmm1,%xmm5
psrld  $0x15,%xmm5
psubd  %xmm7,%xmm5
pshufd $0xf5,%xmm5,%xmm1
pmuludq %xmm3,%xmm5
pshufd $0xe8,%xmm5,%xmm5
pmuludq %xmm3,%xmm1
pshufd $0xe8,%xmm1,%xmm1
punpckldq %xmm1,%xmm5
paddd  %xmm6,%xmm5
movdqa %xmm4,%xmm1
pcmpgtd %xmm5,%xmm1
movdqa %xmm5,%xmm6
pand   %xmm1,%xmm6
pandn  %xmm4,%xmm1
por    %xmm6,%xmm1
movdqa %xmm5,%xmm6
psubd  %xmm1,%xmm6
paddd  %xmm4,%xmm6
movdqa %xmm6,%xmm1
pmuludq %xmm2,%xmm1
pshufd $0xed,%xmm1,%xmm1
pshufd $0xf5,%xmm6,%xmm7
pmuludq %xmm2,%xmm7
pshufd $0xed,%xmm7,%xmm7
punpckldq %xmm7,%xmm1
psrld  $0x15,%xmm1
pshufd $0xf5,%xmm1,%xmm7
pmuludq %xmm3,%xmm1
pshufd $0xe8,%xmm1,%xmm1
pmuludq %xmm3,%xmm7
pshufd $0xe8,%xmm7,%xmm7
punpckldq %xmm7,%xmm1
movdqa %xmm6,%xmm7
psubd  %xmm1,%xmm7
psubd  %xmm6,%xmm7
paddd  %xmm5,%xmm7
psrad  $0x15,%xmm7
movdqu %xmm7,(%rdi,%rax,4)
add    $0x4,%rax
cmp    $0x400,%rax
jne    11d0 <compress_v+0xd0>
ret

LLVM IR (-O0):
define void @compress_v(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %5
br label %7
7: ; preds = %36, %2
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 1024
br i1 %9, label %10, label %39
10: ; preds = %7
%11 = load i32*, i32** %4
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %11, i64 %13
%15 = load i32, i32* %14
store i32 %15, i32* %6
br label %16
16: ; preds = %19, %10
%17 = load i32, i32* %6
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 8058881
store i32 %21, i32* %6
br label %16
22: ; preds = %16
br label %23
23: ; preds = %26, %22
%24 = load i32, i32* %6
%25 = icmp sge i32 %24, 8058881
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* %6
%28 = sub nsw i32 %27, 8058881
store i32 %28, i32* %6
br label %23
29: ; preds = %23
%30 = load i32, i32* %6
%31 = ashr i32 %30, 21
%32 = load i32*, i32** %3
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
store i32 %31, i32* %35
br label %36
36: ; preds = %29
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %7
39: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @compress_v(i32* nocapture writeonly %0, i32* nocapture %1) {
%3 = getelementptr i32, i32* %0, i64 1024
%4 = getelementptr i32, i32* %1, i64 1024
%5 = icmp ugt i32* %4, %0
%6 = icmp ugt i32* %3, %1
%7 = and i1 %5, %6
br i1 %7, label %34, label %8
8: ; preds = %2, %8
%9 = phi i64 [ %32, %8 ], [ 0, %2 ]
%10 = getelementptr inbounds i32, i32* %1, i64 %9
%11 = bitcast i32* %10 to <4 x i32>*
%12 = load <4 x i32>, <4 x i32>* %11
%13 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %12, <4 x i32> zeroinitializer)
%14 = sub <4 x i32> %13, %12
%15 = icmp ne <4 x i32> %14, zeroinitializer
%16 = zext <4 x i1> %15 to <4 x i32>
%17 = sub <4 x i32> %14, %16
%18 = udiv <4 x i32> %17, <i32 8058881, i32 8058881, i32 8058881, i32 8058881>
%19 = add nuw nsw <4 x i32> %18, %16
%20 = mul <4 x i32> %19, <i32 8058881, i32 8058881, i32 8058881, i32 8058881>
%21 = add <4 x i32> %12, %20
%22 = add <4 x i32> %12, <i32 8058880, i32 8058880, i32 8058880, i32 8058880>
%23 = add <4 x i32> %22, %20
%24 = call <4 x i32> @llvm.smin.v4i32(<4 x i32> %21, <4 x i32> <i32 8058880, i32 8058880, i32 8058880, i32 8058880>)
%25 = sub <4 x i32> %23, %24
%26 = urem <4 x i32> %25, <i32 8058881, i32 8058881, i32 8058881, i32 8058881>
%27 = sub <4 x i32> %26, %25
%28 = add <4 x i32> %27, %21
%29 = ashr <4 x i32> %28, <i32 21, i32 21, i32 21, i32 21>
%30 = getelementptr inbounds i32, i32* %0, i64 %9
%31 = bitcast i32* %30 to <4 x i32>*
store <4 x i32> %29, <4 x i32>* %31
%32 = add nuw i64 %9, 4
%33 = icmp eq i64 %32, 1024
br i1 %33, label %58, label %8
34: ; preds = %2, %34
%35 = phi i64 [ %56, %34 ], [ 0, %2 ]
%36 = getelementptr inbounds i32, i32* %1, i64 %35
%37 = load i32, i32* %36
%38 = call i32 @llvm.smax.i32(i32 %37, i32 0)
%39 = sub i32 %38, %37
%40 = icmp ne i32 %39, 0
%41 = zext i1 %40 to i32
%42 = sub i32 %39, %41
%43 = udiv i32 %42, 8058881
%44 = add nuw nsw i32 %43, %41
%45 = mul i32 %44, 8058881
%46 = add i32 %37, %45
%47 = add i32 %37, 8058880
%48 = add i32 %47, %45
%49 = call i32 @llvm.smin.i32(i32 %46, i32 8058880)
%50 = sub i32 %48, %49
%51 = urem i32 %50, 8058881
%52 = sub i32 %51, %50
%53 = add i32 %52, %46
%54 = ashr i32 %53, 21
%55 = getelementptr inbounds i32, i32* %0, i64 %35
store i32 %54, i32* %55
%56 = add nuw nsw i64 %35, 1
%57 = icmp eq i64 %56, 1024
br i1 %57, label %58, label %34
58: ; preds = %8, %34
ret void
}