#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*/ CHECK(int, int, int, int, int, char *);
int gpioRead(int);
int gpioRead_Bits_0_31();
int gpioRead_Bits_32_53();
int /*<<< orphan*/ gpioWrite(int, int);
int /*<<< orphan*/ gpioWrite_Bits_0_31_Clear(int);
int /*<<< orphan*/ gpioWrite_Bits_0_31_Set(int);
int gpioWrite_Bits_32_53_Clear(int /*<<< orphan*/);
int gpioWrite_Bits_32_53_Set(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
void t8() {
  int v, t, i;
  printf("Bank read/write tests.\n");
  gpioWrite(4, 0);
  v = gpioRead_Bits_0_31() & (1 << 4);
  CHECK(8, 1, v, 0, 0, "read bank 1");
  gpioWrite(4, 1);
  v = gpioRead_Bits_0_31() & (1 << 4);
  CHECK(8, 2, v, (1 << 4), 0, "read bank 1");
  gpioWrite_Bits_0_31_Clear(1 << 4);
  v = gpioRead(4);
  CHECK(8, 3, v, 0, 0, "clear bank 1");
  gpioWrite_Bits_0_31_Set(1 << 4);
  v = gpioRead(4);
  CHECK(8, 4, v, 1, 0, "set bank 1");
  t = 0;
  v = (1 << 16);
  for (i = 0; i < 100; i++) {
    if (gpioRead_Bits_32_53() & v)
      t++;
  };
  CHECK(8, 5, t, 60, 75, "read bank 2");
  v = gpioWrite_Bits_32_53_Clear(0);
  CHECK(8, 6, v, 0, 0, "clear bank 2");
  CHECK(8, 7, 0, 0, 0, "NOT APPLICABLE");
  v = gpioWrite_Bits_32_53_Set(0);
  CHECK(8, 8, v, 0, 0, "set bank 2");
  CHECK(8, 9, 0, 0, 0, "NOT APPLICABLE");
}


x86 assembly (clang, -O0):
<t8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe51(%rip),%rdi
call   1070 <printf@plt>
mov    $0x4,%edi
xor    %esi,%esi
call   10c0 <gpioWrite@plt>
mov    $0x0,%al
call   1060 <gpioRead_Bits_0_31@plt>
and    $0x10,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edx
mov    $0x8,%edi
mov    $0x1,%esi
xor    %r8d,%r8d
lea    0xe34(%rip),%r9
mov    %r8d,%ecx
call   1030 <CHECK@plt>
mov    $0x4,%edi
mov    $0x1,%esi
call   10c0 <gpioWrite@plt>
mov    $0x0,%al
call   1060 <gpioRead_Bits_0_31@plt>
and    $0x10,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edx
mov    $0x8,%edi
mov    $0x2,%esi
mov    $0x10,%ecx
xor    %r8d,%r8d
lea    0xdf4(%rip),%r9
call   1030 <CHECK@plt>
mov    $0x10,%edi
call   1040 <gpioWrite_Bits_0_31_Clear@plt>
mov    $0x4,%edi
call   10b0 <gpioRead@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edx
mov    $0x8,%edi
mov    $0x3,%esi
xor    %r8d,%r8d
lea    0xdcd(%rip),%r9
mov    %r8d,%ecx
call   1030 <CHECK@plt>
mov    $0x10,%edi
call   10a0 <gpioWrite_Bits_0_31_Set@plt>
mov    $0x4,%edi
call   10b0 <gpioRead@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edx
mov    $0x8,%edi
mov    $0x4,%esi
mov    $0x1,%ecx
xor    %r8d,%r8d
lea    0xd9f(%rip),%r9
call   1030 <CHECK@plt>
movl   $0x0,-0x8(%rbp)
movl   $0x10000,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jge    12e5 <t8+0x145>
mov    $0x0,%al
call   1080 <gpioRead_Bits_32_53@plt>
and    -0x4(%rbp),%eax
cmp    $0x0,%eax
je     12d2 <t8+0x132>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    12d7 <t8+0x137>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    12ac <t8+0x10c>
mov    -0x8(%rbp),%edx
mov    $0x8,%edi
mov    $0x5,%esi
mov    $0x3c,%ecx
mov    $0x4b,%r8d
lea    0xd38(%rip),%r9
call   1030 <CHECK@plt>
xor    %edi,%edi
call   1090 <gpioWrite_Bits_32_53_Clear@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edx
mov    $0x8,%edi
mov    $0x6,%esi
xor    %r8d,%r8d
lea    0xd1e(%rip),%r9
mov    %r8d,%ecx
call   1030 <CHECK@plt>
mov    $0x8,%edi
mov    $0x7,%esi
xor    %r8d,%r8d
lea    0xd0f(%rip),%r9
mov    %r8d,%edx
mov    %r8d,%ecx
call   1030 <CHECK@plt>
xor    %edi,%edi
call   1050 <gpioWrite_Bits_32_53_Set@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edx
mov    $0x8,%esi
xor    %r8d,%r8d
lea    0xcf7(%rip),%r9
mov    %esi,%edi
mov    %r8d,%ecx
call   1030 <CHECK@plt>
mov    $0x8,%edi
mov    $0x9,%esi
xor    %r8d,%r8d
lea    0xcca(%rip),%r9
mov    %r8d,%edx
mov    %r8d,%ecx
call   1030 <CHECK@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t8>:
push   %rbp
push   %rbx
push   %rax
lea    0xead(%rip),%rdi
call   1040 <puts@plt>
mov    $0x4,%edi
xor    %esi,%esi
call   10c0 <gpioWrite@plt>
xor    %eax,%eax
call   1070 <gpioRead_Bits_0_31@plt>
and    $0x10,%eax
lea    0xe34(%rip),%rbx
mov    $0x8,%edi
mov    $0x1,%esi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %rbx,%r9
call   1030 <CHECK@plt>
mov    $0x4,%edi
mov    $0x1,%esi
call   10c0 <gpioWrite@plt>
xor    %eax,%eax
call   1070 <gpioRead_Bits_0_31@plt>
and    $0x10,%eax
mov    $0x8,%edi
mov    $0x2,%esi
mov    %eax,%edx
mov    $0x10,%ecx
xor    %r8d,%r8d
mov    %rbx,%r9
call   1030 <CHECK@plt>
mov    $0x10,%edi
call   1050 <gpioWrite_Bits_0_31_Clear@plt>
mov    $0x4,%edi
call   10b0 <gpioRead@plt>
lea    0xdd7(%rip),%r9
mov    $0x8,%edi
mov    $0x3,%esi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <CHECK@plt>
mov    $0x10,%edi
call   10a0 <gpioWrite_Bits_0_31_Set@plt>
mov    $0x4,%edi
call   10b0 <gpioRead@plt>
lea    0xdb3(%rip),%r9
mov    $0x8,%edi
mov    $0x4,%esi
mov    %eax,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1030 <CHECK@plt>
mov    $0x64,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <gpioRead_Bits_32_53@plt>
shr    $0x10,%eax
and    $0x1,%eax
add    %eax,%ebx
add    $0xffffffff,%ebp
jne    1290 <t8+0xf0>
lea    0xd79(%rip),%r9
mov    $0x8,%edi
mov    $0x5,%esi
mov    %ebx,%edx
mov    $0x3c,%ecx
mov    $0x4b,%r8d
call   1030 <CHECK@plt>
xor    %edi,%edi
call   1090 <gpioWrite_Bits_32_53_Clear@plt>
lea    0xd5b(%rip),%r9
mov    $0x8,%edi
mov    $0x6,%esi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <CHECK@plt>
lea    0xd4b(%rip),%rbx
mov    $0x8,%edi
mov    $0x7,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %rbx,%r9
call   1030 <CHECK@plt>
xor    %edi,%edi
call   1060 <gpioWrite_Bits_32_53_Set@plt>
lea    0xd33(%rip),%r9
mov    $0x8,%edi
mov    $0x8,%esi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <CHECK@plt>
mov    $0x8,%edi
mov    $0x9,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %rbx,%r9
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <CHECK@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"Bank read/write tests.\0A\00"
@.str.1 = [12 x i8] c"read bank 1\00"
@.str.2 = [13 x i8] c"clear bank 1\00"
@.str.3 = [11 x i8] c"set bank 1\00"
@.str.4 = [12 x i8] c"read bank 2\00"
@.str.5 = [13 x i8] c"clear bank 2\00"
@.str.6 = [15 x i8] c"NOT APPLICABLE\00"
@.str.7 = [11 x i8] c"set bank 2\00"
define void @t8() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @gpioWrite(i32 4, i32 0)
%6 = call i32 (...) @gpioRead_Bits_0_31()
%7 = and i32 %6, 16
store i32 %7, i32* %1
%8 = load i32, i32* %1
%9 = call i32 @CHECK(i32 8, i32 1, i32 %8, i32 0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @gpioWrite(i32 4, i32 1)
%11 = call i32 (...) @gpioRead_Bits_0_31()
%12 = and i32 %11, 16
store i32 %12, i32* %1
%13 = load i32, i32* %1
%14 = call i32 @CHECK(i32 8, i32 2, i32 %13, i32 16, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @gpioWrite_Bits_0_31_Clear(i32 16)
%16 = call i32 @gpioRead(i32 4)
store i32 %16, i32* %1
%17 = load i32, i32* %1
%18 = call i32 @CHECK(i32 8, i32 3, i32 %17, i32 0, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @gpioWrite_Bits_0_31_Set(i32 16)
%20 = call i32 @gpioRead(i32 4)
store i32 %20, i32* %1
%21 = load i32, i32* %1
%22 = call i32 @CHECK(i32 8, i32 4, i32 %21, i32 1, i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
store i32 65536, i32* %1
store i32 0, i32* %3
br label %23
23: ; preds = %35, %0
%24 = load i32, i32* %3
%25 = icmp slt i32 %24, 100
br i1 %25, label %26, label %38
26: ; preds = %23
%27 = call i32 (...) @gpioRead_Bits_32_53()
%28 = load i32, i32* %1
%29 = and i32 %27, %28
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %34
34: ; preds = %31, %26
br label %35
35: ; preds = %34
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 1
store i32 %37, i32* %3
br label %23
38: ; preds = %23
%39 = load i32, i32* %2
%40 = call i32 @CHECK(i32 8, i32 5, i32 %39, i32 60, i32 75, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%41 = call i32 @gpioWrite_Bits_32_53_Clear(i32 0)
store i32 %41, i32* %1
%42 = load i32, i32* %1
%43 = call i32 @CHECK(i32 8, i32 6, i32 %42, i32 0, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%44 = call i32 @CHECK(i32 8, i32 7, i32 0, i32 0, i32 0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%45 = call i32 @gpioWrite_Bits_32_53_Set(i32 0)
store i32 %45, i32* %1
%46 = load i32, i32* %1
%47 = call i32 @CHECK(i32 8, i32 8, i32 %46, i32 0, i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%48 = call i32 @CHECK(i32 8, i32 9, i32 0, i32 0, i32 0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [12 x i8] c"read bank 1\00"
@.str.2 = [13 x i8] c"clear bank 1\00"
@.str.3 = [11 x i8] c"set bank 1\00"
@.str.4 = [12 x i8] c"read bank 2\00"
@.str.5 = [13 x i8] c"clear bank 2\00"
@.str.6 = [15 x i8] c"NOT APPLICABLE\00"
@.str.7 = [11 x i8] c"set bank 2\00"
@str = [23 x i8] c"Bank read/write tests.\00"
define void @t8() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @gpioWrite(i32 4, i32 0)
%3 = tail call i32 (...) @gpioRead_Bits_0_31()
%4 = and i32 %3, 16
%5 = tail call i32 @CHECK(i32 8, i32 1, i32 %4, i32 0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @gpioWrite(i32 4, i32 1)
%7 = tail call i32 (...) @gpioRead_Bits_0_31()
%8 = and i32 %7, 16
%9 = tail call i32 @CHECK(i32 8, i32 2, i32 %8, i32 16, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @gpioWrite_Bits_0_31_Clear(i32 16)
%11 = tail call i32 @gpioRead(i32 4)
%12 = tail call i32 @CHECK(i32 8, i32 3, i32 %11, i32 0, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @gpioWrite_Bits_0_31_Set(i32 16)
%14 = tail call i32 @gpioRead(i32 4)
%15 = tail call i32 @CHECK(i32 8, i32 4, i32 %14, i32 1, i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %16
16: ; preds = %0, %16
%17 = phi i32 [ 0, %0 ], [ %23, %16 ]
%18 = phi i32 [ 0, %0 ], [ %22, %16 ]
%19 = tail call i32 (...) @gpioRead_Bits_32_53()
%20 = lshr i32 %19, 16
%21 = and i32 %20, 1
%22 = add nuw nsw i32 %21, %18
%23 = add nuw nsw i32 %17, 1
%24 = icmp eq i32 %23, 100
br i1 %24, label %25, label %16
25: ; preds = %16
%26 = tail call i32 @CHECK(i32 8, i32 5, i32 %22, i32 60, i32 75, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%27 = tail call i32 @gpioWrite_Bits_32_53_Clear(i32 0)
%28 = tail call i32 @CHECK(i32 8, i32 6, i32 %27, i32 0, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%29 = tail call i32 @CHECK(i32 8, i32 7, i32 0, i32 0, i32 0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%30 = tail call i32 @gpioWrite_Bits_32_53_Set(i32 0)
%31 = tail call i32 @CHECK(i32 8, i32 8, i32 %30, i32 0, i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%32 = tail call i32 @CHECK(i32 8, i32 9, i32 0, i32 0, i32 0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
ret void
}