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

/* Variables and functions */
int encode_packchar(char const);
uint32_t pack_chars(const char *str) {
  const char *pos = (str + 5);
  return ((encode_packchar(*pos) << 1) ^
          (encode_packchar(*(pos - 1)) << (1 + (5 * 1))) ^
          (encode_packchar(*(pos - 2)) << (1 + (5 * 2))) ^
          (encode_packchar(*(pos - 3)) << (1 + (5 * 3))) ^
          (encode_packchar(*(pos - 4)) << (1 + (5 * 4))) ^
          (encode_packchar(*(pos - 5)) << (1 + (5 * 5))));
}


x86 assembly (clang, -O0):
<pack_chars>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <encode_packchar@plt>
shl    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movsbl -0x1(%rax),%edi
call   1030 <encode_packchar@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
shl    $0x6,%ecx
xor    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsbl -0x2(%rax),%edi
call   1030 <encode_packchar@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
shl    $0xb,%ecx
xor    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movsbl -0x3(%rax),%edi
call   1030 <encode_packchar@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
shl    $0x10,%ecx
xor    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl -0x4(%rax),%edi
call   1030 <encode_packchar@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
shl    $0x15,%ecx
xor    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl -0x5(%rax),%edi
call   1030 <encode_packchar@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
shl    $0x1a,%ecx
xor    %ecx,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pack_chars>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
movsbl 0x5(%rdi),%edi
call   1030 <encode_packchar@plt>
mov    %eax,%ebp
add    %eax,%ebp
movsbl 0x4(%r14),%edi
call   1030 <encode_packchar@plt>
mov    %eax,%ebx
shl    $0x6,%ebx
xor    %ebp,%ebx
movsbl 0x3(%r14),%edi
call   1030 <encode_packchar@plt>
mov    %eax,%r15d
shl    $0xb,%r15d
movsbl 0x2(%r14),%edi
call   1030 <encode_packchar@plt>
mov    %eax,%ebp
shl    $0x10,%ebp
xor    %r15d,%ebp
xor    %ebx,%ebp
movsbl 0x1(%r14),%edi
call   1030 <encode_packchar@plt>
mov    %eax,%ebx
shl    $0x15,%ebx
movsbl (%r14),%edi
call   1030 <encode_packchar@plt>
shl    $0x1a,%eax
xor    %ebx,%eax
xor    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @pack_chars(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = getelementptr inbounds i8, i8* %4, i64 5
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = call i32 @encode_packchar(i8 signext %7)
%9 = shl i32 %8, 1
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 -1
%12 = load i8, i8* %11
%13 = call i32 @encode_packchar(i8 signext %12)
%14 = shl i32 %13, 6
%15 = xor i32 %9, %14
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 -2
%18 = load i8, i8* %17
%19 = call i32 @encode_packchar(i8 signext %18)
%20 = shl i32 %19, 11
%21 = xor i32 %15, %20
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i64 -3
%24 = load i8, i8* %23
%25 = call i32 @encode_packchar(i8 signext %24)
%26 = shl i32 %25, 16
%27 = xor i32 %21, %26
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i64 -4
%30 = load i8, i8* %29
%31 = call i32 @encode_packchar(i8 signext %30)
%32 = shl i32 %31, 21
%33 = xor i32 %27, %32
%34 = load i8*, i8** %3
%35 = getelementptr inbounds i8, i8* %34, i64 -5
%36 = load i8, i8* %35
%37 = call i32 @encode_packchar(i8 signext %36)
%38 = shl i32 %37, 26
%39 = xor i32 %33, %38
ret i32 %39
}

LLVM IR (-O2):
define i32 @pack_chars(i8* nocapture %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 5
%3 = load i8, i8* %2
%4 = tail call i32 @encode_packchar(i8 signext %3)
%5 = shl i32 %4, 1
%6 = getelementptr inbounds i8, i8* %0, i64 4
%7 = load i8, i8* %6
%8 = tail call i32 @encode_packchar(i8 signext %7)
%9 = shl i32 %8, 6
%10 = xor i32 %9, %5
%11 = getelementptr inbounds i8, i8* %0, i64 3
%12 = load i8, i8* %11
%13 = tail call i32 @encode_packchar(i8 signext %12)
%14 = shl i32 %13, 11
%15 = xor i32 %10, %14
%16 = getelementptr inbounds i8, i8* %0, i64 2
%17 = load i8, i8* %16
%18 = tail call i32 @encode_packchar(i8 signext %17)
%19 = shl i32 %18, 16
%20 = xor i32 %15, %19
%21 = getelementptr inbounds i8, i8* %0, i64 1
%22 = load i8, i8* %21
%23 = tail call i32 @encode_packchar(i8 signext %22)
%24 = shl i32 %23, 21
%25 = xor i32 %20, %24
%26 = load i8, i8* %0
%27 = tail call i32 @encode_packchar(i8 signext %26)
%28 = shl i32 %27, 26
%29 = xor i32 %25, %28
ret i32 %29
}