#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 /*<<< orphan*/, char *);
int /*<<< orphan*/ clear_bank_1(int, int);
int clear_bank_2(int, int);
int gpio_read(int, int);
int /*<<< orphan*/ gpio_write(int, int, int);
int /*<<< orphan*/ printf(char *);
int read_bank_1(int);
int read_bank_2(int);
int /*<<< orphan*/ set_bank_1(int, int);
int set_bank_2(int, int);
void t8(int pi) {
  int v;
  printf("Bank read/write tests.\n");
  gpio_write(pi, 25, 0);
  v = read_bank_1(pi) & (1 << 25);
  CHECK(8, 1, v, 0, 0, "read bank 1");
  gpio_write(pi, 25, 1);
  v = read_bank_1(pi) & (1 << 25);
  CHECK(8, 2, v, (1 << 25), 0, "read bank 1");
  clear_bank_1(pi, 1 << 25);
  v = gpio_read(pi, 25);
  CHECK(8, 3, v, 0, 0, "clear bank 1");
  set_bank_1(pi, 1 << 25);
  v = gpio_read(pi, 25);
  CHECK(8, 4, v, 1, 0, "set bank 1");
  v = read_bank_2(pi);
  if (v)
    v = 0;
  else
    v = 1;
  CHECK(8, 5, v, 0, 0, "read bank 2");
  v = clear_bank_2(pi, 0);
  CHECK(8, 6, v, 0, 0, "clear bank 2");
  v = clear_bank_2(pi, 0xffffff);
  CHECK(8, 7, v, -42, 0, "clear bank 2");
  v = set_bank_2(pi, 0);
  CHECK(8, 8, v, 0, 0, "set bank 2");
  v = set_bank_2(pi, 0xffffff);
  CHECK(8, 9, v, -42, 0, "set bank 2");
}


