#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 */
double pow(int, double);
int strlen(char const *);
void B_to_A(const char *input) {
  int length = strlen(input);
  int binary[8];
  int asciiNum = 0;
  char ascii;
  int z = 0;
  int x;
  for (x = 0; x < length / 8; x++) {
    int a;
    for (a = 0; a < 8; a++) {
      binary[a] = (int)input[z] - 48;
      z++;
    }
    int power[8];
    int counter = 7;
    int x;
    for (x = 0; x < 8; x++) {
      power[x] = counter;
      counter--;
    }
    int y;
    for (y = 0; y < 8; y++) {
      double a = binary[y];
      double b = power[y];
      asciiNum += a * pow(2, b);
    }
    ascii = asciiNum;
    asciiNum = 0;
  }
}


x86 assembly (clang, -O0):
<B_to_A>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x94(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x94(%rbp),%eax
cmp    %ecx,%eax
jge    128c <B_to_A+0x16c>
movl   $0x0,-0x44(%rbp)
cmpl   $0x8,-0x44(%rbp)
jge    11b3 <B_to_A+0x93>
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
sub    $0x30,%ecx
movslq -0x44(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    117b <B_to_A+0x5b>
movl   $0x7,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
cmpl   $0x8,-0x78(%rbp)
jge    11ed <B_to_A+0xcd>
mov    -0x74(%rbp),%ecx
movslq -0x78(%rbp),%rax
mov    %ecx,-0x70(%rbp,%rax,4)
mov    -0x74(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x74(%rbp)
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    11c1 <B_to_A+0xa1>
movl   $0x0,-0x7c(%rbp)
cmpl   $0x8,-0x7c(%rbp)
jge    1271 <B_to_A+0x151>
movslq -0x7c(%rbp),%rax
cvtsi2sdl -0x30(%rbp,%rax,4),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movslq -0x7c(%rbp),%rax
cvtsi2sdl -0x70(%rbp,%rax,4),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
mov    $0x2,%edi
call   1040 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0xa0(%rbp),%xmm0
ff
cvtsi2sdl -0x34(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x34(%rbp)
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    11f4 <B_to_A+0xd4>
mov    -0x34(%rbp),%eax
mov    %al,-0x35(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1150 <B_to_A+0x30>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<B_to_A>:
push   %rbp
push   %rbx
push   %rax
call   1030 <strlen@plt>
lea    0x7(%rax),%ebx
test   %eax,%eax
cmovns %eax,%ebx
cmp    $0x8,%eax
jl     1274 <B_to_A+0x154>
sar    $0x3,%ebx
and    $0xfffffff8,%eax
cmp    $0x8,%eax
je     126f <B_to_A+0x14f>
mov    %ebx,%ebp
and    $0xfffffffe,%ebp
nopl   (%rax)
mov    $0x2,%edi
movsd  0xea3(%rip),%xmm0
call   1040 <pow@plt>
mov    $0x2,%edi
movsd  0xe99(%rip),%xmm0
call   1040 <pow@plt>
mov    $0x2,%edi
movsd  0xe8f(%rip),%xmm0
call   1040 <pow@plt>
mov    $0x2,%edi
movsd  0xe85(%rip),%xmm0
call   1040 <pow@plt>
mov    $0x2,%edi
movsd  0xe7b(%rip),%xmm0
call   1040 <pow@plt>
mov    $0x2,%edi
movsd  0xe71(%rip),%xmm0
call   1040 <pow@plt>
mov    $0x2,%edi
movsd  0xe67(%rip),%xmm0
call   1040 <pow@plt>
xorps  %xmm0,%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
mov    $0x2,%edi
movsd  0xe18(%rip),%xmm0
call   1040 <pow@plt>
mov    $0x2,%edi
movsd  0xe0e(%rip),%xmm0
call   1040 <pow@plt>
mov    $0x2,%edi
movsd  0xe04(%rip),%xmm0
call   1040 <pow@plt>
mov    $0x2,%edi
movsd  0xdfa(%rip),%xmm0
call   1040 <pow@plt>
mov    $0x2,%edi
movsd  0xdf0(%rip),%xmm0
call   1040 <pow@plt>
mov    $0x2,%edi
movsd  0xde6(%rip),%xmm0
call   1040 <pow@plt>
mov    $0x2,%edi
movsd  0xddc(%rip),%xmm0
call   1040 <pow@plt>
xorps  %xmm0,%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
add    $0xfffffffe,%ebp
jne    1150 <B_to_A+0x30>
test   $0x1,%bl
jne    127b <B_to_A+0x15b>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
movsd  0xd7d(%rip),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
movsd  0xd73(%rip),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
movsd  0xd69(%rip),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
movsd  0xd5f(%rip),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
movsd  0xd55(%rip),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
movsd  0xd4b(%rip),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
movsd  0xd41(%rip),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
xorps  %xmm0,%xmm0
mov    $0x2,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <pow@plt>

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

LLVM IR (-O2):
define void @B_to_A(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = sdiv i32 %2, 8
%4 = icmp sgt i32 %2, 7
br i1 %4, label %5, label %42
5: ; preds = %1
%6 = and i32 %3, 1
%7 = and i32 %2, -8
%8 = icmp eq i32 %7, 8
br i1 %8, label %31, label %9
9: ; preds = %5
%10 = and i32 %3, -2
br label %11
11: ; preds = %11, %9
%12 = phi i32 [ 0, %9 ], [ %29, %11 ]
%13 = tail call double @pow(i32 2, double 7.000000e+00)
%14 = tail call double @pow(i32 2, double 6.000000e+00)
%15 = tail call double @pow(i32 2, double 5.000000e+00)
%16 = tail call double @pow(i32 2, double 4.000000e+00)
%17 = tail call double @pow(i32 2, double 3.000000e+00)
%18 = tail call double @pow(i32 2, double 2.000000e+00)
%19 = tail call double @pow(i32 2, double 1.000000e+00)
%20 = tail call double @pow(i32 2, double 0.000000e+00)
%21 = tail call double @pow(i32 2, double 7.000000e+00)
%22 = tail call double @pow(i32 2, double 6.000000e+00)
%23 = tail call double @pow(i32 2, double 5.000000e+00)
%24 = tail call double @pow(i32 2, double 4.000000e+00)
%25 = tail call double @pow(i32 2, double 3.000000e+00)
%26 = tail call double @pow(i32 2, double 2.000000e+00)
%27 = tail call double @pow(i32 2, double 1.000000e+00)
%28 = tail call double @pow(i32 2, double 0.000000e+00)
%29 = add i32 %12, 2
%30 = icmp eq i32 %29, %10
br i1 %30, label %31, label %11
31: ; preds = %11, %5
%32 = icmp eq i32 %6, 0
br i1 %32, label %42, label %33
33: ; preds = %31
%34 = tail call double @pow(i32 2, double 7.000000e+00)
%35 = tail call double @pow(i32 2, double 6.000000e+00)
%36 = tail call double @pow(i32 2, double 5.000000e+00)
%37 = tail call double @pow(i32 2, double 4.000000e+00)
%38 = tail call double @pow(i32 2, double 3.000000e+00)
%39 = tail call double @pow(i32 2, double 2.000000e+00)
%40 = tail call double @pow(i32 2, double 1.000000e+00)
%41 = tail call double @pow(i32 2, double 0.000000e+00)
br label %42
42: ; preds = %33, %31, %1
ret void
}