#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*/ psoc_clocks(int);
unsigned char psoc_read_byte() {
  unsigned char data;
  int i;
  psoc_clocks(2);
  data = 0;
  for (i = 8; i--;) {
    *(volatile unsigned long *)((void *)0xfffff400 + 0x30) = (1 << (14));
    data <<= 1;
    if (*(volatile unsigned long *)((void *)0xfffff400 + 0x3c) & (1 << (13)))
      data |= 1;
    *(volatile unsigned long *)((void *)0xfffff400 + 0x34) = (1 << (14));
  }
  *(volatile unsigned long *)((void *)0xfffff400 + 0x30) = (1 << (13));
  *(volatile unsigned long *)((void *)0xfffff400 + 0x10) = (1 << (13));
  psoc_clocks(1);
  *(volatile unsigned long *)((void *)0xfffff400 + 0x34) = (1 << (13));
  *(volatile unsigned long *)((void *)0xfffff400 + 0x14) = (1 << (13));
  return data;
}


x86 assembly (clang, -O0):
<psoc_read_byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x2,%edi
call   1030 <psoc_clocks@plt>
movb   $0x0,-0x1(%rbp)
movl   $0x8,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     118d <psoc_read_byte+0x7d>
mov    $0xfffff400,%eax
movq   $0x4000,0x30(%rax)
movzbl -0x1(%rbp),%eax
shl    $0x1,%eax
mov    %al,-0x1(%rbp)
mov    $0xfffff400,%eax
mov    0x3c(%rax),%rax
and    $0x2000,%rax
cmp    $0x0,%rax
je     117b <psoc_read_byte+0x6b>
movzbl -0x1(%rbp),%eax
or     $0x1,%eax
mov    %al,-0x1(%rbp)
mov    $0xfffff400,%eax
movq   $0x4000,0x34(%rax)
jmp    112d <psoc_read_byte+0x1d>
mov    $0xfffff400,%eax
movq   $0x2000,0x30(%rax)
mov    $0xfffff400,%eax
movq   $0x2000,0x10(%rax)
mov    $0x1,%edi
call   1030 <psoc_clocks@plt>
mov    $0xfffff400,%eax
movq   $0x2000,0x34(%rax)
mov    $0xfffff400,%eax
movq   $0x2000,0x14(%rax)
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<psoc_read_byte>:
push   %r14
push   %rbx
push   %rax
mov    $0x2,%edi
call   1030 <psoc_clocks@plt>
mov    $0xfffff430,%r14d
movq   $0x4000,(%r14)
mov    0xc(%r14),%rax
movq   $0x4000,0x4(%r14)
movq   $0x4000,(%r14)
shr    $0xc,%rax
and    $0x2,%al
mov    0xc(%r14),%rcx
shr    $0xd,%rcx
and    $0x1,%cl
or     %al,%cl
movq   $0x4000,0x4(%r14)
movq   $0x4000,(%r14)
mov    0xc(%r14),%rax
movq   $0x4000,0x4(%r14)
movq   $0x4000,(%r14)
shl    $0x2,%cl
shr    $0xc,%rax
and    $0x2,%al
or     %cl,%al
mov    0xc(%r14),%rcx
shr    $0xd,%rcx
and    $0x1,%cl
or     %al,%cl
movq   $0x4000,0x4(%r14)
movq   $0x4000,(%r14)
mov    0xc(%r14),%rax
movq   $0x4000,0x4(%r14)
movq   $0x4000,(%r14)
shl    $0x2,%cl
shr    $0xc,%rax
and    $0x2,%al
or     %cl,%al
mov    0xc(%r14),%rcx
shr    $0xd,%rcx
and    $0x1,%cl
or     %al,%cl
movq   $0x4000,0x4(%r14)
movq   $0x4000,(%r14)
mov    0xc(%r14),%rax
movq   $0x4000,0x4(%r14)
movq   $0x4000,(%r14)
shl    $0x2,%cl
shr    $0xc,%rax
and    $0x2,%al
or     %cl,%al
mov    0xc(%r14),%rbx
shr    $0xd,%rbx
and    $0x1,%bl
or     %al,%bl
movq   $0x4000,0x4(%r14)
movq   $0x2000,(%r14)
movq   $0x2000,-0x20(%r14)
mov    $0x1,%edi
call   1030 <psoc_clocks@plt>
movq   $0x2000,0x4(%r14)
movq   $0x2000,-0x1c(%r14)
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define zeroext i8 @psoc_read_byte() {
%1 = alloca i8
%2 = alloca i32
%3 = call i32 @psoc_clocks(i32 2)
store i8 0, i8* %1
store i32 8, i32* %2
br label %4
4: ; preds = %21, %0
%5 = load i32, i32* %2
%6 = add nsw i32 %5, -1
store i32 %6, i32* %2
%7 = icmp ne i32 %5, 0
br i1 %7, label %8, label %22
8: ; preds = %4
store volatile i64 16384, i64* bitcast (i8* getelementptr (i8, i8* inttoptr (i64 4294964224 to i8*), i64 48) to i64*)
%9 = load i8, i8* %1
%10 = zext i8 %9 to i32
%11 = shl i32 %10, 1
%12 = trunc i32 %11 to i8
store i8 %12, i8* %1
%13 = load volatile i64, i64* bitcast (i8* getelementptr (i8, i8* inttoptr (i64 4294964224 to i8*), i64 60) to i64*)
%14 = and i64 %13, 8192
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %8
%17 = load i8, i8* %1
%18 = zext i8 %17 to i32
%19 = or i32 %18, 1
%20 = trunc i32 %19 to i8
store i8 %20, i8* %1
br label %21
21: ; preds = %16, %8
store volatile i64 16384, i64* bitcast (i8* getelementptr (i8, i8* inttoptr (i64 4294964224 to i8*), i64 52) to i64*)
br label %4
22: ; preds = %4
store volatile i64 8192, i64* bitcast (i8* getelementptr (i8, i8* inttoptr (i64 4294964224 to i8*), i64 48) to i64*)
store volatile i64 8192, i64* bitcast (i8* getelementptr (i8, i8* inttoptr (i64 4294964224 to i8*), i64 16) to i64*)
%23 = call i32 @psoc_clocks(i32 1)
store volatile i64 8192, i64* bitcast (i8* getelementptr (i8, i8* inttoptr (i64 4294964224 to i8*), i64 52) to i64*)
store volatile i64 8192, i64* bitcast (i8* getelementptr (i8, i8* inttoptr (i64 4294964224 to i8*), i64 20) to i64*)
%24 = load i8, i8* %1
ret i8 %24
}

