void ShiftRight(unsigned char *SHFT) {
  unsigned char prevcarry = 0x00;
  unsigned char currcarry = 0x00;
  for (int i = 0; i < 16; i++) {
    prevcarry = currcarry;
    if (SHFT[i] & 0x01)
      currcarry = 0x80;
    else
      currcarry = 0x00;
    SHFT[i] >>= 0x01;
    SHFT[i] += prevcarry;
  }
}


x86 assembly (clang, -O0):
<ShiftRight>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movb   $0x0,-0x9(%rbp)
movb   $0x0,-0xa(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x10,-0x10(%rbp)
jge    1181 <ShiftRight+0x81>
mov    -0xa(%rbp),%al
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1148 <ShiftRight+0x48>
movb   $0x80,-0xa(%rbp)
jmp    114c <ShiftRight+0x4c>
movb   $0x0,-0xa(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
sar    $0x1,%edx
mov    %dl,(%rax,%rcx,1)
movzbl -0x9(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
add    %esi,%edx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1117 <ShiftRight+0x17>
pop    %rbp
ret

x86 assembly (clang, -O2):
<ShiftRight>:
mov    (%rdi),%al
mov    0x1(%rdi),%cl
mov    %eax,%edx
shr    %dl
mov    %dl,(%rdi)
mov    %ecx,%edx
shr    %dl
shl    $0x7,%al
or     %dl,%al
mov    %al,0x1(%rdi)
mov    0x2(%rdi),%al
mov    %eax,%edx
shr    %dl
shl    $0x7,%cl
or     %dl,%cl
mov    %cl,0x2(%rdi)
mov    0x3(%rdi),%cl
mov    %ecx,%edx
shr    %dl
shl    $0x7,%al
or     %dl,%al
mov    %al,0x3(%rdi)
mov    0x4(%rdi),%al
mov    %eax,%edx
shr    %dl
shl    $0x7,%cl
or     %dl,%cl
mov    %cl,0x4(%rdi)
mov    0x5(%rdi),%cl
mov    %ecx,%edx
shr    %dl
shl    $0x7,%al
or     %dl,%al
mov    %al,0x5(%rdi)
mov    0x6(%rdi),%al
mov    %eax,%edx
shr    %dl
shl    $0x7,%cl
or     %dl,%cl
mov    %cl,0x6(%rdi)
mov    0x7(%rdi),%cl
mov    %ecx,%edx
shr    %dl
shl    $0x7,%al
or     %dl,%al
mov    %al,0x7(%rdi)
mov    0x8(%rdi),%al
mov    %eax,%edx
shr    %dl
shl    $0x7,%cl
or     %dl,%cl
mov    %cl,0x8(%rdi)
mov    0x9(%rdi),%cl
mov    %ecx,%edx
shr    %dl
shl    $0x7,%al
or     %dl,%al
mov    %al,0x9(%rdi)
mov    0xa(%rdi),%al
shl    $0x7,%cl
mov    %eax,%edx
shr    %dl
or     %cl,%dl
mov    %dl,0xa(%rdi)
mov    0xb(%rdi),%cl
shl    $0x7,%al
mov    %ecx,%edx
shr    %dl
or     %al,%dl
mov    %dl,0xb(%rdi)
mov    0xc(%rdi),%al
shl    $0x7,%cl
mov    %eax,%edx
shr    %dl
or     %cl,%dl
mov    %dl,0xc(%rdi)
mov    0xd(%rdi),%cl
shl    $0x7,%al
mov    %ecx,%edx
shr    %dl
or     %al,%dl
mov    %dl,0xd(%rdi)
mov    0xe(%rdi),%al
shl    $0x7,%cl
mov    %eax,%edx
shr    %dl
or     %cl,%dl
mov    %dl,0xe(%rdi)
mov    0xf(%rdi),%cl
shl    $0x7,%al
shr    %cl
or     %al,%cl
mov    %cl,0xf(%rdi)
ret

LLVM IR (-O0):
define void @ShiftRight(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
store i8* %0, i8** %2
store i8 0, i8* %3
store i8 0, i8* %4
store i32 0, i32* %5
br label %6
6: ; preds = %40, %1
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 16
br i1 %8, label %9, label %43
9: ; preds = %6
%10 = load i8, i8* %4
store i8 %10, i8* %3
%11 = load i8*, i8** %2
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = and i32 %16, 1
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %9
store i8 -128, i8* %4
br label %21
20: ; preds = %9
store i8 0, i8* %4
br label %21
21: ; preds = %20, %19
%22 = load i8*, i8** %2
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = ashr i32 %27, 1
%29 = trunc i32 %28 to i8
store i8 %29, i8* %25
%30 = load i8, i8* %3
%31 = zext i8 %30 to i32
%32 = load i8*, i8** %2
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = add nsw i32 %37, %31
%39 = trunc i32 %38 to i8
store i8 %39, i8* %35
br label %40
40: ; preds = %21
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %6
43: ; preds = %6
ret void
}

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