#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 /*<<< orphan*/ Draco9210ClearDataOut();
unsigned char Draco9210ReadDataIn();
int /*<<< orphan*/ Draco9210ToggleClock();
void DracoReadData(unsigned char *data) {
  int i;
  unsigned char tmp = 0, readbit;
  Draco9210ClearDataOut();
  Draco9210ToggleClock();
  for (i = 0; i < 7; i++) {
    readbit = Draco9210ReadDataIn();
    tmp |= (readbit & 0x1);
    tmp <<= 1;
    Draco9210ToggleClock();
  }
  readbit = Draco9210ReadDataIn();
  tmp |= (readbit & 0x1);
  *data = tmp;
}


x86 assembly (clang, -O0):
<DracoReadData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x0,-0xd(%rbp)
mov    $0x0,%al
call   1050 <Draco9210ClearDataOut@plt>
mov    $0x0,%al
call   1040 <Draco9210ToggleClock@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x7,-0xc(%rbp)
jge    1198 <DracoReadData+0x68>
mov    $0x0,%al
call   1030 <Draco9210ReadDataIn@plt>
mov    %al,-0xe(%rbp)
movzbl -0xe(%rbp),%ecx
and    $0x1,%ecx
movzbl -0xd(%rbp),%eax
or     %ecx,%eax
mov    %al,-0xd(%rbp)
movzbl -0xd(%rbp),%eax
shl    $0x1,%eax
mov    %al,-0xd(%rbp)
mov    $0x0,%al
call   1040 <Draco9210ToggleClock@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1155 <DracoReadData+0x25>
mov    $0x0,%al
call   1030 <Draco9210ReadDataIn@plt>
mov    %al,-0xe(%rbp)
movzbl -0xe(%rbp),%ecx
and    $0x1,%ecx
movzbl -0xd(%rbp),%eax
or     %ecx,%eax
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DracoReadData>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %eax,%eax
call   1050 <Draco9210ClearDataOut@plt>
xor    %eax,%eax
call   1040 <Draco9210ToggleClock@plt>
xor    %eax,%eax
call   1030 <Draco9210ReadDataIn@plt>
mov    %eax,%ebp
add    %al,%bpl
and    $0x2,%bpl
xor    %eax,%eax
call   1040 <Draco9210ToggleClock@plt>
xor    %eax,%eax
call   1030 <Draco9210ReadDataIn@plt>
mov    %eax,%ebx
and    $0x1,%bl
or     %bpl,%bl
xor    %eax,%eax
call   1040 <Draco9210ToggleClock@plt>
xor    %eax,%eax
call   1030 <Draco9210ReadDataIn@plt>
mov    %eax,%ebp
shl    $0x2,%bl
add    %al,%bpl
and    $0x2,%bpl
or     %bl,%bpl
xor    %eax,%eax
call   1040 <Draco9210ToggleClock@plt>
xor    %eax,%eax
call   1030 <Draco9210ReadDataIn@plt>
mov    %eax,%ebx
and    $0x1,%bl
or     %bpl,%bl
xor    %eax,%eax
call   1040 <Draco9210ToggleClock@plt>
xor    %eax,%eax
call   1030 <Draco9210ReadDataIn@plt>
mov    %eax,%ebp
shl    $0x2,%bl
add    %al,%bpl
and    $0x2,%bpl
or     %bl,%bpl
xor    %eax,%eax
call   1040 <Draco9210ToggleClock@plt>
xor    %eax,%eax
call   1030 <Draco9210ReadDataIn@plt>
mov    %eax,%ebx
and    $0x1,%bl
or     %bpl,%bl
xor    %eax,%eax
call   1040 <Draco9210ToggleClock@plt>
xor    %eax,%eax
call   1030 <Draco9210ReadDataIn@plt>
mov    %eax,%ebp
shl    $0x2,%bl
add    %al,%bpl
and    $0x2,%bpl
or     %bl,%bpl
xor    %eax,%eax
call   1040 <Draco9210ToggleClock@plt>
xor    %eax,%eax
call   1030 <Draco9210ReadDataIn@plt>
and    $0x1,%al
or     %bpl,%al
mov    %al,(%r14)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @DracoReadData(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8
store i8* %0, i8** %2
store i8 0, i8* %4
%6 = call i32 (...) @Draco9210ClearDataOut()
%7 = call i32 (...) @Draco9210ToggleClock()
store i32 0, i32* %3
br label %8
8: ; preds = %25, %1
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 7
br i1 %10, label %11, label %28
11: ; preds = %8
%12 = call zeroext i8 (...) @Draco9210ReadDataIn()
store i8 %12, i8* %5
%13 = load i8, i8* %5
%14 = zext i8 %13 to i32
%15 = and i32 %14, 1
%16 = load i8, i8* %4
%17 = zext i8 %16 to i32
%18 = or i32 %17, %15
%19 = trunc i32 %18 to i8
store i8 %19, i8* %4
%20 = load i8, i8* %4
%21 = zext i8 %20 to i32
%22 = shl i32 %21, 1
%23 = trunc i32 %22 to i8
store i8 %23, i8* %4
%24 = call i32 (...) @Draco9210ToggleClock()
br label %25
25: ; preds = %11
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %8
28: ; preds = %8
%29 = call zeroext i8 (...) @Draco9210ReadDataIn()
store i8 %29, i8* %5
%30 = load i8, i8* %5
%31 = zext i8 %30 to i32
%32 = and i32 %31, 1
%33 = load i8, i8* %4
%34 = zext i8 %33 to i32
%35 = or i32 %34, %32
%36 = trunc i32 %35 to i8
store i8 %36, i8* %4
%37 = load i8, i8* %4
%38 = load i8*, i8** %2
store i8 %37, i8* %38
ret void
}

