#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int fprintf(int /*<<< orphan*/ *, char *, unsigned char);
int /*<<< orphan*/ printf(char *);
void add_bit_vector(FILE *file, unsigned char bit_vector[32]) {
  unsigned char c = 0;
  int i = 0, ret = 0;
  for (i = 0; i < 32; i++) {
    c = 0x00;
    c |= ((bit_vector[i] & 0x01) << 7);
    c |= ((bit_vector[i] & 0x02) << 5);
    c |= ((bit_vector[i] & 0x04) << 3);
    c |= ((bit_vector[i] & 0x08) << 1);
    c |= ((bit_vector[i] & 0x10) >> 1);
    c |= ((bit_vector[i] & 0x20) >> 3);
    c |= ((bit_vector[i] & 0x40) >> 5);
    c |= ((bit_vector[i] & 0x80) >> 7);
    if ((ret = fprintf(file, "%c", c)) != 1) {
      printf("Failure to output bit vector number.\n");
      exit(1);
    }
  }
  return;
}


x86 assembly (clang, -O0):
<add_bit_vector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x20,-0x18(%rbp)
jge    128b <add_bit_vector+0x15b>
movb   $0x0,-0x11(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%ecx
and    $0x1,%ecx
shl    $0x7,%ecx
movzbl -0x11(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%ecx
and    $0x2,%ecx
shl    $0x5,%ecx
movzbl -0x11(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%ecx
and    $0x4,%ecx
shl    $0x3,%ecx
movzbl -0x11(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%ecx
and    $0x8,%ecx
shl    $0x1,%ecx
movzbl -0x11(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%ecx
and    $0x10,%ecx
sar    $0x1,%ecx
movzbl -0x11(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%ecx
and    $0x20,%ecx
sar    $0x3,%ecx
movzbl -0x11(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%ecx
and    $0x40,%ecx
sar    $0x5,%ecx
movzbl -0x11(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%ecx
and    $0x80,%ecx
sar    $0x7,%ecx
movzbl -0x11(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xdb3(%rip),%rsi
movzbl -0x11(%rbp),%edx
call   1040 <fprintf@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x1,%eax
je     1278 <add_bit_vector+0x148>
lea    0xd9a(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    127d <add_bit_vector+0x14d>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1159 <add_bit_vector+0x29>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_bit_vector>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
xor    %ebx,%ebx
lea    0xeb9(%rip),%r15
nopw   0x0(%rax,%rax,1)
movzbl (%r14,%rbx,1),%eax
rol    $0x4,%al
mov    %eax,%ecx
and    $0x33,%cl
shl    $0x2,%cl
shr    $0x2,%al
and    $0x33,%al
or     %cl,%al
mov    %eax,%ecx
and    $0x55,%cl
add    %cl,%cl
shr    %al
and    $0x55,%al
or     %cl,%al
movzbl %al,%edx
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <fprintf@plt>
cmp    $0x1,%eax
jne    119d <add_bit_vector+0x6d>
add    $0x1,%rbx
cmp    $0x20,%rbx
jne    1150 <add_bit_vector+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe5f(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [38 x i8] c"Failure to output bit vector number.\0A\00"
define void @add_bit_vector(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
store i8 0, i8* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %6
br label %8
8: ; preds = %116, %2
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 32
br i1 %10, label %11, label %119
11: ; preds = %8
store i8 0, i8* %5
%12 = load i8*, i8** %4
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = and i32 %17, 1
%19 = shl i32 %18, 7
%20 = load i8, i8* %5
%21 = zext i8 %20 to i32
%22 = or i32 %21, %19
%23 = trunc i32 %22 to i8
store i8 %23, i8* %5
%24 = load i8*, i8** %4
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = and i32 %29, 2
%31 = shl i32 %30, 5
%32 = load i8, i8* %5
%33 = zext i8 %32 to i32
%34 = or i32 %33, %31
%35 = trunc i32 %34 to i8
store i8 %35, i8* %5
%36 = load i8*, i8** %4
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = and i32 %41, 4
%43 = shl i32 %42, 3
%44 = load i8, i8* %5
%45 = zext i8 %44 to i32
%46 = or i32 %45, %43
%47 = trunc i32 %46 to i8
store i8 %47, i8* %5
%48 = load i8*, i8** %4
%49 = load i32, i32* %6
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
%54 = and i32 %53, 8
%55 = shl i32 %54, 1
%56 = load i8, i8* %5
%57 = zext i8 %56 to i32
%58 = or i32 %57, %55
%59 = trunc i32 %58 to i8
store i8 %59, i8* %5
%60 = load i8*, i8** %4
%61 = load i32, i32* %6
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
%64 = load i8, i8* %63
%65 = zext i8 %64 to i32
%66 = and i32 %65, 16
%67 = ashr i32 %66, 1
%68 = load i8, i8* %5
%69 = zext i8 %68 to i32
%70 = or i32 %69, %67
%71 = trunc i32 %70 to i8
store i8 %71, i8* %5
%72 = load i8*, i8** %4
%73 = load i32, i32* %6
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8, i8* %72, i64 %74
%76 = load i8, i8* %75
%77 = zext i8 %76 to i32
%78 = and i32 %77, 32
%79 = ashr i32 %78, 3
%80 = load i8, i8* %5
%81 = zext i8 %80 to i32
%82 = or i32 %81, %79
%83 = trunc i32 %82 to i8
store i8 %83, i8* %5
%84 = load i8*, i8** %4
%85 = load i32, i32* %6
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8, i8* %84, i64 %86
%88 = load i8, i8* %87
%89 = zext i8 %88 to i32
%90 = and i32 %89, 64
%91 = ashr i32 %90, 5
%92 = load i8, i8* %5
%93 = zext i8 %92 to i32
%94 = or i32 %93, %91
%95 = trunc i32 %94 to i8
store i8 %95, i8* %5
%96 = load i8*, i8** %4
%97 = load i32, i32* %6
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i8, i8* %96, i64 %98
%100 = load i8, i8* %99
%101 = zext i8 %100 to i32
%102 = and i32 %101, 128
%103 = ashr i32 %102, 7
%104 = load i8, i8* %5
%105 = zext i8 %104 to i32
%106 = or i32 %105, %103
%107 = trunc i32 %106 to i8
store i8 %107, i8* %5
%108 = load i32*, i32** %3
%109 = load i8, i8* %5
%110 = call i32 @fprintf(i32* %108, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 zeroext %109)
store i32 %110, i32* %7
%111 = icmp ne i32 %110, 1
br i1 %111, label %112, label %115
112: ; preds = %11
%113 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%114 = call i32 @exit(i32 1)
unreachable
115: ; preds = %11
br label %116
116: ; preds = %115
%117 = load i32, i32* %6
%118 = add nsw i32 %117, 1
store i32 %118, i32* %6
br label %8
119: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@str = [37 x i8] c"Failure to output bit vector number.\00"
define void @add_bit_vector(i32* nocapture %0, i8* nocapture %1) {
br label %6
3: ; preds = %6
%4 = add nuw nsw i64 %7, 1
%5 = icmp eq i64 %4, 32
br i1 %5, label %16, label %6
6: ; preds = %2, %3
%7 = phi i64 [ 0, %2 ], [ %4, %3 ]
%8 = getelementptr inbounds i8, i8* %1, i64 %7
%9 = load i8, i8* %8
%10 = tail call i8 @llvm.bitreverse.i8(i8 %9)
%11 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 zeroext %10)
%12 = icmp eq i32 %11, 1
br i1 %12, label %3, label %13
13: ; preds = %6
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %3
ret void
}