#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 GPIOPinRead(int, int);
int /*<<< orphan*/ GPIOPinTypeGPIOInput(int, int);
int /*<<< orphan*/ GPIOPinTypeGPIOOutput(int, int);
int /*<<< orphan*/ GPIOPinWrite(int, int, int);
unsigned char ADSGetByteB() {
  unsigned char i = 0;
  unsigned int temp = 0;
  GPIOPinTypeGPIOInput(0x40007000, 0x00000020);
  for (i = 0; i < 8; i++) {
    temp = temp << 1;
    GPIOPinWrite(0x40007000, 0x00000010, 0x00);
    GPIOPinWrite(0x40007000, 0x00000010, 0xff);
    if ((GPIOPinRead(0x40007000, 0x00000020) & 0x00000020)) {
      temp |= 0x01;
    }
  }
  GPIOPinTypeGPIOOutput(0x40007000, 0x00000020);
  GPIOPinWrite(0x40007000, 0x00000010, 0x00);
  GPIOPinWrite(0x40007000, 0x00000020, 0x00);
  GPIOPinWrite(0x40007000, 0x00000010, 0xff);
  GPIOPinWrite(0x40007000, 0x00000010, 0x00);
  GPIOPinWrite(0x40007000, 0x00000020, 0xff);
  return temp;
}


x86 assembly (clang, -O0):
<ADSGetByteB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movb   $0x0,-0x1(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x40007000,%edi
mov    $0x20,%esi
call   1030 <GPIOPinTypeGPIOInput@plt>
movb   $0x0,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x8,%eax
jge    11d7 <ADSGetByteB+0x97>
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x40007000,%edi
mov    $0x10,%esi
xor    %edx,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x10,%esi
mov    $0xff,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x20,%esi
call   1040 <GPIOPinRead@plt>
and    $0x20,%eax
cmp    $0x0,%eax
je     11c5 <ADSGetByteB+0x85>
mov    -0x8(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ca <ADSGetByteB+0x8a>
mov    -0x1(%rbp),%al
add    $0x1,%al
mov    %al,-0x1(%rbp)
jmp    1166 <ADSGetByteB+0x26>
mov    $0x40007000,%edi
mov    $0x20,%esi
call   1050 <GPIOPinTypeGPIOOutput@plt>
mov    $0x40007000,%edi
mov    $0x10,%esi
xor    %edx,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x20,%esi
xor    %edx,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x10,%esi
mov    $0xff,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x10,%esi
xor    %edx,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x20,%esi
mov    $0xff,%edx
call   1060 <GPIOPinWrite@plt>
mov    -0x8(%rbp),%eax
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ADSGetByteB>:
push   %rbp
push   %rbx
push   %rax
mov    $0x40007000,%edi
mov    $0x20,%esi
call   1030 <GPIOPinTypeGPIOInput@plt>
mov    $0x40007000,%edi
mov    $0x10,%esi
xor    %edx,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x10,%esi
mov    $0xff,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x20,%esi
call   1040 <GPIOPinRead@plt>
mov    %eax,%ebp
shr    $0x4,%ebp
and    $0x2,%ebp
mov    $0x40007000,%edi
mov    $0x10,%esi
xor    %edx,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x10,%esi
mov    $0xff,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x20,%esi
call   1040 <GPIOPinRead@plt>
mov    %eax,%ebx
shr    $0x5,%ebx
and    $0x1,%ebx
or     %ebp,%ebx
mov    $0x40007000,%edi
mov    $0x10,%esi
xor    %edx,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x10,%esi
mov    $0xff,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x20,%esi
call   1040 <GPIOPinRead@plt>
shr    $0x4,%eax
and    $0x2,%eax
lea    (%rax,%rbx,4),%ebp
mov    $0x40007000,%edi
mov    $0x10,%esi
xor    %edx,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x10,%esi
mov    $0xff,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x20,%esi
call   1040 <GPIOPinRead@plt>
mov    %eax,%ebx
shr    $0x5,%ebx
and    $0x1,%ebx
or     %ebp,%ebx
mov    $0x40007000,%edi
mov    $0x10,%esi
xor    %edx,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x10,%esi
mov    $0xff,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x20,%esi
call   1040 <GPIOPinRead@plt>
shr    $0x4,%eax
and    $0x2,%eax
lea    (%rax,%rbx,4),%ebp
mov    $0x40007000,%edi
mov    $0x10,%esi
xor    %edx,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x10,%esi
mov    $0xff,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x20,%esi
call   1040 <GPIOPinRead@plt>
mov    %eax,%ebx
shr    $0x5,%ebx
and    $0x1,%ebx
or     %ebp,%ebx
mov    $0x40007000,%edi
mov    $0x10,%esi
xor    %edx,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x10,%esi
mov    $0xff,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x20,%esi
call   1040 <GPIOPinRead@plt>
shr    $0x4,%eax
and    $0x2,%eax
lea    (%rax,%rbx,4),%ebp
mov    $0x40007000,%edi
mov    $0x10,%esi
xor    %edx,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x10,%esi
mov    $0xff,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x20,%esi
call   1040 <GPIOPinRead@plt>
mov    %eax,%ebx
shr    $0x5,%ebx
and    $0x1,%ebx
or     %ebp,%ebx
mov    $0x40007000,%edi
mov    $0x20,%esi
call   1050 <GPIOPinTypeGPIOOutput@plt>
mov    $0x40007000,%edi
mov    $0x10,%esi
xor    %edx,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x20,%esi
xor    %edx,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x10,%esi
mov    $0xff,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x10,%esi
xor    %edx,%edx
call   1060 <GPIOPinWrite@plt>
mov    $0x40007000,%edi
mov    $0x20,%esi
mov    $0xff,%edx
call   1060 <GPIOPinWrite@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define zeroext i8 @ADSGetByteB() {
%1 = alloca i8
%2 = alloca i32
store i8 0, i8* %1
store i32 0, i32* %2
%3 = call i32 @GPIOPinTypeGPIOInput(i32 1073770496, i32 32)
store i8 0, i8* %1
br label %4
4: ; preds = %20, %0
%5 = load i8, i8* %1
%6 = zext i8 %5 to i32
%7 = icmp slt i32 %6, 8
br i1 %7, label %8, label %23
8: ; preds = %4
%9 = load i32, i32* %2
%10 = shl i32 %9, 1
store i32 %10, i32* %2
%11 = call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 0)
%12 = call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 255)
%13 = call i32 @GPIOPinRead(i32 1073770496, i32 32)
%14 = and i32 %13, 32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %8
%17 = load i32, i32* %2
%18 = or i32 %17, 1
store i32 %18, i32* %2
br label %19
19: ; preds = %16, %8
br label %20
20: ; preds = %19
%21 = load i8, i8* %1
%22 = add i8 %21, 1
store i8 %22, i8* %1
br label %4
23: ; preds = %4
%24 = call i32 @GPIOPinTypeGPIOOutput(i32 1073770496, i32 32)
%25 = call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 0)
%26 = call i32 @GPIOPinWrite(i32 1073770496, i32 32, i32 0)
%27 = call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 255)
%28 = call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 0)
%29 = call i32 @GPIOPinWrite(i32 1073770496, i32 32, i32 255)
%30 = load i32, i32* %2
%31 = trunc i32 %30 to i8
ret i8 %31
}

