#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 */
int /*<<< orphan*/ memset(int *, int, int);
void _comp128_permutation(uint8_t *x, uint8_t *bits) {
  int i;
  memset(&x[16], 0x00, 16);
  for (i = 0; i < 128; i++)
    x[(i >> 3) + 16] |= bits[(i * 17) & 127] << (7 - (i & 7));
}


x86 assembly (clang, -O0):
<_comp128_permutation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x40,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x80,-0x14(%rbp)
jge    118c <_comp128_permutation+0x7c>
mov    -0x10(%rbp),%rax
imul   $0x11,-0x14(%rbp),%ecx
and    $0x7f,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x14(%rbp),%eax
and    $0x7,%eax
mov    $0x7,%ecx
sub    %eax,%ecx
shl    %cl,%edx
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sar    $0x3,%ecx
add    $0x10,%ecx
movslq %ecx,%rcx
or     (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113b <_comp128_permutation+0x2b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_comp128_permutation>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
add    $0x40,%rdi
xor    %ebp,%ebp
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
mov    $0x11,%edx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    -0x11(%rdx),%eax
and    $0x7e,%eax
mov    (%r14,%rax,4),%esi
mov    %ebp,%eax
and    $0x6,%al
mov    %eax,%ecx
xor    $0x7,%cl
shl    %cl,%esi
mov    %ebp,%edi
shr    $0x3,%edi
or     0x40(%r15,%rdi,4),%esi
mov    %esi,0x40(%r15,%rdi,4)
mov    %edx,%ecx
and    $0x7f,%ecx
mov    (%r14,%rcx,4),%ebx
xor    $0x6,%al
mov    %eax,%ecx
shl    %cl,%ebx
or     %esi,%ebx
mov    %ebx,0x40(%r15,%rdi,4)
add    $0x2,%ebp
add    $0x22,%edx
cmp    $0x80,%ebp
jne    1140 <_comp128_permutation+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @_comp128_permutation(i32* %0, i32* nocapture %1) {
%3 = getelementptr inbounds i32, i32* %0, i64 16
%4 = tail call i32 @memset(i32* %3, i32 0, i32 16)
br label %5
5: ; preds = %5, %2
%6 = phi i32 [ 0, %2 ], [ %36, %5 ]
%7 = mul nuw nsw i32 %6, 17
%8 = and i32 %7, 126
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds i32, i32* %1, i64 %9
%11 = load i32, i32* %10
%12 = and i32 %6, 6
%13 = xor i32 %12, 7
%14 = shl i32 %11, %13
%15 = lshr i32 %6, 3
%16 = add nuw nsw i32 %15, 16
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %0, i64 %17
%19 = load i32, i32* %18
%20 = or i32 %19, %14
store i32 %20, i32* %18
%21 = or i32 %6, 1
%22 = mul nuw nsw i32 %21, 17
%23 = and i32 %22, 127
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %1, i64 %24
%26 = load i32, i32* %25
%27 = and i32 %6, 6
%28 = xor i32 %27, 6
%29 = shl i32 %26, %28
%30 = lshr i32 %6, 3
%31 = add nuw nsw i32 %30, 16
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %0, i64 %32
%34 = load i32, i32* %33
%35 = or i32 %34, %29
store i32 %35, i32* %33
%36 = add nuw nsw i32 %6, 2
%37 = icmp eq i32 %36, 128
br i1 %37, label %38, label %5
38: ; preds = %5
ret void
}