void transfer_RGBA8888_to_TRANSPARENCY(unsigned char *(*output),
                                       unsigned char *input,
                                       int(*bit_counter)) {
  if ((*bit_counter) == 7)
    *(*output) = 0;
  if (input[3] < 127) {
    *(*output) |= (unsigned char)1 << (7 - (*bit_counter));
  }
  if ((*bit_counter) == 0) {
    (*output)++;
    (*bit_counter) = 7;
  } else
    (*bit_counter)--;
}


x86 assembly (clang, -O0):
<transfer_RGBA8888_to_TRANSPARENCY>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpl   $0x7,(%rax)
jne    1127 <transfer_RGBA8888_to_TRANSPARENCY+0x27>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%eax
cmp    $0x7f,%eax
jge    1158 <transfer_RGBA8888_to_TRANSPARENCY+0x58>
mov    -0x18(%rbp),%rax
mov    $0x7,%ecx
sub    (%rax),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movzbl (%rax),%ecx
or     %edx,%ecx
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1182 <transfer_RGBA8888_to_TRANSPARENCY+0x82>
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x7,(%rax)
jmp    118d <transfer_RGBA8888_to_TRANSPARENCY+0x8d>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<transfer_RGBA8888_to_TRANSPARENCY>:
cmpl   $0x7,(%rdx)
jne    110b <transfer_RGBA8888_to_TRANSPARENCY+0xb>
mov    (%rdi),%rax
movb   $0x0,(%rax)
cmpb   $0x7e,0x3(%rsi)
ja     1121 <transfer_RGBA8888_to_TRANSPARENCY+0x21>
mov    $0x7,%cl
sub    (%rdx),%cl
mov    $0x1,%eax
shl    %cl,%eax
mov    (%rdi),%rcx
or     %al,(%rcx)
mov    (%rdx),%eax
test   %eax,%eax
je     112d <transfer_RGBA8888_to_TRANSPARENCY+0x2d>
add    $0xffffffff,%eax
mov    %eax,(%rdx)
ret
addq   $0x1,(%rdi)
mov    $0x7,%eax
mov    %eax,(%rdx)
ret

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

LLVM IR (-O2):
define void @transfer_RGBA8888_to_TRANSPARENCY(i8** nocapture %0, i8* nocapture %1, i32* nocapture %2) {
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 7
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = load i8*, i8** %0
store i8 0, i8* %7
br label %8
8: ; preds = %6, %3
%9 = getelementptr inbounds i8, i8* %1, i64 3
%10 = load i8, i8* %9
%11 = icmp ult i8 %10, 127
br i1 %11, label %12, label %20
12: ; preds = %8
%13 = load i32, i32* %2
%14 = sub nsw i32 7, %13
%15 = shl nuw i32 1, %14
%16 = load i8*, i8** %0
%17 = load i8, i8* %16
%18 = trunc i32 %15 to i8
%19 = or i8 %17, %18
store i8 %19, i8* %16
br label %20
20: ; preds = %12, %8
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i8*, i8** %0
%25 = getelementptr inbounds i8, i8* %24, i64 1
store i8* %25, i8** %0
br label %28
26: ; preds = %20
%27 = add nsw i32 %21, -1
br label %28
28: ; preds = %26, %23
%29 = phi i32 [ %27, %26 ], [ 7, %23 ]
store i32 %29, i32* %2
ret void
}