LLVM IR (-O2):
define zeroext i8 @ADSGetByteB() {
%1 = tail call i32 @GPIOPinTypeGPIOInput(i32 1073770496, i32 32)
%2 = tail call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 0)
%3 = tail call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 255)
%4 = tail call i32 @GPIOPinRead(i32 1073770496, i32 32)
%5 = lshr i32 %4, 4
%6 = and i32 %5, 2
%7 = tail call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 0)
%8 = tail call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 255)
%9 = tail call i32 @GPIOPinRead(i32 1073770496, i32 32)
%10 = lshr i32 %9, 5
%11 = and i32 %10, 1
%12 = or i32 %11, %6
%13 = tail call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 0)
%14 = tail call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 255)
%15 = tail call i32 @GPIOPinRead(i32 1073770496, i32 32)
%16 = shl nuw nsw i32 %12, 2
%17 = lshr i32 %15, 4
%18 = and i32 %17, 2
%19 = or i32 %16, %18
%20 = tail call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 0)
%21 = tail call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 255)
%22 = tail call i32 @GPIOPinRead(i32 1073770496, i32 32)
%23 = lshr i32 %22, 5
%24 = and i32 %23, 1
%25 = or i32 %24, %19
%26 = tail call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 0)
%27 = tail call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 255)
%28 = tail call i32 @GPIOPinRead(i32 1073770496, i32 32)
%29 = shl nuw nsw i32 %25, 2
%30 = lshr i32 %28, 4
%31 = and i32 %30, 2
%32 = or i32 %29, %31
%33 = tail call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 0)
%34 = tail call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 255)
%35 = tail call i32 @GPIOPinRead(i32 1073770496, i32 32)
%36 = lshr i32 %35, 5
%37 = and i32 %36, 1
%38 = or i32 %37, %32
%39 = tail call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 0)
%40 = tail call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 255)
%41 = tail call i32 @GPIOPinRead(i32 1073770496, i32 32)
%42 = shl i32 %38, 2
%43 = lshr i32 %41, 4
%44 = and i32 %43, 2
%45 = or i32 %42, %44
%46 = tail call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 0)
%47 = tail call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 255)
%48 = tail call i32 @GPIOPinRead(i32 1073770496, i32 32)
%49 = lshr i32 %48, 5
%50 = and i32 %49, 1
%51 = or i32 %50, %45
%52 = tail call i32 @GPIOPinTypeGPIOOutput(i32 1073770496, i32 32)
%53 = tail call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 0)
%54 = tail call i32 @GPIOPinWrite(i32 1073770496, i32 32, i32 0)
%55 = tail call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 255)
%56 = tail call i32 @GPIOPinWrite(i32 1073770496, i32 16, i32 0)
%57 = tail call i32 @GPIOPinWrite(i32 1073770496, i32 32, i32 255)
%58 = trunc i32 %51 to i8
ret i8 %58
}