#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*/ TwDelay(int);
unsigned char TwGet(void) {
  unsigned char rc = 0;
  int i;
  (*((volatile unsigned int *)((0xFFFF0000 + 0x14))) = ((1 << 16)));
  for (i = 0x80; i; i >>= 1) {
    TwDelay(8);
    (*((volatile unsigned int *)((0xFFFF0000 + 0x14))) = ((1 << 17)));
    TwDelay(2 * 8);
    if (((*((volatile unsigned int *)((0xFFFF0000 + 0x3C)))) & (1 << 16))) {
      rc |= i;
    }
    (*((volatile unsigned int *)((0xFFFF0000 + 0x10))) = ((1 << 17)));
  }
  return rc;
}


x86 assembly (clang, -O0):
<TwGet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movb   $0x0,-0x1(%rbp)
mov    $0xffff0014,%eax
movl   $0x10000,(%rax)
movl   $0x80,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1191 <TwGet+0x81>
mov    $0x8,%edi
call   1030 <TwDelay@plt>
mov    $0xffff0014,%eax
movl   $0x20000,(%rax)
mov    $0x10,%edi
call   1030 <TwDelay@plt>
mov    $0xffff003c,%eax
mov    (%rax),%eax
and    $0x10000,%eax
cmp    $0x0,%eax
je     1178 <TwGet+0x68>
mov    -0x8(%rbp),%ecx
movzbl -0x1(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x1(%rbp)
mov    $0xffff0010,%eax
movl   $0x20000,(%rax)
mov    -0x8(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    112e <TwGet+0x1e>
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TwGet>:
push   %rbp
push   %r14
push   %rbx
mov    $0xffff0014,%r14d
movl   $0x10000,(%r14)
mov    $0x8,%edi
call   1030 <TwDelay@plt>
movl   $0x20000,(%r14)
mov    $0x10,%edi
call   1030 <TwDelay@plt>
mov    0x28(%r14),%ebp
shr    $0x9,%ebp
and    $0x80,%bpl
movl   $0x20000,-0x4(%r14)
mov    $0x8,%edi
call   1030 <TwDelay@plt>
movl   $0x20000,(%r14)
mov    $0x10,%edi
call   1030 <TwDelay@plt>
mov    0x28(%r14),%ebx
shr    $0xa,%ebx
and    $0x40,%bl
or     %bpl,%bl
movl   $0x20000,-0x4(%r14)
mov    $0x8,%edi
call   1030 <TwDelay@plt>
movl   $0x20000,(%r14)
mov    $0x10,%edi
call   1030 <TwDelay@plt>
mov    0x28(%r14),%ebp
shr    $0xb,%ebp
and    $0x20,%bpl
or     %bl,%bpl
movl   $0x20000,-0x4(%r14)
mov    $0x8,%edi
call   1030 <TwDelay@plt>
movl   $0x20000,(%r14)
mov    $0x10,%edi
call   1030 <TwDelay@plt>
mov    0x28(%r14),%ebx
shr    $0xc,%ebx
and    $0x10,%bl
or     %bpl,%bl
movl   $0x20000,-0x4(%r14)
mov    $0x8,%edi
call   1030 <TwDelay@plt>
movl   $0x20000,(%r14)
mov    $0x10,%edi
call   1030 <TwDelay@plt>
mov    0x28(%r14),%ebp
shr    $0xd,%ebp
and    $0x8,%bpl
or     %bl,%bpl
movl   $0x20000,-0x4(%r14)
mov    $0x8,%edi
call   1030 <TwDelay@plt>
movl   $0x20000,(%r14)
mov    $0x10,%edi
call   1030 <TwDelay@plt>
mov    0x28(%r14),%ebx
shr    $0xe,%ebx
and    $0x4,%bl
or     %bpl,%bl
movl   $0x20000,-0x4(%r14)
mov    $0x8,%edi
call   1030 <TwDelay@plt>
movl   $0x20000,(%r14)
mov    $0x10,%edi
call   1030 <TwDelay@plt>
mov    0x28(%r14),%ebp
shr    $0xf,%ebp
and    $0x2,%bpl
or     %bl,%bpl
movl   $0x20000,-0x4(%r14)
mov    $0x8,%edi
call   1030 <TwDelay@plt>
movl   $0x20000,(%r14)
mov    $0x10,%edi
call   1030 <TwDelay@plt>
mov    0x28(%r14),%eax
shr    $0x10,%eax
and    $0x1,%al
or     %bpl,%al
movl   $0x20000,-0x4(%r14)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define zeroext i8 @TwGet() {
%1 = alloca i8
%2 = alloca i32
store i8 0, i8* %1
store volatile i32 65536, i32* inttoptr (i64 4294901780 to i32*)
store i32 128, i32* %2
br label %3
3: ; preds = %19, %0
%4 = load i32, i32* %2
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %22
6: ; preds = %3
%7 = call i32 @TwDelay(i32 8)
store volatile i32 131072, i32* inttoptr (i64 4294901780 to i32*)
%8 = call i32 @TwDelay(i32 16)
%9 = load volatile i32, i32* inttoptr (i64 4294901820 to i32*)
%10 = and i32 %9, 65536
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %6
%13 = load i32, i32* %2
%14 = load i8, i8* %1
%15 = zext i8 %14 to i32
%16 = or i32 %15, %13
%17 = trunc i32 %16 to i8
store i8 %17, i8* %1
br label %18
18: ; preds = %12, %6
store volatile i32 131072, i32* inttoptr (i64 4294901776 to i32*)
br label %19
19: ; preds = %18
%20 = load i32, i32* %2
%21 = ashr i32 %20, 1
store i32 %21, i32* %2
br label %3
22: ; preds = %3
%23 = load i8, i8* %1
ret i8 %23
}

LLVM IR (-O2):
define zeroext i8 @TwGet() {
store volatile i32 65536, i32* inttoptr (i64 4294901780 to i32*)
%1 = tail call i32 @TwDelay(i32 8)
store volatile i32 131072, i32* inttoptr (i64 4294901780 to i32*)
%2 = tail call i32 @TwDelay(i32 16)
%3 = load volatile i32, i32* inttoptr (i64 4294901820 to i32*)
%4 = lshr i32 %3, 9
%5 = trunc i32 %4 to i8
%6 = and i8 %5, -128
store volatile i32 131072, i32* inttoptr (i64 4294901776 to i32*)
%7 = tail call i32 @TwDelay(i32 8)
store volatile i32 131072, i32* inttoptr (i64 4294901780 to i32*)
%8 = tail call i32 @TwDelay(i32 16)
%9 = load volatile i32, i32* inttoptr (i64 4294901820 to i32*)
%10 = lshr i32 %9, 10
%11 = trunc i32 %10 to i8
%12 = and i8 %11, 64
%13 = or i8 %12, %6
store volatile i32 131072, i32* inttoptr (i64 4294901776 to i32*)
%14 = tail call i32 @TwDelay(i32 8)
store volatile i32 131072, i32* inttoptr (i64 4294901780 to i32*)
%15 = tail call i32 @TwDelay(i32 16)
%16 = load volatile i32, i32* inttoptr (i64 4294901820 to i32*)
%17 = lshr i32 %16, 11
%18 = trunc i32 %17 to i8
%19 = and i8 %18, 32
%20 = or i8 %19, %13
store volatile i32 131072, i32* inttoptr (i64 4294901776 to i32*)
%21 = tail call i32 @TwDelay(i32 8)
store volatile i32 131072, i32* inttoptr (i64 4294901780 to i32*)
%22 = tail call i32 @TwDelay(i32 16)
%23 = load volatile i32, i32* inttoptr (i64 4294901820 to i32*)
%24 = lshr i32 %23, 12
%25 = trunc i32 %24 to i8
%26 = and i8 %25, 16
%27 = or i8 %26, %20
store volatile i32 131072, i32* inttoptr (i64 4294901776 to i32*)
%28 = tail call i32 @TwDelay(i32 8)
store volatile i32 131072, i32* inttoptr (i64 4294901780 to i32*)
%29 = tail call i32 @TwDelay(i32 16)
%30 = load volatile i32, i32* inttoptr (i64 4294901820 to i32*)
%31 = lshr i32 %30, 13
%32 = trunc i32 %31 to i8
%33 = and i8 %32, 8
%34 = or i8 %33, %27
store volatile i32 131072, i32* inttoptr (i64 4294901776 to i32*)
%35 = tail call i32 @TwDelay(i32 8)
store volatile i32 131072, i32* inttoptr (i64 4294901780 to i32*)
%36 = tail call i32 @TwDelay(i32 16)
%37 = load volatile i32, i32* inttoptr (i64 4294901820 to i32*)
%38 = lshr i32 %37, 14
%39 = trunc i32 %38 to i8
%40 = and i8 %39, 4
%41 = or i8 %40, %34
store volatile i32 131072, i32* inttoptr (i64 4294901776 to i32*)
%42 = tail call i32 @TwDelay(i32 8)
store volatile i32 131072, i32* inttoptr (i64 4294901780 to i32*)
%43 = tail call i32 @TwDelay(i32 16)
%44 = load volatile i32, i32* inttoptr (i64 4294901820 to i32*)
%45 = lshr i32 %44, 15
%46 = trunc i32 %45 to i8
%47 = and i8 %46, 2
%48 = or i8 %47, %41
store volatile i32 131072, i32* inttoptr (i64 4294901776 to i32*)
%49 = tail call i32 @TwDelay(i32 8)
store volatile i32 131072, i32* inttoptr (i64 4294901780 to i32*)
%50 = tail call i32 @TwDelay(i32 16)
%51 = load volatile i32, i32* inttoptr (i64 4294901820 to i32*)
%52 = lshr i32 %51, 16
%53 = trunc i32 %52 to i8
%54 = and i8 %53, 1
%55 = or i8 %54, %48
store volatile i32 131072, i32* inttoptr (i64 4294901776 to i32*)
ret i8 %55
}