#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 */
int Bus_ReadBit();
int Bus_ReadByte(void) {
  int i = 0;
  int Data = 0;
  for (i = 0; i < 8; i++) {
    Data = Data | (Bus_ReadBit() << (i));
  }
  return Data;
}


x86 assembly (clang, -O0):
<Bus_ReadByte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x8,-0x4(%rbp)
jge    1163 <Bus_ReadByte+0x53>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <Bus_ReadBit@plt>
mov    %eax,%edx
mov    -0xc(%rbp),%eax
mov    -0x4(%rbp),%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    112d <Bus_ReadByte+0x1d>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Bus_ReadByte>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <Bus_ReadBit@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <Bus_ReadBit@plt>
mov    %eax,%ebp
add    %eax,%ebp
or     %ebx,%ebp
xor    %eax,%eax
call   1030 <Bus_ReadBit@plt>
mov    %eax,%r14d
shl    $0x2,%r14d
xor    %eax,%eax
call   1030 <Bus_ReadBit@plt>
mov    %eax,%r15d
shl    $0x3,%r15d
or     %r14d,%r15d
or     %ebp,%r15d
xor    %eax,%eax
call   1030 <Bus_ReadBit@plt>
mov    %eax,%r14d
shl    $0x4,%r14d
xor    %eax,%eax
call   1030 <Bus_ReadBit@plt>
mov    %eax,%ebp
shl    $0x5,%ebp
or     %r14d,%ebp
xor    %eax,%eax
call   1030 <Bus_ReadBit@plt>
mov    %eax,%ebx
shl    $0x6,%ebx
or     %ebp,%ebx
or     %r15d,%ebx
xor    %eax,%eax
call   1030 <Bus_ReadBit@plt>
shl    $0x7,%eax
or     %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @Bus_ReadByte() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %1
br label %3
3: ; preds = %12, %0
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 8
br i1 %5, label %6, label %15
6: ; preds = %3
%7 = load i32, i32* %2
%8 = call i32 (...) @Bus_ReadBit()
%9 = load i32, i32* %1
%10 = shl i32 %8, %9
%11 = or i32 %7, %10
store i32 %11, i32* %2
br label %12
12: ; preds = %6
%13 = load i32, i32* %1
%14 = add nsw i32 %13, 1
store i32 %14, i32* %1
br label %3
15: ; preds = %3
%16 = load i32, i32* %2
ret i32 %16
}

LLVM IR (-O2):
define i32 @Bus_ReadByte() {
%1 = tail call i32 (...) @Bus_ReadBit()
%2 = tail call i32 (...) @Bus_ReadBit()
%3 = shl i32 %2, 1
%4 = or i32 %3, %1
%5 = tail call i32 (...) @Bus_ReadBit()
%6 = shl i32 %5, 2
%7 = or i32 %6, %4
%8 = tail call i32 (...) @Bus_ReadBit()
%9 = shl i32 %8, 3
%10 = or i32 %9, %7
%11 = tail call i32 (...) @Bus_ReadBit()
%12 = shl i32 %11, 4
%13 = or i32 %12, %10
%14 = tail call i32 (...) @Bus_ReadBit()
%15 = shl i32 %14, 5
%16 = or i32 %15, %13
%17 = tail call i32 (...) @Bus_ReadBit()
%18 = shl i32 %17, 6
%19 = or i32 %18, %16
%20 = tail call i32 (...) @Bus_ReadBit()
%21 = shl i32 %20, 7
%22 = or i32 %21, %19
ret i32 %22
}