x86 assembly (clang, -O0):
<t8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xe4e(%rip),%rdi
call   1060 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x19,%esi
xor    %edx,%edx
call   1070 <gpio_write@plt>
mov    -0x4(%rbp),%edi
call   10c0 <read_bank_1@plt>
and    $0x2000000,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
mov    $0x8,%edi
mov    $0x1,%esi
xor    %r8d,%r8d
lea    0xe2b(%rip),%r9
mov    %r8d,%ecx
call   1030 <CHECK@plt>
mov    -0x4(%rbp),%edi
mov    $0x19,%esi
mov    $0x1,%edx
call   1070 <gpio_write@plt>
mov    -0x4(%rbp),%edi
call   10c0 <read_bank_1@plt>
and    $0x2000000,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
mov    $0x8,%edi
mov    $0x2,%esi
mov    $0x2000000,%ecx
xor    %r8d,%r8d
lea    0xde5(%rip),%r9
call   1030 <CHECK@plt>
mov    -0x4(%rbp),%edi
mov    $0x2000000,%esi
call   1040 <clear_bank_1@plt>
mov    -0x4(%rbp),%edi
mov    $0x19,%esi
call   1090 <gpio_read@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
mov    $0x8,%edi
mov    $0x3,%esi
xor    %r8d,%r8d
lea    0xdb8(%rip),%r9
mov    %r8d,%ecx
call   1030 <CHECK@plt>
mov    -0x4(%rbp),%edi
mov    $0x2000000,%esi
call   1050 <set_bank_1@plt>
mov    -0x4(%rbp),%edi
mov    $0x19,%esi
call   1090 <gpio_read@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
mov    $0x8,%edi
mov    $0x4,%esi
mov    $0x1,%ecx
xor    %r8d,%r8d
lea    0xd84(%rip),%r9
call   1030 <CHECK@plt>
mov    -0x4(%rbp),%edi
call   1080 <read_bank_2@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     12d3 <t8+0x133>
movl   $0x0,-0x8(%rbp)
jmp    12da <t8+0x13a>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%edx
mov    $0x8,%edi
mov    $0x5,%esi
xor    %r8d,%r8d
lea    0xd4b(%rip),%r9
mov    %r8d,%ecx
call   1030 <CHECK@plt>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   10a0 <clear_bank_2@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
mov    $0x8,%edi
mov    $0x6,%esi
xor    %r8d,%r8d
lea    0xd2b(%rip),%r9
mov    %r8d,%ecx
call   1030 <CHECK@plt>
mov    -0x4(%rbp),%edi
mov    $0xffffff,%esi
call   10a0 <clear_bank_2@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
mov    $0x8,%edi
mov    $0x7,%esi
mov    $0xffffffd6,%ecx
xor    %r8d,%r8d
lea    0xcf7(%rip),%r9
call   1030 <CHECK@plt>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   10b0 <set_bank_2@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
mov    $0x8,%esi
xor    %r8d,%r8d
lea    0xce0(%rip),%r9
mov    %esi,%edi
mov    %r8d,%ecx
call   1030 <CHECK@plt>
mov    -0x4(%rbp),%edi
mov    $0xffffff,%esi
call   10b0 <set_bank_2@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
mov    $0x8,%edi
mov    $0x9,%esi
mov    $0xffffffd6,%ecx
xor    %r8d,%r8d
lea    0xcaa(%rip),%r9
call   1030 <CHECK@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t8>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xe9b(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%edi
mov    $0x19,%esi
xor    %edx,%edx
call   1070 <gpio_write@plt>
mov    %ebx,%edi
call   10c0 <read_bank_1@plt>
and    $0x2000000,%eax
lea    0xe2d(%rip),%r14
mov    $0x8,%edi
mov    $0x1,%esi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %r14,%r9
call   1030 <CHECK@plt>
mov    %ebx,%edi
mov    $0x19,%esi
mov    $0x1,%edx
call   1070 <gpio_write@plt>
mov    %ebx,%edi
call   10c0 <read_bank_1@plt>
and    $0x2000000,%eax
mov    $0x8,%edi
mov    $0x2,%esi
mov    %eax,%edx
mov    $0x2000000,%ecx
xor    %r8d,%r8d
mov    %r14,%r9
call   1030 <CHECK@plt>
mov    %ebx,%edi
mov    $0x2000000,%esi
call   1050 <clear_bank_1@plt>
mov    %ebx,%edi
mov    $0x19,%esi
call   1090 <gpio_read@plt>
lea    0xdc8(%rip),%r9
mov    $0x8,%edi
mov    $0x3,%esi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <CHECK@plt>
mov    %ebx,%edi
mov    $0x2000000,%esi
call   1060 <set_bank_1@plt>
mov    %ebx,%edi
mov    $0x19,%esi
call   1090 <gpio_read@plt>
lea    0xda0(%rip),%r9
mov    $0x8,%edi
mov    $0x4,%esi
mov    %eax,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1030 <CHECK@plt>
mov    %ebx,%edi
call   1080 <read_bank_2@plt>
xor    %edx,%edx
test   %eax,%eax
sete   %dl
lea    0xd7d(%rip),%r9
mov    $0x8,%edi
mov    $0x5,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <CHECK@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   10a0 <clear_bank_2@plt>
lea    0xd65(%rip),%r14
mov    $0x8,%edi
mov    $0x6,%esi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %r14,%r9
call   1030 <CHECK@plt>
mov    %ebx,%edi
mov    $0xffffff,%esi
call   10a0 <clear_bank_2@plt>
mov    $0x8,%edi
mov    $0x7,%esi
mov    %eax,%edx
mov    $0xffffffd6,%ecx
xor    %r8d,%r8d
mov    %r14,%r9
call   1030 <CHECK@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   10b0 <set_bank_2@plt>
lea    0xd21(%rip),%r14
mov    $0x8,%edi
mov    $0x8,%esi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %r14,%r9
call   1030 <CHECK@plt>
mov    %ebx,%edi
mov    $0xffffff,%esi
call   10b0 <set_bank_2@plt>
mov    $0x8,%edi
mov    $0x9,%esi
mov    %eax,%edx
mov    $0xffffffd6,%ecx
xor    %r8d,%r8d
mov    %r14,%r9
add    $0x8,%rsp
pop    %rbx
pop    %r14
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 = [11 x i8] c"set bank 2\00"
define void @t8(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* %2
%6 = call i32 @gpio_write(i32 %5, i32 25, i32 0)
%7 = load i32, i32* %2
%8 = call i32 @read_bank_1(i32 %7)
%9 = and i32 %8, 33554432
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = call i32 @CHECK(i32 8, i32 1, i32 %10, i32 0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* %2
%13 = call i32 @gpio_write(i32 %12, i32 25, i32 1)
%14 = load i32, i32* %2
%15 = call i32 @read_bank_1(i32 %14)
%16 = and i32 %15, 33554432
store i32 %16, i32* %3
%17 = load i32, i32* %3
%18 = call i32 @CHECK(i32 8, i32 2, i32 %17, i32 33554432, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* %2
%20 = call i32 @clear_bank_1(i32 %19, i32 33554432)
%21 = load i32, i32* %2
%22 = call i32 @gpio_read(i32 %21, i32 25)
store i32 %22, i32* %3
%23 = load i32, i32* %3
%24 = call i32 @CHECK(i32 8, i32 3, i32 %23, i32 0, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%25 = load i32, i32* %2
%26 = call i32 @set_bank_1(i32 %25, i32 33554432)
%27 = load i32, i32* %2
%28 = call i32 @gpio_read(i32 %27, i32 25)
store i32 %28, i32* %3
%29 = load i32, i32* %3
%30 = call i32 @CHECK(i32 8, i32 4, i32 %29, i32 1, i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%31 = load i32, i32* %2
%32 = call i32 @read_bank_2(i32 %31)
store i32 %32, i32* %3
%33 = load i32, i32* %3
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %1
store i32 0, i32* %3
br label %37
36: ; preds = %1
store i32 1, i32* %3
br label %37
37: ; preds = %36, %35
%38 = load i32, i32* %3
%39 = call i32 @CHECK(i32 8, i32 5, i32 %38, i32 0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%40 = load i32, i32* %2
%41 = call i32 @clear_bank_2(i32 %40, i32 0)
store i32 %41, i32* %3
%42 = load i32, i32* %3
%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 = load i32, i32* %2
%45 = call i32 @clear_bank_2(i32 %44, i32 16777215)
store i32 %45, i32* %3
%46 = load i32, i32* %3
%47 = call i32 @CHECK(i32 8, i32 7, i32 %46, i32 -42, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%48 = load i32, i32* %2
%49 = call i32 @set_bank_2(i32 %48, i32 0)
store i32 %49, i32* %3
%50 = load i32, i32* %3
%51 = call i32 @CHECK(i32 8, i32 8, i32 %50, i32 0, i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%52 = load i32, i32* %2
%53 = call i32 @set_bank_2(i32 %52, i32 16777215)
store i32 %53, i32* %3
%54 = load i32, i32* %3
%55 = call i32 @CHECK(i32 8, i32 9, i32 %54, i32 -42, i32 0, i8* getelementptr inbounds ([11 x i8], [11 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 = [11 x i8] c"set bank 2\00"
@str = [23 x i8] c"Bank read/write tests.\00"
define void @t8(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @gpio_write(i32 %0, i32 25, i32 0)
%4 = tail call i32 @read_bank_1(i32 %0)
%5 = and i32 %4, 33554432
%6 = tail call i32 @CHECK(i32 8, i32 1, i32 %5, i32 0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @gpio_write(i32 %0, i32 25, i32 1)
%8 = tail call i32 @read_bank_1(i32 %0)
%9 = and i32 %8, 33554432
%10 = tail call i32 @CHECK(i32 8, i32 2, i32 %9, i32 33554432, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @clear_bank_1(i32 %0, i32 33554432)
%12 = tail call i32 @gpio_read(i32 %0, i32 25)
%13 = tail call i32 @CHECK(i32 8, i32 3, i32 %12, i32 0, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%14 = tail call i32 @set_bank_1(i32 %0, i32 33554432)
%15 = tail call i32 @gpio_read(i32 %0, i32 25)
%16 = tail call i32 @CHECK(i32 8, i32 4, i32 %15, i32 1, i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%17 = tail call i32 @read_bank_2(i32 %0)
%18 = icmp eq i32 %17, 0
%19 = zext i1 %18 to i32
%20 = tail call i32 @CHECK(i32 8, i32 5, i32 %19, i32 0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%21 = tail call i32 @clear_bank_2(i32 %0, i32 0)
%22 = tail call i32 @CHECK(i32 8, i32 6, i32 %21, i32 0, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%23 = tail call i32 @clear_bank_2(i32 %0, i32 16777215)
%24 = tail call i32 @CHECK(i32 8, i32 7, i32 %23, i32 -42, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%25 = tail call i32 @set_bank_2(i32 %0, i32 0)
%26 = tail call i32 @CHECK(i32 8, i32 8, i32 %25, i32 0, i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%27 = tail call i32 @set_bank_2(i32 %0, i32 16777215)
%28 = tail call i32 @CHECK(i32 8, i32 9, i32 %27, i32 -42, i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
ret void
}