#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 */
unsigned char onion_char(unsigned char const);
void onion_encode_block(unsigned char *dst, const unsigned char *src) {
  dst[0] = onion_char(src[0] >> 3);
  dst[1] = onion_char(src[0] << 2 | src[1] >> 6);
  dst[2] = onion_char(src[1] >> 1);
  dst[3] = onion_char(src[1] << 4 | src[2] >> 4);
  dst[4] = onion_char(src[2] << 1 | src[3] >> 7);
  dst[5] = onion_char(src[3] >> 2);
  dst[6] = onion_char(src[3] << 3 | src[4] >> 5);
  dst[7] = onion_char(src[4]);
}


x86 assembly (clang, -O0):
<onion_encode_block>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
sar    $0x3,%eax
movzbl %al,%edi
call   1030 <onion_char@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
shl    $0x2,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
sar    $0x6,%ecx
or     %ecx,%eax
movzbl %al,%edi
call   1030 <onion_char@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x10(%rbp),%rax
movzbl 0x1(%rax),%eax
sar    $0x1,%eax
movzbl %al,%edi
call   1030 <onion_char@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x10(%rbp),%rax
movzbl 0x1(%rax),%eax
shl    $0x4,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x2(%rcx),%ecx
sar    $0x4,%ecx
or     %ecx,%eax
movzbl %al,%edi
call   1030 <onion_char@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%eax
shl    $0x1,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
sar    $0x7,%ecx
or     %ecx,%eax
movzbl %al,%edi
call   1030 <onion_char@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%eax
sar    $0x2,%eax
movzbl %al,%edi
call   1030 <onion_char@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%eax
shl    $0x3,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x4(%rcx),%ecx
sar    $0x5,%ecx
or     %ecx,%eax
movzbl %al,%edi
call   1030 <onion_char@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x6(%rax)
mov    -0x10(%rbp),%rax
movzbl 0x4(%rax),%edi
call   1030 <onion_char@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x7(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<onion_encode_block>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rsi),%al
shr    $0x3,%al
movzbl %al,%edi
call   1030 <onion_char@plt>
mov    %al,(%r14)
mov    (%rbx),%al
mov    0x1(%rbx),%cl
shr    $0x6,%cl
shl    $0x2,%al
or     %cl,%al
movzbl %al,%edi
call   1030 <onion_char@plt>
mov    %al,0x1(%r14)
mov    0x1(%rbx),%al
shr    %al
movzbl %al,%edi
call   1030 <onion_char@plt>
mov    %al,0x2(%r14)
mov    0x1(%rbx),%al
mov    0x2(%rbx),%cl
shr    $0x4,%cl
shl    $0x4,%al
or     %cl,%al
movzbl %al,%edi
call   1030 <onion_char@plt>
mov    %al,0x3(%r14)
mov    0x2(%rbx),%al
mov    0x3(%rbx),%cl
shr    $0x7,%cl
add    %al,%al
or     %cl,%al
movzbl %al,%edi
call   1030 <onion_char@plt>
mov    %al,0x4(%r14)
mov    0x3(%rbx),%al
shr    $0x2,%al
movzbl %al,%edi
call   1030 <onion_char@plt>
mov    %al,0x5(%r14)
mov    0x3(%rbx),%al
mov    0x4(%rbx),%cl
shr    $0x5,%cl
shl    $0x3,%al
or     %cl,%al
movzbl %al,%edi
call   1030 <onion_char@plt>
mov    %al,0x6(%r14)
movzbl 0x4(%rbx),%edi
call   1030 <onion_char@plt>
mov    %al,0x7(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @onion_encode_block(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = zext i8 %7 to i32
%9 = ashr i32 %8, 3
%10 = trunc i32 %9 to i8
%11 = call zeroext i8 @onion_char(i8 zeroext %10)
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 0
store i8 %11, i8* %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 = shl i32 %17, 2
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = ashr i32 %22, 6
%24 = or i32 %18, %23
%25 = trunc i32 %24 to i8
%26 = call zeroext i8 @onion_char(i8 zeroext %25)
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 1
store i8 %26, i8* %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 = ashr i32 %32, 1
%34 = trunc i32 %33 to i8
%35 = call zeroext i8 @onion_char(i8 zeroext %34)
%36 = load i8*, i8** %3
%37 = getelementptr inbounds i8, i8* %36, i64 2
store i8 %35, i8* %37
%38 = load i8*, i8** %4
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = shl i32 %41, 4
%43 = load i8*, i8** %4
%44 = getelementptr inbounds i8, i8* %43, i64 2
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = ashr i32 %46, 4
%48 = or i32 %42, %47
%49 = trunc i32 %48 to i8
%50 = call zeroext i8 @onion_char(i8 zeroext %49)
%51 = load i8*, i8** %3
%52 = getelementptr inbounds i8, i8* %51, i64 3
store i8 %50, i8* %52
%53 = load i8*, i8** %4
%54 = getelementptr inbounds i8, i8* %53, i64 2
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = shl i32 %56, 1
%58 = load i8*, i8** %4
%59 = getelementptr inbounds i8, i8* %58, i64 3
%60 = load i8, i8* %59
%61 = zext i8 %60 to i32
%62 = ashr i32 %61, 7
%63 = or i32 %57, %62
%64 = trunc i32 %63 to i8
%65 = call zeroext i8 @onion_char(i8 zeroext %64)
%66 = load i8*, i8** %3
%67 = getelementptr inbounds i8, i8* %66, i64 4
store i8 %65, i8* %67
%68 = load i8*, i8** %4
%69 = getelementptr inbounds i8, i8* %68, i64 3
%70 = load i8, i8* %69
%71 = zext i8 %70 to i32
%72 = ashr i32 %71, 2
%73 = trunc i32 %72 to i8
%74 = call zeroext i8 @onion_char(i8 zeroext %73)
%75 = load i8*, i8** %3
%76 = getelementptr inbounds i8, i8* %75, i64 5
store i8 %74, i8* %76
%77 = load i8*, i8** %4
%78 = getelementptr inbounds i8, i8* %77, i64 3
%79 = load i8, i8* %78
%80 = zext i8 %79 to i32
%81 = shl i32 %80, 3
%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 = ashr i32 %85, 5
%87 = or i32 %81, %86
%88 = trunc i32 %87 to i8
%89 = call zeroext i8 @onion_char(i8 zeroext %88)
%90 = load i8*, i8** %3
%91 = getelementptr inbounds i8, i8* %90, i64 6
store i8 %89, i8* %91
%92 = load i8*, i8** %4
%93 = getelementptr inbounds i8, i8* %92, i64 4
%94 = load i8, i8* %93
%95 = call zeroext i8 @onion_char(i8 zeroext %94)
%96 = load i8*, i8** %3
%97 = getelementptr inbounds i8, i8* %96, i64 7
store i8 %95, i8* %97
ret void
}

LLVM IR (-O2):
define void @onion_encode_block(i8* nocapture writeonly %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = lshr i8 %3, 3
%5 = tail call zeroext i8 @onion_char(i8 zeroext %4)
store i8 %5, i8* %0
%6 = load i8, i8* %1
%7 = getelementptr inbounds i8, i8* %1, i64 1
%8 = load i8, i8* %7
%9 = tail call i8 @llvm.fshl.i8(i8 %6, i8 %8, i8 2)
%10 = tail call zeroext i8 @onion_char(i8 zeroext %9)
%11 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %10, i8* %11
%12 = load i8, i8* %7
%13 = lshr i8 %12, 1
%14 = tail call zeroext i8 @onion_char(i8 zeroext %13)
%15 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %14, i8* %15
%16 = load i8, i8* %7
%17 = getelementptr inbounds i8, i8* %1, i64 2
%18 = load i8, i8* %17
%19 = tail call i8 @llvm.fshl.i8(i8 %16, i8 %18, i8 4)
%20 = tail call zeroext i8 @onion_char(i8 zeroext %19)
%21 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %20, i8* %21
%22 = load i8, i8* %17
%23 = getelementptr inbounds i8, i8* %1, i64 3
%24 = load i8, i8* %23
%25 = tail call i8 @llvm.fshl.i8(i8 %22, i8 %24, i8 1)
%26 = tail call zeroext i8 @onion_char(i8 zeroext %25)
%27 = getelementptr inbounds i8, i8* %0, i64 4
store i8 %26, i8* %27
%28 = load i8, i8* %23
%29 = lshr i8 %28, 2
%30 = tail call zeroext i8 @onion_char(i8 zeroext %29)
%31 = getelementptr inbounds i8, i8* %0, i64 5
store i8 %30, i8* %31
%32 = load i8, i8* %23
%33 = getelementptr inbounds i8, i8* %1, i64 4
%34 = load i8, i8* %33
%35 = tail call i8 @llvm.fshl.i8(i8 %32, i8 %34, i8 3)
%36 = tail call zeroext i8 @onion_char(i8 zeroext %35)
%37 = getelementptr inbounds i8, i8* %0, i64 6
store i8 %36, i8* %37
%38 = load i8, i8* %33
%39 = tail call zeroext i8 @onion_char(i8 zeroext %38)
%40 = getelementptr inbounds i8, i8* %0, i64 7
store i8 %39, i8* %40
ret void
}