#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ BusyWait(int);
scalar_t__ getpin();
int /*<<< orphan*/ setpin0();
int /*<<< orphan*/ setpinhiz();
uint32_t xferbyte(uint32_t thebyte) {
  for (uint32_t bits = 0; bits < 8; bits++) {
    setpin0();
    BusyWait(((uint32_t)(((((double)1.5 * (double)(5 * 11059200)) /
                           ((double)(7) * 1000.0f * 1000.0f))) +
                         0.5f)));
    if (thebyte & 0x01)
      setpinhiz();
    thebyte >>= 1;
    BusyWait(((uint32_t)(((((double)13 * (double)(5 * 11059200)) /
                           ((double)(7) * 1000.0f * 1000.0f))) +
                         0.5f)));
    if (getpin())
      thebyte |= 0x80;
    BusyWait(((uint32_t)(((((double)45 * (double)(5 * 11059200)) /
                           ((double)(7) * 1000.0f * 1000.0f))) +
                         0.5f)));
    setpinhiz();
    BusyWait(((uint32_t)(((((double)10 * (double)(5 * 11059200)) /
                           ((double)(7) * 1000.0f * 1000.0f))) +
                         0.5f)));
  }
  return thebyte;
}


x86 assembly (clang, -O0):
<xferbyte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    11db <xferbyte+0x9b>
mov    $0x0,%al
call   1030 <setpin0@plt>
mov    $0xc,%edi
call   1040 <BusyWait@plt>
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1183 <xferbyte+0x43>
mov    $0x0,%al
call   1050 <setpinhiz@plt>
mov    -0x4(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    $0x67,%edi
call   1040 <BusyWait@plt>
mov    $0x0,%al
call   1060 <getpin@plt>
cmp    $0x0,%rax
je     11b2 <xferbyte+0x72>
mov    -0x4(%rbp),%eax
or     $0x80,%eax
mov    %eax,-0x4(%rbp)
mov    $0x163,%edi
call   1040 <BusyWait@plt>
mov    $0x0,%al
call   1050 <setpinhiz@plt>
mov    $0x4f,%edi
call   1040 <BusyWait@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1152 <xferbyte+0x12>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xferbyte>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
mov    $0x8,%r14d
jmp    1194 <xferbyte+0x54>
xchg   %ax,%ax
mov    %ebx,%ebp
sar    %ebp
mov    $0x67,%edi
call   1040 <BusyWait@plt>
xor    %eax,%eax
call   1060 <getpin@plt>
mov    %ebp,%ebx
or     $0x80,%ebx
test   %rax,%rax
cmove  %ebp,%ebx
mov    $0x163,%edi
call   1040 <BusyWait@plt>
xor    %eax,%eax
call   1050 <setpinhiz@plt>
mov    $0x4f,%edi
call   1040 <BusyWait@plt>
add    $0xffffffff,%r14d
je     11b3 <xferbyte+0x73>
xor    %eax,%eax
call   1030 <setpin0@plt>
mov    $0xc,%edi
call   1040 <BusyWait@plt>
test   $0x1,%bl
je     1150 <xferbyte+0x10>
xor    %eax,%eax
call   1050 <setpinhiz@plt>
jmp    1150 <xferbyte+0x10>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @xferbyte(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %28, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 8
br i1 %6, label %7, label %31
7: ; preds = %4
%8 = call i32 (...) @setpin0()
%9 = call i32 @BusyWait(i32 12)
%10 = load i32, i32* %2
%11 = and i32 %10, 1
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = call i32 (...) @setpinhiz()
br label %15
15: ; preds = %13, %7
%16 = load i32, i32* %2
%17 = ashr i32 %16, 1
store i32 %17, i32* %2
%18 = call i32 @BusyWait(i32 103)
%19 = call i64 (...) @getpin()
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load i32, i32* %2
%23 = or i32 %22, 128
store i32 %23, i32* %2
br label %24
24: ; preds = %21, %15
%25 = call i32 @BusyWait(i32 355)
%26 = call i32 (...) @setpinhiz()
%27 = call i32 @BusyWait(i32 79)
br label %28
28: ; preds = %24
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %4
31: ; preds = %4
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
define i32 @xferbyte(i32 %0) {
br label %3
2: ; preds = %12
ret i32 %18
3: ; preds = %1, %12
%4 = phi i32 [ 0, %1 ], [ %22, %12 ]
%5 = phi i32 [ %0, %1 ], [ %18, %12 ]
%6 = tail call i32 (...) @setpin0()
%7 = tail call i32 @BusyWait(i32 12)
%8 = and i32 %5, 1
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %3
%11 = tail call i32 (...) @setpinhiz()
br label %12
12: ; preds = %10, %3
%13 = ashr i32 %5, 1
%14 = tail call i32 @BusyWait(i32 103)
%15 = tail call i64 (...) @getpin()
%16 = icmp eq i64 %15, 0
%17 = or i32 %13, 128
%18 = select i1 %16, i32 %13, i32 %17
%19 = tail call i32 @BusyWait(i32 355)
%20 = tail call i32 (...) @setpinhiz()
%21 = tail call i32 @BusyWait(i32 79)
%22 = add nuw nsw i32 %4, 1
%23 = icmp eq i32 %22, 8
br i1 %23, label %2, label %3
}