#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 /*<<< orphan*/ printbinary(unsigned char);
void cutarray(unsigned char *value, int amount, int shift, int cut) {
  unsigned char full = 0xFF;
  unsigned char zero = 0x00;
  unsigned char part = 0x3F;
  for (int i = 0; i < cut / 8; i++)
    printbinary((value[i + (shift / 8)] << (shift % 8)) |
                (value[i + (shift / 8) + 1] >> 8 - (shift % 8)));
  printbinary(((value[(cut / 8) + (shift / 8)] << (shift % 8)) |
               (value[(cut / 8) + (shift / 8) + 1] >> 8 - (shift % 8))) &
              (0xFF << 8 - (cut % 8)));
}


x86 assembly (clang, -O0):
<cutarray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movb   $0xff,-0x15(%rbp)
movb   $0x0,-0x16(%rbp)
movb   $0x3f,-0x17(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    11f4 <cutarray+0xe4>
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%eax
mov    $0x8,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0x40(%rbp),%rax
add    %edx,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0x34(%rbp),%eax
mov    %edx,%ecx
shl    %cl,%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%eax
mov    $0x8,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0x30(%rbp),%rax
add    %edx,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0x28(%rbp),%eax
mov    %edx,%esi
mov    -0x24(%rbp),%edx
mov    $0x8,%ecx
sub    %esi,%ecx
sar    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
movzbl %al,%edi
call   1030 <printbinary@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1138 <cutarray+0x28>
mov    -0x8(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
mov    $0x8,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0x68(%rbp),%rax
add    %edx,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0x5c(%rbp),%eax
mov    %edx,%ecx
shl    %cl,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
mov    $0x8,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0x58(%rbp),%rax
add    %edx,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x48(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0x4c(%rbp),%eax
mov    %edx,%esi
mov    -0x48(%rbp),%edx
mov    $0x8,%ecx
sub    %esi,%ecx
sar    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x44(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0x44(%rbp),%eax
mov    $0x8,%ecx
sub    %edx,%ecx
mov    $0xff,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
movzbl %al,%edi
call   1030 <printbinary@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cutarray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebx
mov    %rdi,0x10(%rsp)
lea    0x7(%rcx),%eax
test   %ecx,%ecx
cmovns %ecx,%eax
mov    %eax,%r12d
sar    $0x3,%r12d
and    $0xfffffff8,%eax
mov    %ecx,%edx
sub    %eax,%edx
mov    %edx,0xc(%rsp)
lea    0x7(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
mov    %eax,%edx
sar    $0x3,%edx
mov    %edx,0x8(%rsp)
and    $0xfffffff8,%eax
sub    %eax,%ebx
mov    $0x8,%ebp
sub    %ebx,%ebp
cmp    $0x8,%ecx
jl     11a6 <cutarray+0x96>
movslq 0x8(%rsp),%rax
mov    %r12d,%r14d
mov    0x10(%rsp),%rcx
lea    (%rax,%rcx,1),%r15
add    $0x1,%r15
xor    %r13d,%r13d
nopl   0x0(%rax)
movzbl -0x1(%r15,%r13,1),%eax
mov    %ebx,%ecx
shl    %cl,%eax
movzbl (%r15,%r13,1),%edx
mov    %ebp,%ecx
shr    %cl,%edx
or     %eax,%edx
movzbl %dl,%edi
call   1030 <printbinary@plt>
add    $0x1,%r13
cmp    %r13,%r14
jne    1180 <cutarray+0x70>
add    0x8(%rsp),%r12d
movslq %r12d,%rax
mov    0x10(%rsp),%rsi
movzbl (%rsi,%rax,1),%edx
mov    %ebx,%ecx
shl    %cl,%edx
movzbl 0x1(%rsi,%rax,1),%eax
mov    %ebp,%ecx
shr    %cl,%eax
mov    $0x8,%cl
sub    0xc(%rsp),%cl
mov    $0xff,%esi
shl    %cl,%esi
or     %edx,%eax
and    %eax,%esi
movzbl %sil,%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printbinary@plt>

LLVM IR (-O0):
define void @cutarray(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8
%12 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i8 -1, i8* %9
store i8 0, i8* %10
store i8 63, i8* %11
store i32 0, i32* %12
br label %13
13: ; preds = %48, %4
%14 = load i32, i32* %12
%15 = load i32, i32* %8
%16 = sdiv i32 %15, 8
%17 = icmp slt i32 %14, %16
br i1 %17, label %18, label %51
18: ; preds = %13
%19 = load i8*, i8** %5
%20 = load i32, i32* %12
%21 = load i32, i32* %7
%22 = sdiv i32 %21, 8
%23 = add nsw i32 %20, %22
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %19, i64 %24
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = load i32, i32* %7
%29 = srem i32 %28, 8
%30 = shl i32 %27, %29
%31 = load i8*, i8** %5
%32 = load i32, i32* %12
%33 = load i32, i32* %7
%34 = sdiv i32 %33, 8
%35 = add nsw i32 %32, %34
%36 = add nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %31, i64 %37
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = load i32, i32* %7
%42 = srem i32 %41, 8
%43 = sub nsw i32 8, %42
%44 = ashr i32 %40, %43
%45 = or i32 %30, %44
%46 = trunc i32 %45 to i8
%47 = call i32 @printbinary(i8 zeroext %46)
br label %48
48: ; preds = %18
%49 = load i32, i32* %12
%50 = add nsw i32 %49, 1
store i32 %50, i32* %12
br label %13
51: ; preds = %13
%52 = load i8*, i8** %5
%53 = load i32, i32* %8
%54 = sdiv i32 %53, 8
%55 = load i32, i32* %7
%56 = sdiv i32 %55, 8
%57 = add nsw i32 %54, %56
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %52, i64 %58
%60 = load i8, i8* %59
%61 = zext i8 %60 to i32
%62 = load i32, i32* %7
%63 = srem i32 %62, 8
%64 = shl i32 %61, %63
%65 = load i8*, i8** %5
%66 = load i32, i32* %8
%67 = sdiv i32 %66, 8
%68 = load i32, i32* %7
%69 = sdiv i32 %68, 8
%70 = add nsw i32 %67, %69
%71 = add nsw i32 %70, 1
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8, i8* %65, i64 %72
%74 = load i8, i8* %73
%75 = zext i8 %74 to i32
%76 = load i32, i32* %7
%77 = srem i32 %76, 8
%78 = sub nsw i32 8, %77
%79 = ashr i32 %75, %78
%80 = or i32 %64, %79
%81 = load i32, i32* %8
%82 = srem i32 %81, 8
%83 = sub nsw i32 8, %82
%84 = shl i32 255, %83
%85 = and i32 %80, %84
%86 = trunc i32 %85 to i8
%87 = call i32 @printbinary(i8 zeroext %86)
ret void
}

LLVM IR (-O2):
define void @cutarray(i8* nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = sdiv i32 %3, 8
%6 = srem i32 %3, 8
%7 = icmp sgt i32 %3, 7
%8 = sdiv i32 %2, 8
%9 = srem i32 %2, 8
%10 = sub nsw i32 8, %9
br i1 %7, label %11, label %14
11: ; preds = %4
%12 = sext i32 %8 to i64
%13 = zext i32 %5 to i64
br label %33
14: ; preds = %33, %4
%15 = add nsw i32 %5, %8
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = shl nuw nsw i32 %19, %9
%21 = add nsw i32 %15, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = lshr i32 %25, %10
%27 = or i32 %26, %20
%28 = sub nsw i32 8, %6
%29 = shl nuw nsw i32 255, %28
%30 = and i32 %27, %29
%31 = trunc i32 %30 to i8
%32 = tail call i32 @printbinary(i8 zeroext %31)
ret void
33: ; preds = %11, %33
%34 = phi i64 [ 0, %11 ], [ %48, %33 ]
%35 = add nsw i64 %34, %12
%36 = getelementptr inbounds i8, i8* %0, i64 %35
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = shl nuw nsw i32 %38, %9
%40 = add nsw i64 %35, 1
%41 = getelementptr inbounds i8, i8* %0, i64 %40
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = lshr i32 %43, %10
%45 = or i32 %44, %39
%46 = trunc i32 %45 to i8
%47 = tail call i32 @printbinary(i8 zeroext %46)
%48 = add nuw nsw i64 %34, 1
%49 = icmp eq i64 %48, %13
br i1 %49, label %14, label %33
}