LLVM IR (-O2):
define void @DracoReadData(i8* nocapture writeonly %0) {
%2 = tail call i32 (...) @Draco9210ClearDataOut()
%3 = tail call i32 (...) @Draco9210ToggleClock()
%4 = tail call zeroext i8 (...) @Draco9210ReadDataIn()
%5 = shl i8 %4, 1
%6 = and i8 %5, 2
%7 = tail call i32 (...) @Draco9210ToggleClock()
%8 = tail call zeroext i8 (...) @Draco9210ReadDataIn()
%9 = and i8 %8, 1
%10 = or i8 %9, %6
%11 = tail call i32 (...) @Draco9210ToggleClock()
%12 = tail call zeroext i8 (...) @Draco9210ReadDataIn()
%13 = shl nuw nsw i8 %10, 2
%14 = shl i8 %12, 1
%15 = and i8 %14, 2
%16 = or i8 %13, %15
%17 = tail call i32 (...) @Draco9210ToggleClock()
%18 = tail call zeroext i8 (...) @Draco9210ReadDataIn()
%19 = and i8 %18, 1
%20 = or i8 %19, %16
%21 = tail call i32 (...) @Draco9210ToggleClock()
%22 = tail call zeroext i8 (...) @Draco9210ReadDataIn()
%23 = shl nuw nsw i8 %20, 2
%24 = shl i8 %22, 1
%25 = and i8 %24, 2
%26 = or i8 %23, %25
%27 = tail call i32 (...) @Draco9210ToggleClock()
%28 = tail call zeroext i8 (...) @Draco9210ReadDataIn()
%29 = and i8 %28, 1
%30 = or i8 %29, %26
%31 = tail call i32 (...) @Draco9210ToggleClock()
%32 = tail call zeroext i8 (...) @Draco9210ReadDataIn()
%33 = shl i8 %30, 2
%34 = shl i8 %32, 1
%35 = and i8 %34, 2
%36 = or i8 %33, %35
%37 = tail call i32 (...) @Draco9210ToggleClock()
%38 = tail call zeroext i8 (...) @Draco9210ReadDataIn()
%39 = and i8 %38, 1
%40 = or i8 %39, %36
store i8 %40, i8* %0
ret void
}