LLVM IR (-O2):
define zeroext i8 @psoc_read_byte() {
%1 = tail call i32 @psoc_clocks(i32 2)
store volatile i64 16384, i64* inttoptr (i64 4294964272 to i64*)
%2 = load volatile i64, i64* inttoptr (i64 4294964284 to i64*)
store volatile i64 16384, i64* inttoptr (i64 4294964276 to i64*)
store volatile i64 16384, i64* inttoptr (i64 4294964272 to i64*)
%3 = lshr i64 %2, 12
%4 = trunc i64 %3 to i8
%5 = and i8 %4, 2
%6 = load volatile i64, i64* inttoptr (i64 4294964284 to i64*)
%7 = lshr i64 %6, 13
%8 = trunc i64 %7 to i8
%9 = and i8 %8, 1
%10 = or i8 %9, %5
store volatile i64 16384, i64* inttoptr (i64 4294964276 to i64*)
store volatile i64 16384, i64* inttoptr (i64 4294964272 to i64*)
%11 = load volatile i64, i64* inttoptr (i64 4294964284 to i64*)
store volatile i64 16384, i64* inttoptr (i64 4294964276 to i64*)
store volatile i64 16384, i64* inttoptr (i64 4294964272 to i64*)
%12 = shl nuw nsw i8 %10, 2
%13 = lshr i64 %11, 12
%14 = trunc i64 %13 to i8
%15 = and i8 %14, 2
%16 = or i8 %12, %15
%17 = load volatile i64, i64* inttoptr (i64 4294964284 to i64*)
%18 = lshr i64 %17, 13
%19 = trunc i64 %18 to i8
%20 = and i8 %19, 1
%21 = or i8 %20, %16
store volatile i64 16384, i64* inttoptr (i64 4294964276 to i64*)
store volatile i64 16384, i64* inttoptr (i64 4294964272 to i64*)
%22 = load volatile i64, i64* inttoptr (i64 4294964284 to i64*)
store volatile i64 16384, i64* inttoptr (i64 4294964276 to i64*)
store volatile i64 16384, i64* inttoptr (i64 4294964272 to i64*)
%23 = shl nuw nsw i8 %21, 2
%24 = lshr i64 %22, 12
%25 = trunc i64 %24 to i8
%26 = and i8 %25, 2
%27 = or i8 %23, %26
%28 = load volatile i64, i64* inttoptr (i64 4294964284 to i64*)
%29 = lshr i64 %28, 13
%30 = trunc i64 %29 to i8
%31 = and i8 %30, 1
%32 = or i8 %31, %27
store volatile i64 16384, i64* inttoptr (i64 4294964276 to i64*)
store volatile i64 16384, i64* inttoptr (i64 4294964272 to i64*)
%33 = load volatile i64, i64* inttoptr (i64 4294964284 to i64*)
store volatile i64 16384, i64* inttoptr (i64 4294964276 to i64*)
store volatile i64 16384, i64* inttoptr (i64 4294964272 to i64*)
%34 = shl i8 %32, 2
%35 = lshr i64 %33, 12
%36 = trunc i64 %35 to i8
%37 = and i8 %36, 2
%38 = or i8 %34, %37
%39 = load volatile i64, i64* inttoptr (i64 4294964284 to i64*)
%40 = lshr i64 %39, 13
%41 = trunc i64 %40 to i8
%42 = and i8 %41, 1
%43 = or i8 %42, %38
store volatile i64 16384, i64* inttoptr (i64 4294964276 to i64*)
store volatile i64 8192, i64* inttoptr (i64 4294964272 to i64*)
store volatile i64 8192, i64* inttoptr (i64 4294964240 to i64*)
%44 = tail call i32 @psoc_clocks(i32 1)
store volatile i64 8192, i64* inttoptr (i64 4294964276 to i64*)
store volatile i64 8192, i64* inttoptr (i64 4294964244 to i64*)
ret i8 %43
}