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


x86 assembly (clang, -O0):
<t8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe51(%rip),%rdi
call   1060 <printf@plt>
mov    $0x19,%edi
xor    %esi,%esi
call   1070 <gpio_write@plt>
mov    $0x0,%al
call   10c0 <read_bank_1@plt>
and    $0x2000000,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edx
mov    $0x8,%edi
mov    $0x1,%esi
xor    %r8d,%r8d
lea    0xe32(%rip),%r9
mov    %r8d,%ecx
call   1030 <CHECK@plt>
mov    $0x19,%edi
mov    $0x1,%esi
call   1070 <gpio_write@plt>
mov    $0x0,%al
call   10c0 <read_bank_1@plt>
and    $0x2000000,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edx
mov    $0x8,%edi
mov    $0x2,%esi
mov    $0x2000000,%ecx
xor    %r8d,%r8d
lea    0xdf0(%rip),%r9
call   1030 <CHECK@plt>
mov    $0x2000000,%edi
call   1040 <clear_bank_1@plt>
mov    $0x19,%edi
call   1090 <gpio_read@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edx
mov    $0x8,%edi
mov    $0x3,%esi
xor    %r8d,%r8d
lea    0xdc9(%rip),%r9
mov    %r8d,%ecx
call   1030 <CHECK@plt>
mov    $0x2000000,%edi
call   1050 <set_bank_1@plt>
mov    $0x19,%edi
call   1090 <gpio_read@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edx
mov    $0x8,%edi
mov    $0x4,%esi
mov    $0x1,%ecx
xor    %r8d,%r8d
lea    0xd9b(%rip),%r9
call   1030 <CHECK@plt>
mov    $0x0,%al
call   1080 <read_bank_2@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     12bb <t8+0x11b>
movl   $0x0,-0x4(%rbp)
jmp    12c2 <t8+0x122>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%edx
mov    $0x8,%edi
mov    $0x5,%esi
xor    %r8d,%r8d
lea    0xd63(%rip),%r9
mov    %r8d,%ecx
call   1030 <CHECK@plt>
xor    %edi,%edi
call   10a0 <clear_bank_2@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edx
mov    $0x8,%edi
mov    $0x6,%esi
xor    %r8d,%r8d
lea    0xd46(%rip),%r9
mov    %r8d,%ecx
call   1030 <CHECK@plt>
mov    $0xffffff,%edi
call   10a0 <clear_bank_2@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edx
mov    $0x8,%edi
mov    $0x7,%esi
mov    $0xffffffd6,%ecx
xor    %r8d,%r8d
lea    0xd15(%rip),%r9
call   1030 <CHECK@plt>
xor    %edi,%edi
call   10b0 <set_bank_2@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edx
mov    $0x8,%esi
xor    %r8d,%r8d
lea    0xd01(%rip),%r9
mov    %esi,%edi
mov    %r8d,%ecx
call   1030 <CHECK@plt>
mov    $0xffffff,%edi
call   10b0 <set_bank_2@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edx
mov    $0x8,%edi
mov    $0x9,%esi
mov    $0xffffffd6,%ecx
xor    %r8d,%r8d
lea    0xcce(%rip),%r9
call   1030 <CHECK@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t8>:
push   %rbx
lea    0xea0(%rip),%rdi
call   1040 <puts@plt>
mov    $0x19,%edi
xor    %esi,%esi
call   1070 <gpio_write@plt>
xor    %eax,%eax
call   10c0 <read_bank_1@plt>
and    $0x2000000,%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    $0x19,%edi
mov    $0x1,%esi
call   1070 <gpio_write@plt>
xor    %eax,%eax
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    %rbx,%r9
call   1030 <CHECK@plt>
mov    $0x2000000,%edi
call   1050 <clear_bank_1@plt>
mov    $0x19,%edi
call   1090 <gpio_read@plt>
lea    0xdd5(%rip),%r9
mov    $0x8,%edi
mov    $0x3,%esi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <CHECK@plt>
mov    $0x2000000,%edi
call   1060 <set_bank_1@plt>
mov    $0x19,%edi
call   1090 <gpio_read@plt>
lea    0xdb1(%rip),%r9
mov    $0x8,%edi
mov    $0x4,%esi
mov    %eax,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1030 <CHECK@plt>
xor    %eax,%eax
call   1080 <read_bank_2@plt>
xor    %edx,%edx
test   %eax,%eax
sete   %dl
lea    0xd8e(%rip),%r9
mov    $0x8,%edi
mov    $0x5,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <CHECK@plt>
xor    %edi,%edi
call   10a0 <clear_bank_2@plt>
lea    0xd78(%rip),%rbx
mov    $0x8,%edi
mov    $0x6,%esi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %rbx,%r9
call   1030 <CHECK@plt>
mov    $0xffffff,%edi
call   10a0 <clear_bank_2@plt>
mov    $0x8,%edi
mov    $0x7,%esi
mov    %eax,%edx
mov    $0xffffffd6,%ecx
xor    %r8d,%r8d
mov    %rbx,%r9
call   1030 <CHECK@plt>
xor    %edi,%edi
call   10b0 <set_bank_2@plt>
lea    0xd38(%rip),%rbx
mov    $0x8,%edi
mov    $0x8,%esi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %rbx,%r9
call   1030 <CHECK@plt>
mov    $0xffffff,%edi
call   10b0 <set_bank_2@plt>
mov    $0x8,%edi
mov    $0x9,%esi
mov    %eax,%edx
mov    $0xffffffd6,%ecx
xor    %r8d,%r8d
mov    %rbx,%r9
pop    %rbx
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() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @gpio_write(i32 25, i32 0)
%4 = call i32 (...) @read_bank_1()
%5 = and i32 %4, 33554432
store i32 %5, i32* %1
%6 = load i32, i32* %1
%7 = call i32 @CHECK(i32 8, i32 1, i32 %6, i32 0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @gpio_write(i32 25, i32 1)
%9 = call i32 (...) @read_bank_1()
%10 = and i32 %9, 33554432
store i32 %10, i32* %1
%11 = load i32, i32* %1
%12 = call i32 @CHECK(i32 8, i32 2, i32 %11, i32 33554432, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @clear_bank_1(i32 33554432)
%14 = call i32 @gpio_read(i32 25)
store i32 %14, i32* %1
%15 = load i32, i32* %1
%16 = call i32 @CHECK(i32 8, i32 3, i32 %15, i32 0, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @set_bank_1(i32 33554432)
%18 = call i32 @gpio_read(i32 25)
store i32 %18, i32* %1
%19 = load i32, i32* %1
%20 = call i32 @CHECK(i32 8, i32 4, i32 %19, i32 1, i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 (...) @read_bank_2()
store i32 %21, i32* %1
%22 = load i32, i32* %1
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %0
store i32 0, i32* %1
br label %26
25: ; preds = %0
store i32 1, i32* %1
br label %26
26: ; preds = %25, %24
%27 = load i32, i32* %1
%28 = call i32 @CHECK(i32 8, i32 5, i32 %27, i32 0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%29 = call i32 @clear_bank_2(i32 0)
store i32 %29, i32* %1
%30 = load i32, i32* %1
%31 = call i32 @CHECK(i32 8, i32 6, i32 %30, i32 0, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%32 = call i32 @clear_bank_2(i32 16777215)
store i32 %32, i32* %1
%33 = load i32, i32* %1
%34 = call i32 @CHECK(i32 8, i32 7, i32 %33, i32 -42, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%35 = call i32 @set_bank_2(i32 0)
store i32 %35, i32* %1
%36 = load i32, i32* %1
%37 = call i32 @CHECK(i32 8, i32 8, i32 %36, i32 0, i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%38 = call i32 @set_bank_2(i32 16777215)
store i32 %38, i32* %1
%39 = load i32, i32* %1
%40 = call i32 @CHECK(i32 8, i32 9, i32 %39, 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() {
%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 @gpio_write(i32 25, i32 0)
%3 = tail call i32 (...) @read_bank_1()
%4 = and i32 %3, 33554432
%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 @gpio_write(i32 25, i32 1)
%7 = tail call i32 (...) @read_bank_1()
%8 = and i32 %7, 33554432
%9 = tail call i32 @CHECK(i32 8, i32 2, i32 %8, i32 33554432, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @clear_bank_1(i32 33554432)
%11 = tail call i32 @gpio_read(i32 25)
%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 @set_bank_1(i32 33554432)
%14 = tail call i32 @gpio_read(i32 25)
%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))
%16 = tail call i32 (...) @read_bank_2()
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
%19 = tail call i32 @CHECK(i32 8, i32 5, i32 %18, i32 0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%20 = tail call i32 @clear_bank_2(i32 0)
%21 = tail call i32 @CHECK(i32 8, i32 6, i32 %20, i32 0, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%22 = tail call i32 @clear_bank_2(i32 16777215)
%23 = tail call i32 @CHECK(i32 8, i32 7, i32 %22, i32 -42, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%24 = tail call i32 @set_bank_2(i32 0)
%25 = tail call i32 @CHECK(i32 8, i32 8, i32 %24, i32 0, i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%26 = tail call i32 @set_bank_2(i32 16777215)
%27 = tail call i32 @CHECK(i32 8, i32 9, i32 %26, i32 -42, i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
ret void
}