#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 compute_quantization(int);
void compressed_parse_medians(unsigned char *medians_header, int *quantizations,
                              int *medians) {
  medians[0] = (int)medians_header[0] & 0x3f;
  quantizations[0] =
      (int)((medians_header[0] & 0xC0) >> 6 | (medians_header[1] & 0x03) << 2);
  medians[1] = (int)(medians_header[1] & 0xfc) >> 2;
  quantizations[1] = (int)(medians_header[2] & 0x0f);
  medians[2] =
      (int)((medians_header[2] & 0xf0) >> 4 | (medians_header[3] & 0x03) << 4);
  quantizations[2] = (int)(medians_header[3] & 0x3c) >> 2;
  medians[3] =
      (int)((medians_header[3] & 0xc0) >> 6 | (medians_header[4] & 0x0f) << 2);
  quantizations[3] = (int)(medians_header[4] & 0xf0) >> 4;
  quantizations[0] = compute_quantization(quantizations[0]);
  quantizations[1] = compute_quantization(quantizations[1]);
  quantizations[2] = compute_quantization(quantizations[2]);
  quantizations[3] = compute_quantization(quantizations[3]);
}


x86 assembly (clang, -O0):
<compressed_parse_medians>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%ecx
and    $0x3f,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
movzbl (%rax),%ecx
and    $0xc0,%ecx
sar    $0x6,%ecx
mov    -0x8(%rbp),%rax
movzbl 0x1(%rax),%eax
and    $0x3,%eax
shl    $0x2,%eax
or     %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
movzbl 0x1(%rax),%ecx
and    $0xfc,%ecx
sar    $0x2,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x8(%rbp),%rax
movzbl 0x2(%rax),%ecx
and    $0xf,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x8(%rbp),%rax
movzbl 0x2(%rax),%ecx
and    $0xf0,%ecx
sar    $0x4,%ecx
mov    -0x8(%rbp),%rax
movzbl 0x3(%rax),%eax
and    $0x3,%eax
shl    $0x4,%eax
or     %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x8(%rbp),%rax
movzbl 0x3(%rax),%ecx
and    $0x3c,%ecx
sar    $0x2,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x8(%rbp),%rax
movzbl 0x3(%rax),%ecx
and    $0xc0,%ecx
sar    $0x6,%ecx
mov    -0x8(%rbp),%rax
movzbl 0x4(%rax),%eax
and    $0xf,%eax
shl    $0x2,%eax
or     %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x8(%rbp),%rax
movzbl 0x4(%rax),%ecx
and    $0xf0,%ecx
sar    $0x4,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1030 <compute_quantization@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edi
call   1030 <compute_quantization@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%edi
call   1030 <compute_quantization@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%edi
call   1030 <compute_quantization@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0xc(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compressed_parse_medians>:
push   %rbx
mov    %rsi,%rbx
movzbl (%rdi),%eax
and    $0x3f,%eax
mov    %eax,(%rdx)
movzbl (%rdi),%eax
shr    $0x6,%eax
movzbl 0x1(%rdi),%ecx
and    $0x3,%ecx
lea    (%rax,%rcx,4),%eax
mov    %eax,(%rsi)
movzbl 0x1(%rdi),%eax
shr    $0x2,%eax
mov    %eax,0x4(%rdx)
movzbl 0x2(%rdi),%eax
and    $0xf,%eax
mov    %eax,0x4(%rsi)
movzbl 0x2(%rdi),%eax
shr    $0x4,%eax
movzbl 0x3(%rdi),%ecx
shl    $0x4,%ecx
and    $0x30,%ecx
or     %eax,%ecx
mov    %ecx,0x8(%rdx)
movzbl 0x3(%rdi),%eax
shr    $0x2,%eax
and    $0xf,%eax
mov    %eax,0x8(%rsi)
movzbl 0x3(%rdi),%eax
shr    $0x6,%eax
movzbl 0x4(%rdi),%ecx
and    $0xf,%ecx
lea    (%rax,%rcx,4),%eax
mov    %eax,0xc(%rdx)
movzbl 0x4(%rdi),%eax
shr    $0x4,%eax
mov    %eax,0xc(%rsi)
mov    (%rsi),%edi
call   1030 <compute_quantization@plt>
mov    %eax,(%rbx)
mov    0x4(%rbx),%edi
call   1030 <compute_quantization@plt>
mov    %eax,0x4(%rbx)
mov    0x8(%rbx),%edi
call   1030 <compute_quantization@plt>
mov    %eax,0x8(%rbx)
mov    0xc(%rbx),%edi
call   1030 <compute_quantization@plt>
mov    %eax,0xc(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @compressed_parse_medians(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%7 = load i8*, i8** %4
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = zext i8 %9 to i32
%11 = and i32 %10, 63
%12 = load i32*, i32** %6
%13 = getelementptr inbounds i32, i32* %12, i64 0
store i32 %11, i32* %13
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = and i32 %17, 192
%19 = ashr i32 %18, 6
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = and i32 %23, 3
%25 = shl i32 %24, 2
%26 = or i32 %19, %25
%27 = load i32*, i32** %5
%28 = getelementptr inbounds i32, i32* %27, i64 0
store i32 %26, i32* %28
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = and i32 %32, 252
%34 = ashr i32 %33, 2
%35 = load i32*, i32** %6
%36 = getelementptr inbounds i32, i32* %35, i64 1
store i32 %34, i32* %36
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i64 2
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = and i32 %40, 15
%42 = load i32*, i32** %5
%43 = getelementptr inbounds i32, i32* %42, i64 1
store i32 %41, i32* %43
%44 = load i8*, i8** %4
%45 = getelementptr inbounds i8, i8* %44, i64 2
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
%48 = and i32 %47, 240
%49 = ashr i32 %48, 4
%50 = load i8*, i8** %4
%51 = getelementptr inbounds i8, i8* %50, i64 3
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
%54 = and i32 %53, 3
%55 = shl i32 %54, 4
%56 = or i32 %49, %55
%57 = load i32*, i32** %6
%58 = getelementptr inbounds i32, i32* %57, i64 2
store i32 %56, i32* %58
%59 = load i8*, i8** %4
%60 = getelementptr inbounds i8, i8* %59, i64 3
%61 = load i8, i8* %60
%62 = zext i8 %61 to i32
%63 = and i32 %62, 60
%64 = ashr i32 %63, 2
%65 = load i32*, i32** %5
%66 = getelementptr inbounds i32, i32* %65, i64 2
store i32 %64, i32* %66
%67 = load i8*, i8** %4
%68 = getelementptr inbounds i8, i8* %67, i64 3
%69 = load i8, i8* %68
%70 = zext i8 %69 to i32
%71 = and i32 %70, 192
%72 = ashr i32 %71, 6
%73 = load i8*, i8** %4
%74 = getelementptr inbounds i8, i8* %73, i64 4
%75 = load i8, i8* %74
%76 = zext i8 %75 to i32
%77 = and i32 %76, 15
%78 = shl i32 %77, 2
%79 = or i32 %72, %78
%80 = load i32*, i32** %6
%81 = getelementptr inbounds i32, i32* %80, i64 3
store i32 %79, i32* %81
%82 = load i8*, i8** %4
%83 = getelementptr inbounds i8, i8* %82, i64 4
%84 = load i8, i8* %83
%85 = zext i8 %84 to i32
%86 = and i32 %85, 240
%87 = ashr i32 %86, 4
%88 = load i32*, i32** %5
%89 = getelementptr inbounds i32, i32* %88, i64 3
store i32 %87, i32* %89
%90 = load i32*, i32** %5
%91 = getelementptr inbounds i32, i32* %90, i64 0
%92 = load i32, i32* %91
%93 = call i32 @compute_quantization(i32 %92)
%94 = load i32*, i32** %5
%95 = getelementptr inbounds i32, i32* %94, i64 0
store i32 %93, i32* %95
%96 = load i32*, i32** %5
%97 = getelementptr inbounds i32, i32* %96, i64 1
%98 = load i32, i32* %97
%99 = call i32 @compute_quantization(i32 %98)
%100 = load i32*, i32** %5
%101 = getelementptr inbounds i32, i32* %100, i64 1
store i32 %99, i32* %101
%102 = load i32*, i32** %5
%103 = getelementptr inbounds i32, i32* %102, i64 2
%104 = load i32, i32* %103
%105 = call i32 @compute_quantization(i32 %104)
%106 = load i32*, i32** %5
%107 = getelementptr inbounds i32, i32* %106, i64 2
store i32 %105, i32* %107
%108 = load i32*, i32** %5
%109 = getelementptr inbounds i32, i32* %108, i64 3
%110 = load i32, i32* %109
%111 = call i32 @compute_quantization(i32 %110)
%112 = load i32*, i32** %5
%113 = getelementptr inbounds i32, i32* %112, i64 3
store i32 %111, i32* %113
ret void
}

LLVM IR (-O2):
define void @compressed_parse_medians(i8* nocapture %0, i32* nocapture %1, i32* nocapture writeonly %2) {
%4 = load i8, i8* %0
%5 = and i8 %4, 63
%6 = zext i8 %5 to i32
store i32 %6, i32* %2
%7 = load i8, i8* %0
%8 = lshr i8 %7, 6
%9 = getelementptr inbounds i8, i8* %0, i64 1
%10 = load i8, i8* %9
%11 = shl i8 %10, 2
%12 = and i8 %11, 12
%13 = or i8 %12, %8
%14 = zext i8 %13 to i32
store i32 %14, i32* %1
%15 = load i8, i8* %9
%16 = lshr i8 %15, 2
%17 = zext i8 %16 to i32
%18 = getelementptr inbounds i32, i32* %2, i64 1
store i32 %17, i32* %18
%19 = getelementptr inbounds i8, i8* %0, i64 2
%20 = load i8, i8* %19
%21 = and i8 %20, 15
%22 = zext i8 %21 to i32
%23 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %22, i32* %23
%24 = load i8, i8* %19
%25 = lshr i8 %24, 4
%26 = getelementptr inbounds i8, i8* %0, i64 3
%27 = load i8, i8* %26
%28 = shl i8 %27, 4
%29 = and i8 %28, 48
%30 = or i8 %29, %25
%31 = zext i8 %30 to i32
%32 = getelementptr inbounds i32, i32* %2, i64 2
store i32 %31, i32* %32
%33 = load i8, i8* %26
%34 = lshr i8 %33, 2
%35 = and i8 %34, 15
%36 = zext i8 %35 to i32
%37 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %36, i32* %37
%38 = load i8, i8* %26
%39 = lshr i8 %38, 6
%40 = getelementptr inbounds i8, i8* %0, i64 4
%41 = load i8, i8* %40
%42 = shl i8 %41, 2
%43 = and i8 %42, 60
%44 = or i8 %43, %39
%45 = zext i8 %44 to i32
%46 = getelementptr inbounds i32, i32* %2, i64 3
store i32 %45, i32* %46
%47 = load i8, i8* %40
%48 = lshr i8 %47, 4
%49 = zext i8 %48 to i32
%50 = getelementptr inbounds i32, i32* %1, i64 3
store i32 %49, i32* %50
%51 = load i32, i32* %1
%52 = tail call i32 @compute_quantization(i32 %51)
store i32 %52, i32* %1
%53 = load i32, i32* %23
%54 = tail call i32 @compute_quantization(i32 %53)
store i32 %54, i32* %23
%55 = load i32, i32* %37
%56 = tail call i32 @compute_quantization(i32 %55)
store i32 %56, i32* %37
%57 = load i32, i32* %50
%58 = tail call i32 @compute_quantization(i32 %57)
store i32 %58, i32* %50
ret void
}