#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 */
char ConvertBinaryToDecimal(int);
int atoi(char *);
scalar_t__ endian();
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int, int, int, int);
bool BitsToWord(int *bits, FILE *store) {
  char c[8];
  if (endian()) {
    sprintf(c, "%d%d%d%d%d%d%d", bits[6], bits[5], bits[4], bits[3], bits[2],
            bits[1], bits[0]);
  } else {
    sprintf(c, "%d%d%d%d%d%d%d", bits[0], bits[1], bits[2], bits[3], bits[4],
            bits[5], bits[6]);
  }
  int d = atoi(c);
  char ch = ConvertBinaryToDecimal(d);
  fputc(ch, store);
  if (ch == '~') {
    return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<BitsToWord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x0,%al
call   1030 <endian@plt>
cmp    $0x0,%rax
je     11c7 <BitsToWord+0x77>
lea    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r8d
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r11d
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%r10d
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
lea    0xe50(%rip),%rsi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1070 <sprintf@plt>
jmp    1218 <BitsToWord+0xc8>
lea    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r8d
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r11d
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%r10d
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%eax
lea    0xdfa(%rip),%rsi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1070 <sprintf@plt>
lea    -0x20(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1050 <ConvertBinaryToDecimal@plt>
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1040 <fputc@plt>
movsbl -0x25(%rbp),%eax
cmp    $0x7e,%eax
jne    1257 <BitsToWord+0x107>
movl   $0x0,-0x4(%rbp)
jmp    125e <BitsToWord+0x10e>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BitsToWord>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <endian@plt>
test   %rax,%rax
je     1191 <BitsToWord+0x41>
mov    0x18(%rbx),%edx
mov    0x14(%rbx),%ecx
mov    0x10(%rbx),%r8d
mov    0xc(%rbx),%r9d
mov    0x8(%rbx),%r10d
mov    (%rbx),%eax
mov    0x4(%rbx),%ebx
sub    $0x8,%rsp
lea    0xe78(%rip),%rsi
lea    0x8(%rsp),%rdi
push   %rax
push   %rbx
jmp    11ba <BitsToWord+0x6a>
mov    (%rbx),%edx
mov    0x4(%rbx),%ecx
mov    0x8(%rbx),%r8d
mov    0xc(%rbx),%r9d
mov    0x10(%rbx),%r10d
mov    0x14(%rbx),%eax
mov    0x18(%rbx),%ebx
sub    $0x8,%rsp
lea    0xe4d(%rip),%rsi
lea    0x8(%rsp),%rdi
push   %rbx
push   %rax
push   %r10
call   1070 <sprintf@plt>
add    $0x20,%rsp
mov    %rsp,%rdi
call   1060 <atoi@plt>
mov    %eax,%edi
call   1050 <ConvertBinaryToDecimal@plt>
movsbl %al,%ebx
mov    %ebx,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
xor    %eax,%eax
cmp    $0x7e,%bl
setne  %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [15 x i8] c"%d%d%d%d%d%d%d\00"
define i32 @BitsToWord(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca [8 x i8]
%7 = alloca i32
%8 = alloca i8
store i32* %0, i32** %4
store i32* %1, i32** %5
%9 = call i64 (...) @endian()
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %35
11: ; preds = %2
%12 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%13 = load i32*, i32** %4
%14 = getelementptr inbounds i32, i32* %13, i64 6
%15 = load i32, i32* %14
%16 = load i32*, i32** %4
%17 = getelementptr inbounds i32, i32* %16, i64 5
%18 = load i32, i32* %17
%19 = load i32*, i32** %4
%20 = getelementptr inbounds i32, i32* %19, i64 4
%21 = load i32, i32* %20
%22 = load i32*, i32** %4
%23 = getelementptr inbounds i32, i32* %22, i64 3
%24 = load i32, i32* %23
%25 = load i32*, i32** %4
%26 = getelementptr inbounds i32, i32* %25, i64 2
%27 = load i32, i32* %26
%28 = load i32*, i32** %4
%29 = getelementptr inbounds i32, i32* %28, i64 1
%30 = load i32, i32* %29
%31 = load i32*, i32** %4
%32 = getelementptr inbounds i32, i32* %31, i64 0
%33 = load i32, i32* %32
%34 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %18, i32 %21, i32 %24, i32 %27, i32 %30, i32 %33)
br label %59
35: ; preds = %2
%36 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%37 = load i32*, i32** %4
%38 = getelementptr inbounds i32, i32* %37, i64 0
%39 = load i32, i32* %38
%40 = load i32*, i32** %4
%41 = getelementptr inbounds i32, i32* %40, i64 1
%42 = load i32, i32* %41
%43 = load i32*, i32** %4
%44 = getelementptr inbounds i32, i32* %43, i64 2
%45 = load i32, i32* %44
%46 = load i32*, i32** %4
%47 = getelementptr inbounds i32, i32* %46, i64 3
%48 = load i32, i32* %47
%49 = load i32*, i32** %4
%50 = getelementptr inbounds i32, i32* %49, i64 4
%51 = load i32, i32* %50
%52 = load i32*, i32** %4
%53 = getelementptr inbounds i32, i32* %52, i64 5
%54 = load i32, i32* %53
%55 = load i32*, i32** %4
%56 = getelementptr inbounds i32, i32* %55, i64 6
%57 = load i32, i32* %56
%58 = call i32 @sprintf(i8* %36, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %39, i32 %42, i32 %45, i32 %48, i32 %51, i32 %54, i32 %57)
br label %59
59: ; preds = %35, %11
%60 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%61 = call i32 @atoi(i8* %60)
store i32 %61, i32* %7
%62 = load i32, i32* %7
%63 = call signext i8 @ConvertBinaryToDecimal(i32 %62)
store i8 %63, i8* %8
%64 = load i8, i8* %8
%65 = load i32*, i32** %5
%66 = call i32 @fputc(i8 signext %64, i32* %65)
%67 = load i8, i8* %8
%68 = sext i8 %67 to i32
%69 = icmp eq i32 %68, 126
br i1 %69, label %70, label %71
70: ; preds = %59
store i32 0, i32* %3
br label %72
71: ; preds = %59
store i32 1, i32* %3
br label %72
72: ; preds = %71, %70
%73 = load i32, i32* %3
ret i32 %73
}

LLVM IR (-O2):
@.str = [15 x i8] c"%d%d%d%d%d%d%d\00"
define i32 @BitsToWord(i32* nocapture %0, i32* nocapture %1) {
%3 = alloca [8 x i8]
%4 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%5 = tail call i64 (...) @endian()
%6 = icmp eq i64 %5, 0
br i1 %6, label %22, label %7
7: ; preds = %2
%8 = getelementptr inbounds i32, i32* %0, i64 6
%9 = load i32, i32* %8
%10 = getelementptr inbounds i32, i32* %0, i64 5
%11 = load i32, i32* %10
%12 = getelementptr inbounds i32, i32* %0, i64 4
%13 = load i32, i32* %12
%14 = getelementptr inbounds i32, i32* %0, i64 3
%15 = load i32, i32* %14
%16 = getelementptr inbounds i32, i32* %0, i64 2
%17 = load i32, i32* %16
%18 = getelementptr inbounds i32, i32* %0, i64 1
%19 = load i32, i32* %18
%20 = load i32, i32* %0
%21 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %11, i32 %13, i32 %15, i32 %17, i32 %19, i32 %20)
br label %37
22: ; preds = %2
%23 = load i32, i32* %0
%24 = getelementptr inbounds i32, i32* %0, i64 1
%25 = load i32, i32* %24
%26 = getelementptr inbounds i32, i32* %0, i64 2
%27 = load i32, i32* %26
%28 = getelementptr inbounds i32, i32* %0, i64 3
%29 = load i32, i32* %28
%30 = getelementptr inbounds i32, i32* %0, i64 4
%31 = load i32, i32* %30
%32 = getelementptr inbounds i32, i32* %0, i64 5
%33 = load i32, i32* %32
%34 = getelementptr inbounds i32, i32* %0, i64 6
%35 = load i32, i32* %34
%36 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %23, i32 %25, i32 %27, i32 %29, i32 %31, i32 %33, i32 %35)
br label %37
37: ; preds = %22, %7
%38 = call i32 @atoi(i8* %4)
%39 = tail call signext i8 @ConvertBinaryToDecimal(i32 %38)
%40 = tail call i32 @fputc(i8 signext %39, i32* %1)
%41 = icmp ne i8 %39, 126
%42 = zext i1 %41 to i32
ret i32 %42
}