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

/* Variables and functions */
void mpeg2_idct_mmx_init(void) {
  extern uint8_t mpeg2_scan_norm[64];
  extern uint8_t mpeg2_scan_alt[64];
  int i, j;
  for (i = 0; i < 64; i++) {
    j = mpeg2_scan_norm[i];
    mpeg2_scan_norm[i] = (j & 0x38) | ((j & 6) >> 1) | ((j & 1) << 2);
    j = mpeg2_scan_alt[i];
    mpeg2_scan_alt[i] = (j & 0x38) | ((j & 6) >> 1) | ((j & 1) << 2);
  }
}


x86 assembly (clang, -O0):
<mpeg2_idct_mmx_init>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
cmpl   $0x40,-0x4(%rbp)
jge    1199 <mpeg2_idct_mmx_init+0x99>
movslq -0x4(%rbp),%rcx
mov    0x2ec0(%rip),%rax
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
and    $0x38,%edx
mov    -0x8(%rbp),%eax
and    $0x6,%eax
sar    $0x1,%eax
or     %eax,%edx
mov    -0x8(%rbp),%eax
and    $0x1,%eax
shl    $0x2,%eax
or     %eax,%edx
movslq -0x4(%rbp),%rcx
mov    0x2e93(%rip),%rax
mov    %edx,(%rax,%rcx,4)
movslq -0x4(%rbp),%rcx
mov    0x2e8d(%rip),%rax
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
and    $0x38,%edx
mov    -0x8(%rbp),%eax
and    $0x6,%eax
sar    $0x1,%eax
or     %eax,%edx
mov    -0x8(%rbp),%eax
and    $0x1,%eax
shl    $0x2,%eax
or     %eax,%edx
movslq -0x4(%rbp),%rcx
mov    0x2e60(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    110b <mpeg2_idct_mmx_init+0xb>
pop    %rbp
ret

x86 assembly (clang, -O2):
<mpeg2_idct_mmx_init>:
xor    %eax,%eax
mov    0x2ed7(%rip),%rcx
movdqa 0xeef(%rip),%xmm0
movdqa 0xef7(%rip),%xmm1
movdqa 0xeff(%rip),%xmm2
mov    0x2ec0(%rip),%rdx
nopl   0x0(%rax,%rax,1)
movdqa (%rcx,%rax,4),%xmm3
movdqa %xmm3,%xmm4
pand   %xmm0,%xmm4
movdqa %xmm3,%xmm5
psrld  $0x1,%xmm5
pand   %xmm1,%xmm5
por    %xmm4,%xmm5
pslld  $0x2,%xmm3
pand   %xmm2,%xmm3
por    %xmm5,%xmm3
movdqa %xmm3,(%rcx,%rax,4)
movdqa (%rdx,%rax,4),%xmm3
movdqa %xmm3,%xmm4
pand   %xmm0,%xmm4
movdqa %xmm3,%xmm5
psrld  $0x1,%xmm5
pand   %xmm1,%xmm5
por    %xmm4,%xmm5
pslld  $0x2,%xmm3
pand   %xmm2,%xmm3
por    %xmm5,%xmm3
movdqa %xmm3,(%rdx,%rax,4)
add    $0x4,%rax
cmp    $0x40,%rax
jne    1130 <mpeg2_idct_mmx_init+0x30>
ret

LLVM IR (-O0):
@mpeg2_scan_norm = external global [64 x i32]
@mpeg2_scan_alt = external global [64 x i32]
define void @mpeg2_idct_mmx_init() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %41, %0
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 64
br i1 %5, label %6, label %44
6: ; preds = %3
%7 = load i32, i32* %1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [64 x i32], [64 x i32]* @mpeg2_scan_norm, i64 0, i64 %8
%10 = load i32, i32* %9
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = and i32 %11, 56
%13 = load i32, i32* %2
%14 = and i32 %13, 6
%15 = ashr i32 %14, 1
%16 = or i32 %12, %15
%17 = load i32, i32* %2
%18 = and i32 %17, 1
%19 = shl i32 %18, 2
%20 = or i32 %16, %19
%21 = load i32, i32* %1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [64 x i32], [64 x i32]* @mpeg2_scan_norm, i64 0, i64 %22
store i32 %20, i32* %23
%24 = load i32, i32* %1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [64 x i32], [64 x i32]* @mpeg2_scan_alt, i64 0, i64 %25
%27 = load i32, i32* %26
store i32 %27, i32* %2
%28 = load i32, i32* %2
%29 = and i32 %28, 56
%30 = load i32, i32* %2
%31 = and i32 %30, 6
%32 = ashr i32 %31, 1
%33 = or i32 %29, %32
%34 = load i32, i32* %2
%35 = and i32 %34, 1
%36 = shl i32 %35, 2
%37 = or i32 %33, %36
%38 = load i32, i32* %1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [64 x i32], [64 x i32]* @mpeg2_scan_alt, i64 0, i64 %39
store i32 %37, i32* %40
br label %41
41: ; preds = %6
%42 = load i32, i32* %1
%43 = add nsw i32 %42, 1
store i32 %43, i32* %1
br label %3
44: ; preds = %3
ret void
}

LLVM IR (-O2):
@mpeg2_scan_norm = external global [64 x i32]
@mpeg2_scan_alt = external global [64 x i32]
define void @mpeg2_idct_mmx_init() {
br label %1
1: ; preds = %1, %0
%2 = phi i64 [ 0, %0 ], [ %25, %1 ]
%3 = getelementptr inbounds [64 x i32], [64 x i32]* @mpeg2_scan_norm, i64 0, i64 %2
%4 = bitcast i32* %3 to <4 x i32>*
%5 = load <4 x i32>, <4 x i32>* %4
%6 = and <4 x i32> %5, <i32 56, i32 56, i32 56, i32 56>
%7 = lshr <4 x i32> %5, <i32 1, i32 1, i32 1, i32 1>
%8 = and <4 x i32> %7, <i32 3, i32 3, i32 3, i32 3>
%9 = or <4 x i32> %8, %6
%10 = shl <4 x i32> %5, <i32 2, i32 2, i32 2, i32 2>
%11 = and <4 x i32> %10, <i32 4, i32 4, i32 4, i32 4>
%12 = or <4 x i32> %9, %11
%13 = bitcast i32* %3 to <4 x i32>*
store <4 x i32> %12, <4 x i32>* %13
%14 = getelementptr inbounds [64 x i32], [64 x i32]* @mpeg2_scan_alt, i64 0, i64 %2
%15 = bitcast i32* %14 to <4 x i32>*
%16 = load <4 x i32>, <4 x i32>* %15
%17 = and <4 x i32> %16, <i32 56, i32 56, i32 56, i32 56>
%18 = lshr <4 x i32> %16, <i32 1, i32 1, i32 1, i32 1>
%19 = and <4 x i32> %18, <i32 3, i32 3, i32 3, i32 3>
%20 = or <4 x i32> %19, %17
%21 = shl <4 x i32> %16, <i32 2, i32 2, i32 2, i32 2>
%22 = and <4 x i32> %21, <i32 4, i32 4, i32 4, i32 4>
%23 = or <4 x i32> %20, %22
%24 = bitcast i32* %14 to <4 x i32>*
store <4 x i32> %23, <4 x i32>* %24
%25 = add nuw i64 %2, 4
%26 = icmp eq i64 %25, 64
br i1 %26, label %27, label %1
27: ; preds = %1
ret void
}