#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 */
unsigned char bReceiveBit();
unsigned char bReceiveByte(void) {
  unsigned char b;
  unsigned char bCurrByte = 0x00;
  for (b = 0; b < 8; b++) {
    bCurrByte = (bCurrByte << 1) + bReceiveBit();
  }
  return (bCurrByte);
}


x86 assembly (clang, -O0):
<bReceiveByte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movb   $0x0,-0x2(%rbp)
movb   $0x0,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x8,%eax
jge    1158 <bReceiveByte+0x48>
movzbl -0x2(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1030 <bReceiveBit@plt>
mov    %al,%cl
mov    -0x8(%rbp),%eax
movzbl %cl,%ecx
add    %ecx,%eax
mov    %al,-0x2(%rbp)
mov    -0x1(%rbp),%al
add    $0x1,%al
mov    %al,-0x1(%rbp)
jmp    1120 <bReceiveByte+0x10>
movzbl -0x2(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bReceiveByte>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <bReceiveBit@plt>
mov    %eax,%ebp
add    %al,%bpl
xor    %eax,%eax
call   1030 <bReceiveBit@plt>
mov    %eax,%ebx
add    %bpl,%bl
add    %bl,%bl
xor    %eax,%eax
call   1030 <bReceiveBit@plt>
mov    %eax,%ebp
add    %bl,%bpl
add    %bpl,%bpl
xor    %eax,%eax
call   1030 <bReceiveBit@plt>
mov    %eax,%ebx
add    %bpl,%bl
add    %bl,%bl
xor    %eax,%eax
call   1030 <bReceiveBit@plt>
mov    %eax,%ebp
add    %bl,%bpl
add    %bpl,%bpl
xor    %eax,%eax
call   1030 <bReceiveBit@plt>
mov    %eax,%ebx
add    %bpl,%bl
add    %bl,%bl
xor    %eax,%eax
call   1030 <bReceiveBit@plt>
mov    %eax,%ebp
add    %bl,%bpl
add    %bpl,%bpl
xor    %eax,%eax
call   1030 <bReceiveBit@plt>
add    %bpl,%al
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define zeroext i8 @bReceiveByte() {
%1 = alloca i8
%2 = alloca i8
store i8 0, i8* %2
store i8 0, i8* %1
br label %3
3: ; preds = %15, %0
%4 = load i8, i8* %1
%5 = zext i8 %4 to i32
%6 = icmp slt i32 %5, 8
br i1 %6, label %7, label %18
7: ; preds = %3
%8 = load i8, i8* %2
%9 = zext i8 %8 to i32
%10 = shl i32 %9, 1
%11 = call zeroext i8 (...) @bReceiveBit()
%12 = zext i8 %11 to i32
%13 = add nsw i32 %10, %12
%14 = trunc i32 %13 to i8
store i8 %14, i8* %2
br label %15
15: ; preds = %7
%16 = load i8, i8* %1
%17 = add i8 %16, 1
store i8 %17, i8* %1
br label %3
18: ; preds = %3
%19 = load i8, i8* %2
ret i8 %19
}

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